视频理解

Gemini Robotics ER 2 可以使用以下两种功能跟踪连续视频馈送中的任务进度:

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

时刻查找

时刻查找功能可以识别关键事件发生的精确视频帧,例如杯子装满或结被系好时。机器人使用此功能来验证成功、按顺序执行步骤和触发更正。

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

from google import genai
from google.genai import types

client = genai.Client()

with open("task_video.mp4", "rb") as f:
    video_bytes = f.read()

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}.
"""

response = client.models.generate_content(
    model="gemini-robotics-er-2-preview",
    contents=[
        types.Part.from_bytes(data=video_bytes, mime_type="video/mp4"),
        prompt,
    ],
)

print(response.text)

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

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

进度分类

进度分类功能会将视频分配到五个完成度范围之一:0-20%、20-40%、40-60%、60-80% 或 80-100%。这使机器人能够实时了解情况,以便调整操作或重试失败的步骤,而无需重启整个工作流。

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

from google import genai
from google.genai import types

client = genai.Client()

with open("task_video.mp4", "rb") as f:
    video_bytes = f.read()

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"}.
"""

response = client.models.generate_content(
    model="gemini-robotics-er-2-preview",
    contents=[
        types.Part.from_bytes(data=video_bytes, mime_type="video/mp4"),
        prompt,
    ],
)

print(response.text)

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

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

示例

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

后续步骤