Gemini Robotics-ER 1.5

Gemini Robotics-ER 1.5 は、Gemini のエージェント機能をロボット工学に導入する視覚言語モデル(VLM)です。物理世界での高度な推論用に設計されており、ロボットが複雑な視覚データを解釈し、空間推論を実行し、自然言語コマンドからアクションを計画できます。

主な機能と利点:

  • 自律性の向上: ロボットは、オープンエンドの環境の変化を推論、適応、応答できます。
  • 自然言語によるインタラクション: 自然言語を使用して複雑なタスクを割り当てることができるため、ロボットを簡単に使用できます。
  • タスク オーケストレーション: 自然言語コマンドをサブタスクに分解し、既存のロボット コントローラと動作を統合して、長期的なタスクを完了します。
  • 多機能: オブジェクトの特定と識別、オブジェクトの関係の理解、把持と軌道の計画、動的なシーンの解釈を行います。

このドキュメントでは、モデルの機能について説明し、モデルのエージェント機能を示すをいくつか紹介します。

すぐに試したい場合は、Google AI Studio でモデルを試すことができます。

Google AI Studio で試す

安全性

Gemini Robotics-ER 1.5 は安全性を考慮して構築されていますが、ロボットの周囲の安全な環境を維持するのはお客様の責任です。生成 AI モデルは間違えることがあり、物理的なロボットは損傷を引き起こす可能性があります。安全性は優先事項であり、現実世界のロボット工学で使用される生成 AI モデルを安全にすることは、Google の研究の活発かつ重要な分野です。詳しくは、Google DeepMind のロボット工学の安全性に関するページをご覧ください。

スタートガイド: シーン内のオブジェクトを見つける

次の例は、一般的なロボット工学のユースケースを示しています。このサンプルでは、generateContent メソッドを使用して画像とテキスト プロンプトをモデルに渡し、識別されたオブジェクトのリストと対応する 2D ポイントを取得する方法を示します。モデルは、画像内で識別したアイテムのポイントを返し、正規化された 2D 座標とラベルを返します。

この出力は、ロボット工学 API で使用したり、ビジョン言語アクション(VLA)モデルや他のサードパーティのユーザー定義関数を呼び出して、ロボットが実行するアクションを生成したりできます。

Python

from google import genai
from google.genai import types

import IPython
from PIL import Image

# Initialize the GenAI client and specify the model
MODEL_ID = "gemini-robotics-er-1.5-preview"
PROMPT = """
          Point to no more than 10 items in the image. The label returned
          should be an identifying name for the object detected.
          The answer should follow the json format: [{"point": <point>,
          "label": <label1>}, ...]. The points are in [y, x] format
          normalized to 0-1000.
        """
client = genai.Client()

# Load your image
img = Image.open("my-image.png")
img = img.resize((800, int(800 * img.size[1] / img.size[0])), Image.Resampling.LANCZOS) # Resizing to speed-up rendering

image_response = client.models.generate_content(
    model=MODEL_ID,
    contents=[
        img,
        PROMPT
    ],
    config = types.GenerateContentConfig(
        temperature=0.5,
        thinking_config=types.ThinkingConfig(thinking_budget=0)
    )
)

print(image_response.text)

REST

# First, ensure you have the image file locally.
# Encode the image to base64
IMAGE_BASE64=$(base64 -w 0 my-image.png)

curl -X POST \
  "https://generativelanguage.googleapis.com/v1beta/models/gemini-robotics-er-1.5-preview:generateContent \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [
      {
        "parts": [
          {
            "inlineData": {
              "mimeType": "image/png",
              "data": "'"${IMAGE_BASE64}"'"
            }
          },
          {
            "text": "Point to no more than 10 items in the image. The label returned should be an identifying name for the object detected. The answer should follow the json format: [{\"point\": [y, x], \"label\": <label1>}, ...]. The points are in [y, x] format normalized to 0-1000."
          }
        ]
      }
    ],
    "generationConfig": {
      "temperature": 0.5,
      "thinkingConfig": {
        "thinkingBudget": 0
      }
    }
  }'

出力は、オブジェクトを含む JSON 配列になります。各オブジェクトには、point(正規化された [y, x] 座標)と、オブジェクトを識別する label が含まれます。

JSON

[
  {"point": [376, 508], "label": "small banana"},
  {"point": [287, 609], "label": "larger banana"},
  {"point": [223, 303], "label": "pink starfruit"},
  {"point": [435, 172], "label": "paper bag"},
  {"point": [270, 786], "label": "green plastic bowl"},
  {"point": [488, 775], "label": "metal measuring cup"},
  {"point": [673, 580], "label": "dark blue bowl"},
  {"point": [471, 353], "label": "light blue bowl"},
  {"point": [492, 497], "label": "bread"},
  {"point": [525, 429], "label": "lime"}
]

次の図は、これらのポイントを表示する方法の例です。

画像内のオブジェクトのポイントを表示する例

仕組み

Gemini Robotics-ER 1.5 を使用すると、ロボットは空間認識を使用して物理世界をコンテキスト化し、その中で作業できます。画像、動画、音声の入力と自然言語プロンプトを受け取り、次の処理を行います。

  • オブジェクトとシーンのコンテキストを理解する: オブジェクトを特定し、アフォーダンスなど、オブジェクトとシーンの関係について推論します。
  • タスクの指示を理解する: 「バナナを探して」などの自然言語で指定されたタスクを解釈します。
  • 空間的、時間的に推論する: 一連のアクションと、オブジェクトが時間とともにシーンとどのようにやり取りするかを理解します。
  • 構造化された出力を提供する: オブジェクトの位置を表す座標(点または境界ボックス)を返します。

これにより、ロボットが環境をプログラムで「認識」して「理解」できるようになります。

Gemini Robotics-ER 1.5 はエージェント機能も備えています。つまり、「りんごをボウルに入れる」などの複雑なタスクをサブタスクに分解して、長期的なタスクを調整できます。

  • サブタスクの順序付け: コマンドを論理的な手順のシーケンスに分解します。
  • 関数呼び出し/コード実行: 既存のロボット関数/ツールを呼び出すか、生成されたコードを実行して手順を実行します。

Gemini の関数呼び出しの仕組みについては、関数呼び出しのページをご覧ください。

Gemini Robotics-ER 1.5 で思考予算を使用する

Gemini Robotics-ER 1.5 には、レイテンシと精度のトレードオフを制御できる柔軟な思考予算があります。オブジェクト検出などの空間認識タスクでは、モデルは少ない思考予算で高いパフォーマンスを実現できます。カウントや重み推定などの複雑な推論タスクでは、思考予算が大きいほどメリットがあります。これにより、より難しいタスクで、低レイテンシのレスポンスと高精度の結果のバランスを取ることができます。

思考バジェットの詳細については、思考のコア機能のページをご覧ください。

ロボット工学のエージェント機能

このセクションでは、Gemini Robotics-ER 1.5 のさまざまな機能について説明し、ロボットの認識、推論、計画のアプリケーションでモデルを使用する方法を示します。

このセクションの例では、画像内のオブジェクトのポイントと検索から、軌道の計画と長期間のタスクのオーケストレーションまでの機能を示します。コード スニペットは、プロンプトと generate_content API の呼び出しを示すために簡略化されています。実行可能な完全なコードと追加の例は、ロボティクス クックブックで確認できます。

オブジェクトを指す

画像や動画フレーム内のオブジェクトを指し示して見つけることは、ロボット工学におけるビジョン言語モデル(VLM)の一般的なユースケースです。次の例では、画像内の特定のオブジェクトを見つけて、その座標を画像で返すようにモデルに指示しています。

Python

from google import genai
from google.genai import types

# Initialize the GenAI client and specify the model
MODEL_ID = "gemini-robotics-er-1.5-preview"
client = genai.Client()

# Load your image and set up your prompt
  with open('path/to/image-with-objects.jpg', 'rb') as f:
      image_bytes = f.read()

queries = [
    "bread",
    "starfruit",
    "banana",
]

prompt = f"""
    Get all points matching the following objects: {', '.join(queries)}. The
    label returned should be an identifying name for the object detected.
    The answer should follow the json format:
    [\{\{"point": <point>, "label": <label1>\}\}, ...]. The points are in
    [y, x] format normalized to 0-1000.
    """

image_response = client.models.generate_content(
  model=MODEL_ID,
  contents=[
    types.Part.from_bytes(
      data=image_bytes,
      mime_type='image/jpeg',
    ),
    prompt
  ],
  config = types.GenerateContentConfig(
      temperature=0.5,
      thinking_config=types.ThinkingConfig(thinking_budget=0)
  )
)

print(image_response.text)

出力は、スタートガイドの例と同様に、検出されたオブジェクトの座標とそのラベルを含む JSON になります。

[
  {"point": [671, 317], "label": "bread"},
  {"point": [738, 307], "label": "bread"},
  {"point": [702, 237], "label": "bread"},
  {"point": [629, 307], "label": "bread"},
  {"point": [833, 800], "label": "bread"},
  {"point": [609, 663], "label": "banana"},
  {"point": [770, 483], "label": "starfruit"}
]

画像内で識別されたオブジェクトのポイントを表示する例

次のプロンプトを使用して、特定のオブジェクトではなく「果物」などの抽象的なカテゴリを解釈し、画像内のすべてのインスタンスを特定するようにモデルにリクエストします。

Python

prompt = f"""
        Get all points for fruit. The label returned should be an identifying
        name for the object detected.
        """ + """The answer should follow the json format:
        [{"point": <point>, "label": <label1>}, ...]. The points are in
        [y, x] format normalized to 0-1000."""

他の画像処理手法については、画像理解のページをご覧ください。

動画内のオブジェクトのトラッキング

Gemini Robotics-ER 1.5 は、動画フレームを分析して、オブジェクトを時間経過とともに追跡することもできます。サポートされている動画形式の一覧については、動画入力をご覧ください。

モデルが分析する各フレーム内の特定のオブジェクトを見つけるために使用される基本プロンプトは次のとおりです。

Python

# Define the objects to find
queries = [
    "pen (on desk)",
    "pen (in robot hand)",
    "laptop (opened)",
    "laptop (closed)",
]

base_prompt = f"""
  Point to the following objects in the provided image: {', '.join(queries)}.
  The answer should follow the json format:
  [\{\{"point": <point>, "label": <label1>\}\}, ...].
  The points are in [y, x] format normalized to 0-1000.
  If no objects are found, return an empty JSON list [].
  """

出力には、動画フレーム全体でペンとノートパソコンが追跡されている様子が表示されます。

GIF のフレームでオブジェクトが追跡されている例

実行可能なコードの完全版については、ロボティクス クックブックをご覧ください。

オブジェクトの検出と境界ボックス

単一のポイントだけでなく、モデルは 2D 境界ボックスを返すこともできます。これは、オブジェクトを囲む長方形の領域です。

この例では、テーブル上の識別可能なオブジェクトの 2D 境界ボックスをリクエストしています。モデルは、出力を 25 個のオブジェクトに制限し、複数のインスタンスに一意の名前を付けるように指示されています。

Python

from google import genai
from google.genai import types

# Initialize the GenAI client and specify the model
MODEL_ID = "gemini-robotics-er-1.5-preview"
client = genai.Client()

# Load your image and set up your prompt
  with open('path/to/image-with-objects.jpg', 'rb') as f:
      image_bytes = f.read()

prompt = """
      Return bounding boxes as a JSON array with labels. Never return masks
      or code fencing. Limit to 25 objects. Include as many objects as you
      can identify on the table.
      If an object is present multiple times, name them according to their
      unique characteristic (colors, size, position, unique characteristics, etc..).
      The format should be as follows: [{"box_2d": [ymin, xmin, ymax, xmax],
      "label": <label for the object>}] normalized to 0-1000. The values in
      box_2d must only be integers
      """

  image_response = client.models.generate_content(
    model=MODEL_ID,
    contents=[
      types.Part.from_bytes(
        data=image_bytes,
        mime_type='image/jpeg',
      ),
      prompt
    ],
    config = types.GenerateContentConfig(
        temperature=0.5,
        thinking_config=types.ThinkingConfig(thinking_budget=0)
    )
  )

  print(image_response.text)

次の図は、モデルから返されたボックスを示しています。

検出されたオブジェクトの境界ボックスを示す例

実行可能なコードの全文については、ロボティクス クックブックをご覧ください。[画像理解] ページには、セグメンテーションやオブジェクト検出などの視覚タスクの追加の例もあります。

境界ボックスのその他の例については、画像理解のページをご覧ください。

軌跡

Gemini Robotics-ER 1.5 は、ロボットの動きをガイドするのに役立つ、軌跡を定義する一連のポイントを生成できます。

この例では、赤いペンをオーガナイザーに移動する軌跡をリクエストしています。これには、開始点と一連の中間点が含まれます。

Python

from google import genai
from google.genai import types

# Initialize the GenAI client and specify the model
MODEL_ID = "gemini-robotics-er-1.5-preview"
client = genai.Client()

# Load your image and set up your prompt
  with open('path/to/image-with-objects.jpg', 'rb') as f:
      image_bytes = f.read()

points_data = []
prompt = """
        Place a point on the red pen, then 15 points for the trajectory of
        moving the red pen to the top of the organizer on the left.
        The points should be labeled by order of the trajectory, from '0'
        (start point at left hand) to <n> (final point)
        The answer should follow the json format:
        [{"point": <point>, "label": <label1>}, ...].
        The points are in [y, x] format normalized to 0-1000.
        """

  image_response = client.models.generate_content(
    model=MODEL_ID,
    contents=[
      types.Part.from_bytes(
        data=image_bytes,
        mime_type='image/jpeg',
      ),
      prompt
    ],
    config = types.GenerateContentConfig(
        temperature=0.5,
    )
  )

  print(image_response.text)

レスポンスは、赤いペンをオーガナイザーの上に移動させるタスクを完了するために赤いペンがたどるべきパスの軌跡を表す一連の座標です。

[
  {"point": [550, 610], "label": "0"},
  {"point": [500, 600], "label": "1"},
  {"point": [450, 590], "label": "2"},
  {"point": [400, 580], "label": "3"},
  {"point": [350, 550], "label": "4"},
  {"point": [300, 520], "label": "5"},
  {"point": [250, 490], "label": "6"},
  {"point": [200, 460], "label": "7"},
  {"point": [180, 430], "label": "8"},
  {"point": [160, 400], "label": "9"},
  {"point": [140, 370], "label": "10"},
  {"point": [120, 340], "label": "11"},
  {"point": [110, 320], "label": "12"},
  {"point": [105, 310], "label": "13"},
  {"point": [100, 305], "label": "14"},
  {"point": [100, 300], "label": "15"}
]

計画された軌道を示す例

オーケストレーション

Gemini Robotics-ER 1.5 は、コンテキストの理解に基づいてアクションを推論したり、最適な場所を特定したりするなど、より高度な空間推論を実行できます。

ノートパソコンを置くスペースを確保する

この例では、Gemini Robotics-ER が空間について推論する方法を示します。このプロンプトでは、別のアイテムのためのスペースを作るためにどのオブジェクトを移動する必要があるかを特定するようモデルに指示しています。

Python

from google import genai
from google.genai import types

# Initialize the GenAI client and specify the model
MODEL_ID = "gemini-robotics-er-1.5-preview"
client = genai.Client()

# Load your image and set up your prompt
  with open('path/to/image-with-objects.jpg', 'rb') as f:
      image_bytes = f.read()

prompt = """
          Point to the object that I need to remove to make room for my laptop
          The answer should follow the json format: [{"point": <point>,
          "label": <label1>}, ...]. The points are in [y, x] format normalized to 0-1000.
        """

  image_response = client.models.generate_content(
    model=MODEL_ID,
    contents=[
      types.Part.from_bytes(
        data=image_bytes,
        mime_type='image/jpeg',
      ),
      prompt
    ],
    config = types.GenerateContentConfig(
        temperature=0.5,
        thinking_config=types.ThinkingConfig(thinking_budget=0)
    )
  )

  print(image_response.text)

レスポンスには、ユーザーの質問に答えるオブジェクトの 2D 座標が含まれています。この場合、ノートパソコンを置くために移動する必要があるオブジェクトです。

[
  {"point": [672, 301], "label": "The object that I need to remove to make room for my laptop"}
]

別のオブジェクトのために移動する必要があるオブジェクトを示す例

ランチの準備

モデルは、複数ステップのタスクの手順を提供し、各ステップに関連するオブジェクトを指すこともできます。この例では、モデルがランチバッグに詰める一連の手順を計画する方法を示します。

Python

from google import genai
from google.genai import types

# Initialize the GenAI client and specify the model
MODEL_ID = "gemini-robotics-er-1.5-preview"
client = genai.Client()

# Load your image and set up your prompt
  with open('path/to/image-of-lunch.jpg', 'rb') as f:
      image_bytes = f.read()

prompt = """
          Explain how to pack the lunch box and lunch bag. Point to each
          object that you refer to. Each point should be in the format:
          [{"point": [y, x], "label": }], where the coordinates are
          normalized between 0-1000.
        """

  image_response = client.models.generate_content(
    model=MODEL_ID,
    contents=[
      types.Part.from_bytes(
        data=image_bytes,
        mime_type='image/jpeg',
      ),
      prompt
    ],
    config = types.GenerateContentConfig(
        temperature=0.5,
        thinking_config=types.ThinkingConfig(thinking_budget=0)
    )
  )

  print(image_response.text)

このプロンプトのレスポンスは、画像入力からランチバッグを詰める方法に関する手順のセットです。

入力画像

弁当箱と弁当箱に入れる物の画像

モデル出力

Based on the image, here is a plan to pack the lunch box and lunch bag:

1.  **Pack the fruit into the lunch box.** Place the [apple](apple), [banana](banana), [red grapes](red grapes), and [green grapes](green grapes) into the [blue lunch box](blue lunch box).
2.  **Add the spoon to the lunch box.** Put the [blue spoon](blue spoon) inside the lunch box as well.
3.  **Close the lunch box.** Secure the lid on the [blue lunch box](blue lunch box).
4.  **Place the lunch box inside the lunch bag.** Put the closed [blue lunch box](blue lunch box) into the [brown lunch bag](brown lunch bag).
5.  **Pack the remaining items into the lunch bag.** Place the [blue snack bar](blue snack bar) and the [brown snack bar](brown snack bar) into the [brown lunch bag](brown lunch bag).

Here is the list of objects and their locations:
*   [{"point": [899, 440], "label": "apple"}]
*   [{"point": [814, 363], "label": "banana"}]
*   [{"point": [727, 470], "label": "red grapes"}]
*   [{"point": [675, 608], "label": "green grapes"}]
*   [{"point": [706, 529], "label": "blue lunch box"}]
*   [{"point": [864, 517], "label": "blue spoon"}]
*   [{"point": [499, 401], "label": "blue snack bar"}]
*   [{"point": [614, 705], "label": "brown snack bar"}]
*   [{"point": [448, 501], "label": "brown lunch bag"}]

カスタム ロボット API の呼び出し

この例では、カスタム ロボット API を使用したタスク オーケストレーションを示します。このサンプルでは、ピッキングと配置のオペレーション用に設計されたモック API を紹介します。青いブロックを拾ってオレンジ色のボウルに入れるタスクです。

ブロックとボウルの画像

このページの他の例と同様に、実行可能なコードの全文は Robotics cookbook で確認できます。

最初の手順は、次のプロンプトを使用して両方のアイテムを見つけることです。

Python

prompt = """
            Locate and point to the blue block and the orange bowl. The label
            returned should be an identifying name for the object detected.
            The answer should follow the json format: [{"point": <point>, "label": <label1>}, ...].
            The points are in [y, x] format normalized to 0-1000.
          """

モデルのレスポンスには、ブロックとボウルの正規化された座標が含まれます。

[
  {"point": [389, 252], "label": "orange bowl"},
  {"point": [727, 659], "label": "blue block"}
]

この例では、次のモックロボット API を使用します。

Python

def move(x, y, high):
  print(f"moving to coordinates: {x}, {y}, {15 if high else 5}")

def setGripperState(opened):
  print("Opening gripper" if opened else "Closing gripper")

def returnToOrigin():
  print("Returning to origin pose")

次のステップでは、アクションを実行するために必要なロジックを使用して、API 関数のシーケンスを呼び出します。次のプロンプトには、このタスクをオーケストレートするときにモデルが使用するロボット API の説明が含まれています。

Python

prompt = f"""
    You are a robotic arm with six degrees-of-freedom. You have the
    following functions available to you:

    def move(x, y, high):
      # moves the arm to the given coordinates. The boolean value 'high' set
      to True means the robot arm should be lifted above the scene for
      avoiding obstacles during motion. 'high' set to False means the robot
      arm should have the gripper placed on the surface for interacting with
      objects.

    def setGripperState(opened):
      # Opens the gripper if opened set to true, otherwise closes the gripper

    def returnToOrigin():
      # Returns the robot to an initial state. Should be called as a cleanup
      operation.

    The origin point for calculating the moves is at normalized point
    y={robot_origin_y}, x={robot_origin_x}. Use this as the new (0,0) for
    calculating moves, allowing x and y to be negative.
    Perform a pick and place operation where you pick up the blue block at
    normalized coordinates ({block_x}, {block_y}) (relative coordinates:
    {block_relative_x}, {block_relative_y}) and place it into the orange
    bowl at normalized coordinates ({bowl_x}, {bowl_y})
    (relative coordinates: {bowl_relative_x}, {bowl_relative_y}).
    Provide the sequence of function calls as a JSON list of objects, where
    each object has a "function" key (the function name) and an "args" key
    (a list of arguments for the function).
    Also, include your reasoning before the JSON output.
    For example:
    Reasoning: To pick up the block, I will first move the arm to a high
    position above the block, open the gripper, move down to the block,
    close the gripper, lift the arm, move to a high position above the bowl,
    move down to the bowl, open the gripper, and then lift the arm back to
    a high position.
"""

以下に、プロンプトとモックロボット API に基づくモデルの出力例を示します。出力には、モデルの思考プロセスと、その結果として計画されたタスクが含まれます。また、モデルが順序付けたロボット関数呼び出しの出力も表示されます。

Reasoning: To perform the pick and place operation, I will first move the
robotic arm to a high position above the blue block to ensure clearance. Then, I
will open the gripper in preparation for grasping. Next, I will lower the arm to
the surface level to position the gripper around the block and close the gripper
to secure it. After picking up the block, I will lift the arm to clear the
surface and move towards the orange bowl, maintaining a high position to avoid
collisions. Once positioned above the bowl, I will lower the arm to place the
block inside. I will then open the gripper to release the block. Finally, I will
lift the arm out of the bowl and call `returnToOrigin` to reset the robot's
state.

[
  {
    "function": "move",
    "args": [
      163,
      427,
      true
    ]
  },
  {
    "function": "setGripperState",
    "args": [
      true
    ]
  },
  {
    "function": "move",
    "args": [
      163,
      427,
      false
    ]
  },
  {
    "function": "setGripperState",
    "args": [
      false
    ]
  },
  {
    "function": "move",
    "args": [
      163,
      427,
      true
    ]
  },
  {
    "function": "move",
    "args": [
      -247,
      90,
      true
    ]
  },
  {
    "function": "move",
    "args": [
      -247,
      90,
      false
    ]
  },
  {
    "function": "setGripperState",
    "args": [
      true
    ]
  },
  {
    "function": "move",
    "args": [
      -247,
      90,
      true
    ]
  },
  {
    "function": "returnToOrigin",
    "args": []
  }
]


Executing Function Calls:
moving to coordinates: 163, 427, 15
Opening gripper
moving to coordinates: 163, 427, 5
Closing gripper
moving to coordinates: 163, 427, 15
moving to coordinates: -247, 90, 15
moving to coordinates: -247, 90, 5
Opening gripper
moving to coordinates: -247, 90, 15
Returning to origin pose

コードの実行

Gemini Robotics-ER 1.5 は、画像領域を拡大して詳細を確認するなど、動的なアクションが必要なタスクを実行するための Python コードを提案して実行できます。

この例では、モデルがコード実行ツールを使用して画像の特定の領域を「拡大」することを提案し、その提案を実行してユーザーの質問に答える方法を示します。

Python

from google import genai
from google.genai import types

client = genai.Client()

MODEL_ID = "gemini-robotics-er-1.5-preview"

# Load your image and set up your prompt
  with open('path/to/image-of-object.jpg', 'rb') as f:
      image_bytes = f.read()
prompt = """
          What is the air quality reading? Using the code execution feature,
          zoom in on the image to take a closer look.
        """

response = client.models.generate_content(
    model=MODEL_ID,
    contents=[
        img,
        prompt
    ],
    config = types.GenerateContentConfig(
        temperature=0.5,
        tools=[types.Tool(code_execution=types.ToolCodeExecution)]
    )
)

for part in response.candidates[0].content.parts:
    if part.text is not None:
        print(part.text)
    if part.executable_code is not None:
        print(part.executable_code.code)
    if part.code_execution_result is not None:
        print(part.code_execution_result.output)

このタスクに対するモデルのレスポンスの例を次に示します。出力には、画面を読みやすくするために画像を拡大するコードを生成するモデルが表示されます。また、トリミングの調整に関する思考プロセスも示します。完全なサンプル出力については、ロボティクス クックブックをご覧ください。

# Detect relevant objects and output in json format
# [{"box_2d": [379, 407, 481, 553], "label": "display"}]
from PIL import Image

# Open the image
img = Image.open("input_file_0.jpeg")

# Define the coordinates for cropping (normalized to 0-1000)
# Based on visual inspection, the display is roughly centered around [430, 430] to [500, 500] in a 1000x1000 scale.
# Let's try to zoom in on the display area.
# Bounding box for display: [ymin, xmin, ymax, xmax] in pixels.
# From visual inspection of the original image (size 90489 bytes, resolution
unknown but let's assume a standard aspect ratio and roughly 1000x1000 for
relative positioning),
# the display is located at approximately y=380-480, x=410-540.
# Let's define a larger area around it for context.
# Let's say we want to crop from y=350 to y=550 and x=350 to x=650.

...

thought
The crop was too tight and only captured part of the display. Let's adjust the bounding box.
The previous crop was `img.crop((400, 350, 600, 500))`. This means xmin=400, ymin=350, xmax=600, ymax=500.
The display is centered around x=480, y=430.
The previous crop captured the left side of the display.
Let's expand the x range to the right and y range to cover the whole circle.
New bounding box estimate: ymin=370, xmin=400, ymax=500, xmax=600.
Let's try again with a wider crop.
# Detect relevant objects and output in json format
# [{"box_2d": [379, 407, 481, 553], "label": "display"}]
from PIL import Image

# Open the image
img = Image.open("input_file_0.jpeg")

# Define the coordinates for cropping (normalized to 0-1000)
…

The reading of 14 falls into the "Moderate" category.
The prompt asks for the "air quality reading", which can be interpreted as
either the numerical value or the categorical description. Given the numerical
value is explicitly displayed, it's the primary reading.

Let's provide the numerical value as the reading.
The reading is 014.
Based on the display on the air purifier, the air quality reading is **014**.

ベスト プラクティス

ロボット アプリケーションのパフォーマンスと精度を最適化するには、Gemini モデルを効果的に操作する方法を理解することが重要です。このセクションでは、最も信頼性の高い結果を得るためのプロンプトの作成、視覚データの処理、タスクの構造化に関するベスト プラクティスと主要な戦略について説明します。

  1. 明確でわかりやすい言葉を使いましょう。

    • 自然言語を活用する: Gemini モデルは、自然な会話言語を理解するように設計されています。意味的に明確で、人が自然に指示を出す方法を反映した形でプロンプトを構成します。

    • 日常的な用語を使用する: 専門用語や特殊な専門用語ではなく、日常的な一般的な言葉を選びます。特定の用語に対してモデルが期待どおりに反応しない場合は、より一般的な同義語で言い換えてみてください。

  2. 視覚的な入力を最適化します。

    • ズームインして詳細を確認する: 広角で撮影された小さなオブジェクトや判別しにくいオブジェクトを扱う場合は、境界ボックス関数を使用して対象のオブジェクトを分離します。その後、画像をこの選択範囲に切り抜き、新しいフォーカスされた画像をモデルに送信して、より詳細な分析を行うことができます。

    • 照明と色を試す: モデルの認識は、照明条件が厳しい場合や色のコントラストが低い場合に影響を受ける可能性があります。

  3. 複雑な問題を小さなステップに分解します。各ステップを個別に処理することで、モデルをより正確で成功につながる結果に導くことができます。

  4. コンセンサスを通じて精度を向上させます。高い精度が求められるタスクでは、同じプロンプトを使用してモデルに複数回クエリを実行できます。返された結果を平均することで、多くの場合、より正確で信頼性の高い「コンセンサス」に到達できます。

制限事項

Gemini Robotics-ER 1.5 を使用して開発する場合は、次の制限事項を考慮してください。

  • プレビュー ステータス: 現在、このモデルはプレビュー版です。API と機能は変更される可能性があり、徹底的なテストを行わないと、本番環境で重要なアプリケーションには適していない可能性があります。
  • レイテンシ: 複雑なクエリ、高解像度の入力、広範な thinking_budget は、処理時間の増加につながる可能性があります。
  • ハルシネーション: すべての大規模言語モデルと同様に、Gemini Robotics-ER 1.5 は、特に曖昧なプロンプトや分布外の入力に対して、誤った情報を提供したり、「ハルシネーション」を起こしたりすることがあります。
  • プロンプトの品質への依存: モデルの出力の品質は、入力プロンプトの明瞭さと具体性に大きく依存します。曖昧なプロンプトや構造化されていないプロンプトは、最適でない結果につながる可能性があります。
  • 計算コスト: モデルを実行すると、特に動画入力や高い thinking_budget を使用すると、コンピューティング リソースが消費され、コストが発生します。詳細については、Thinking ページをご覧ください。
  • 入力タイプ: 各モードの制限事項について詳しくは、以下のトピックをご覧ください。

プライバシーに関するお知らせ

お客様は、このドキュメントで言及されているモデル(「ロボティクス モデル」)が、お客様の指示に従ってハードウェアを操作し、移動するために動画データと音声データを活用することを認めます。そのため、ロボティクス モデルを操作して、音声、画像、肖像データなどの個人を特定できる人物のデータ(「個人データ」)をロボティクス モデルで収集することがあります。ロボティクス モデルを個人データを収集する方法で運用する場合、https://ai.google.dev/gemini-api/terms にある Gemini API 追加利用規約(以下「本規約」)に記載されているとおり、個人データが Google に提供され、Google によって使用される可能性があることを十分に通知し、同意を得るまで、ロボティクス モデルの周囲に個人を特定できる人物が立ち入ったり、ロボティクス モデルとやり取りしたりすることを許可しないことに同意するものとします。これには、「Google によるデータの使用方法」というセクションに記載されている内容も含まれます。お客様は、かかる通知が本規約に定める個人データの収集と使用を許可することを保証し、顔のぼかしなどの技術を使用したり、特定可能な人物が含まれない地域でロボット モデルを運用したりするなど、商業的に合理的な努力を払い、個人データの収集と配布を可能な限り最小限に抑えます。

料金

料金と利用可能なリージョンの詳細については、料金ページをご覧ください。

次のステップ