视频理解

Gemini Robotics ER 2 可以通过以下两种功能跟踪持续视频信息流中的任务进度:

  • 精彩瞬间查找:确定关键事件发生的精确时间戳。
  • 进度分类:将每个视频分配到五个完成度区间之一(0-20%、20-40%、40-60%、60-80%、80-100%)。

查找精彩瞬间

精彩瞬间查找功能可识别发生关键事件的确切视频帧,例如,杯子装满水或结打好时。机器人使用此信息来验证成功情况、确定步骤顺序和触发修正。

以下示例提示要求模型识别视频中给定任务的完成时刻:

from google import genai

client = genai.Client()

uploaded_file = client.files.upload(file="task_video.mp4")

prompt = """
At what timestamp (in seconds) does the task reach successful completion?
Return a JSON object: {"completion_time_seconds": <float>}.
If the task is not completed, return {"completion_time_seconds": null}.
"""

interaction = client.interactions.create(
    model="gemini-robotics-er-2-preview",
    input=[
        {
            "type": "video",
            "uri": uploaded_file.uri,
            "mime_type": uploaded_file.mime_type
        },
        {"type": "text", "text": prompt}
    ],
)

print(interaction.output_text)

以下示例展示了精彩瞬间查找视频中的帧,其中模型识别了任务完成时间戳:

示例视频帧,显示了带有时间戳叠加层的精彩瞬间查找输出

进度分类

进度分类会将视频分配到五个完成度区间之一:0-20%、20-40%、40-60%、60-80% 或 80-100%。这使机器人能够实时感知情况,从而调整操作或重试失败的步骤,而无需重新启动整个工作流程。

以下示例提示要求模型对视频的当前进度级别进行分类:

from google import genai

client = genai.Client()

uploaded_file = client.files.upload(file="task_video.mp4")

prompt = """
Watch this video and classify the task progress level at the final frame.
Return a JSON object with the progress bracket:
{"progress_level": "0-20" | "20-40" | "40-60" | "60-80" | "80-100"}.
"""

interaction = client.interactions.create(
    model="gemini-robotics-er-2-preview",
    input=[
        {
            "type": "video",
            "uri": uploaded_file.uri,
            "mime_type": uploaded_file.mime_type
        },
        {"type": "text", "text": prompt}
    ],
)

print(interaction.output_text)

以下示例展示了进度分类视频中的帧,其中模型分配了进度区间:

示例视频帧,显示了带有进度括号标签的进度分类输出

示例

如需查看包含多步任务跟踪的完整可运行示例,请参阅机器人技术食谱

后续步骤