1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Chat GPTみたいにちゃんと答えてくれる

しかもけっこうかんたんにつかえる。

Colabサンプル

使い方

インストール

git clone https://github.com/facebookresearch/llama.git
cd llama
pip install -e .

モデルダウンロード

以下のリンクで名前やメールを登録して、ダウンロードURLをもらう。
自分はLlama2を選びました。

Meta website

bash download.sh

上記スクリプトを実行すると、ダウンロードURLを聞かれるので、メールでもらったURLを入力する。
ダウンロードするモデルを聞かれるので、リストから入力します。
今回はチャットしたいので
7b-chat
を選びました。

実行

example_chat_completion.py の以下の dialogs の "content" 部分を自分のしたい質問に書き換えます。

example_chat_completion.py
dialogs: List[Dialog] = [
        [{"role": "user", "content": "What is the best diet method to lose weight?"}]
    ]

example_chat_completion.py を実行

torchrun --nproc_per_node 1 example_chat_completion.py \
    --ckpt_dir llama-2-7b-chat/ \
    --tokenizer_path tokenizer.model \
    --max_seq_len 512 --max_batch_size 6

User: What is the best diet method to lose weight?

Assistant: The best diet method for weight loss is one that is sustainable, tailored to your individual needs, and focuses on a balanced and healthy eating pattern. Here are some effective diet methods for weight loss:

  1. Calorie Deficit: The most common method for weight loss is to create a calorie deficit by reducing daily caloric intake. This can be achieved by reducing portion sizes, cutting back on high-calorie foods, and increasing physical activity. Aim for a deficit of 500-1000 calories per day for safe and sustainable weight loss.
  2. Mediterranean Diet: The Mediterranean diet is a balanced and sustainable eating pattern that emphasizes whole grains, fruits, vegetables, lean protein, and healthy fats. It has been shown to promote weight loss and improve overall health.
  3. Plant-Based Diet: A plant-based diet that focuses on fruits, vegetables, whole grains, and lean protein can be an effective way to lose weight and improve overall health. This diet can help reduce inflammation and improve insulin sensitivity, which can lead to weight loss.
  4. Portion Control: Controlling portion sizes is an effective way to lose weight without restricting certain foods. Use a food diary or app to track your daily food intake and adjust your portion sizes accordingly.
  5. Intermittent Fasting: Intermittent fasting involves restricting calorie intake for certain periods of time. There are several types of intermittent fasting, including 16:8, 5:2, and alternate-day fasting. This method can lead to weight loss and improve insulin sensitivity.
  6. Low-Carb Diet: A low-carb diet restricts the intake of carbohydrates, such as sugar, bread, and pasta. This can lead to weight loss and improve insulin sensitivity. However, it may not be suitable for everyone, especially those with diabetes or other health conditions.
  7. High-Protein Diet: A high-protein diet can help promote weight loss by reducing hunger and increasing feelings of fullness. Aim

==================================

アシスタント: 減量に最適なダイエット方法は、持続可能で、個人のニーズに合わせて調整され、バランスのとれた健康的な食事パターンに焦点を当てたものです。 ここでは、体重を減らすための効果的なダイエット方法をいくつか紹介します。

  1. カロリー不足: 体重を減らすための最も一般的な方法は、毎日のカロリー摂取量を減らしてカロリー不足を作り出すことです。 これは、分量を減らし、高カロリーの食品を減らし、身体活動を増やすことで達成できます。 安全かつ持続的に減量するには、1 日あたり 500 ~ 1000 カロリーの不足を目指します。
  2. 地中海食: 地中海食は、全粒穀物、果物、野菜、脂肪分の少ないタンパク質、健康的な脂肪を重視した、バランスのとれた持続可能な食事パターンです。 体重減少を促進し、全体的な健康状態を改善することが証明されています。
  3. 植物ベースの食事: 果物、野菜、全粒穀物、脂肪分の少ないタンパク質に重点を置いた植物ベースの食事は、体重を減らし、全体的な健康状態を改善する効果的な方法となります。 この食事療法は炎症を軽減し、インスリン感受性を改善するのに役立ち、体重減少につながる可能性があります。
  4. 分量のコントロール: 分量をコントロールすることは、特定の食品を制限せずに体重を減らす効果的な方法です。 食事日記やアプリを使用して毎日の食事摂取量を追跡し、それに応じて分量を調整します。
  5. 断続的断食: 断続的断食には、一定期間のカロリー摂取制限が含まれます。 間欠的断食には、16:8、5:2、隔日断食など、いくつかの種類があります。 この方法は体重減少につながり、インスリン感受性を改善する可能性があります。
  6. 低炭水化物ダイエット: 低炭水化物ダイエットでは、砂糖、パン、パスタなどの炭水化物の摂取を制限します。 これにより、体重が減少し、インスリン感受性が改善される可能性があります。 ただし、すべての人、特に糖尿病やその他の健康状態のある人に適しているわけではありません。
  7. 高タンパク質の食事: 高タンパク質の食事は、空腹感を軽減し、満腹感を高めることで減量を促進します。 標的

めっちゃちゃんと答えてくれる。

コードも書いてくれる。が、ちゃんとは動かなかったし、ChatGPTの方が動くコードを書いてくれる。

User: Code to improve the image quality of human images by improving their skin color using python.

Assistant: Improving the image quality of human images by enhancing their skin color can be achieved through various techniques in image processing. Here's a basic approach using Python and OpenCV:

  1. Load the image: Load the image you want to improve using OpenCV's cv2.imread() function.
  2. Convert to HSV color space: Convert the image to the HSV (Hue, Saturation, Value) color space using OpenCV's cv2.cvtColor() function. This separation of colors allows for more precise adjustments.
  3. Thresholding: Apply a threshold to the HSV image to separate the skin tone from the rest of the image. You can use OpenCV's cv2.inRange() function to threshold the image based on the skin tone range.
  4. Histogram equalization: Use histogram equalization to enhance the contrast of the skin tone. This can be done using OpenCV's cv2.equalizeHist() function.
  5. Color correction: Apply color correction to the skin tone using OpenCV's cv2.cvtColor() function. This can involve adjusting the red, green, and blue channels to match the desired skin tone.
  6. Skin tone mapping: Use a skin tone mapping algorithm to improve the overall quality of the skin tone. OpenCV provides several built-in skin tone mapping functions, such as cv2.SkinToneMapping() and cv2.SkinToneCorrection().
  7. Save the image: Finally, save the improved image using OpenCV's cv2.imwrite() function.
    Here's some sample code to demonstrate these steps:
import cv2
# Load the image
img = cv2.imread('image.jpg')
# Convert to HSV color space
hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
# Thresholding
lower_red = (0, 0, 100)
upper_red = (60, 255, 255)
red_channel = cv2.inRange(hsv, lower_red, upper_red)
# Histogram equalization
eq = cv2.equalizeHist(red_channel)

# Color correction
color_corrected = cv2.cvtColor(eq, cv2.COLOR_HSV2BGR)

# Skin tone mapping
skin_tone = cv2.SkinToneMapping(color_corrected)

# Save the image
cv2.imwrite('output.jpg', skin_tone)

==================================

🐣


フリーランスエンジニアです。
AIについて色々記事を書いていますのでよかったらプロフィールを見てみてください。

もし以下のようなご要望をお持ちでしたらお気軽にご相談ください。
AIサービスを開発したい、ビジネスにAIを組み込んで効率化したい、AIを使ったスマホアプリを開発したい、
ARを使ったアプリケーションを作りたい、スマホアプリを作りたいけどどこに相談したらいいかわからない…

いずれも中間コストを省いたリーズナブルな価格でお請けできます。

お仕事のご相談はこちらまで
rockyshikoku@gmail.com

機械学習やAR技術を使ったアプリケーションを作っています。
機械学習/AR関連の情報を発信しています。

X
Medium
GitHub

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?