見出し画像

Google AI Studio のクイックスタートを試しました(テキストと画像を使ってプロンプトを作成)

クイックスタート

Google AI Studio

次の写真をSNSで公開する場合、どんなタイトルがいいでしょうか

RUN

変数を使用してプロンプトをパラメータ化

Add text example

RUN

Get API key

Get code

Open in Colab

!pip install google-generativelanguage

ERROR: Could not find a version that satisfies the requirement google-generativelanguage (from versions: none)
ERROR: No matching distribution found for google-generativelanguage

※エラーが出るのでGoogleで調べ、他のサイトを参考に以下で実行。

#!pip install google-generativelanguage
!pip install -q -U google-generativeai

Add your API_KEY to the secrets manager

※取得したコードではデフォルトでプロンプトとイメージは以下。
※Google AI Studioで試したプロンプトや画像が反映されるわけではなかった。

contents = '[{"parts": [{"text":"what\'s in this picture:"}, {"image": {"image_url": "https://storage.googleapis.com/generativeai-downloads/images/scones.jpg"}}]}]' 

生成結果

if generation_config.get('candidate_count', 1) == 1:
  display(Markdown(response.text))
else:
  print(response.candidates)

There are four blueberry scones, a bowl of blueberries, two cups of coffee, a spoon that says "Let's Jam", and some pink flowers.

※プロンプト部分を変更。

if generation_config.get('candidate_count', 1) == 1:
  display(Markdown(response.text))
else:
  print(response.candidates)

ブルーベリーのスコーン、ブルーベリー、コーヒー、花


この記事が気に入ったらサポートをしてみませんか?