Gemini Robotics-ER 1.5 เป็นโมเดลวิสัยทัศน์ภาษา (VLM) ที่นำความสามารถของเอเจนต์ของ Gemini มาใช้กับหุ่นยนต์ ซึ่งออกแบบมาเพื่อการให้เหตุผลขั้นสูงในโลกกายภาพ ทำให้หุ่นยนต์ตีความข้อมูลภาพที่ซับซ้อน ทำการให้เหตุผลเชิงพื้นที่ และวางแผนการดำเนินการจากคำสั่งภาษาธรรมชาติได้
ฟีเจอร์และประโยชน์หลัก
- อิสระที่เพิ่มขึ้น: หุ่นยนต์สามารถให้เหตุผล ปรับตัว และตอบสนองต่อการเปลี่ยนแปลงในสภาพแวดล้อมแบบเปิด
- การโต้ตอบด้วยภาษาธรรมชาติ: ช่วยให้ใช้หุ่นยนต์ได้ง่ายขึ้นด้วยการเปิดใช้ การมอบหมายงานที่ซับซ้อนโดยใช้ภาษาธรรมชาติ
- การจัดระเบียบงาน: แยกคำสั่งภาษาธรรมชาติออกเป็นงานย่อย และผสานรวมกับตัวควบคุมและลักษณะการทำงานของหุ่นยนต์ที่มีอยู่เพื่อทำงาน ระยะยาวให้เสร็จสมบูรณ์
- ความสามารถที่หลากหลาย: ค้นหาและระบุออบเจ็กต์ ทำความเข้าใจ ความสัมพันธ์ของออบเจ็กต์ วางแผนการจับและวิถีการเคลื่อนที่ รวมถึงตีความฉาก แบบไดนามิก
เอกสารนี้อธิบายสิ่งที่โมเดลทำและพาคุณไปดูตัวอย่างหลายๆ ตัวอย่างที่เน้นความสามารถในการดำเนินการของโมเดล
หากต้องการเริ่มใช้งานเลย คุณสามารถลองใช้โมเดลใน Google AI Studio ได้
ความปลอดภัย
แม้ว่า Gemini Robotics-ER 1.5 จะสร้างขึ้นโดยคำนึงถึงความปลอดภัยเป็นหลัก แต่คุณก็มี หน้าที่รับผิดชอบในการรักษาสภาพแวดล้อมที่ปลอดภัยรอบหุ่นยนต์ โมเดล Generative AI อาจทำงานผิดพลาดได้ และหุ่นยนต์ที่จับต้องได้อาจทำให้เกิดความเสียหาย ความปลอดภัยเป็น สิ่งสำคัญ และการทำให้โมเดล Generative AI ปลอดภัยเมื่อใช้กับหุ่นยนต์ในโลกแห่งความจริง เป็นขอบเขตการวิจัยที่สำคัญและมีการดำเนินการอย่างต่อเนื่อง ดูข้อมูลเพิ่มเติมได้ที่หน้าความปลอดภัยด้านหุ่นยนต์ของ Google DeepMind
เริ่มต้นใช้งาน: การค้นหาออบเจ็กต์ในฉาก
ตัวอย่างต่อไปนี้แสดงกรณีการใช้งานหุ่นยนต์ทั่วไป โดยจะแสดงวิธีส่งรูปภาพและพรอมต์ข้อความไปยังโมเดลโดยใช้เมธอด generateContent
เพื่อรับรายการออบเจ็กต์ที่ระบุพร้อมกับจุด 2 มิติที่เกี่ยวข้อง
โมเดลจะแสดงผลจุดสำหรับรายการที่ระบุในรูปภาพ โดยแสดงผลพิกัด 2 มิติที่ได้รับการทำให้เป็นมาตรฐานและป้ายกำกับของรายการเหล่านั้น
คุณสามารถใช้เอาต์พุตนี้กับ Robotics API หรือเรียกใช้โมเดล Vision-Language-Action (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 มีงบประมาณการคิดที่ยืดหยุ่นซึ่งช่วยให้คุณควบคุม การแลกเปลี่ยนระหว่างเวลาในการตอบสนองกับความแม่นยำได้ สำหรับงานที่ต้องทำความเข้าใจเชิงพื้นที่ เช่น การตรวจหาออบเจ็กต์ โมเดลจะทำงานได้อย่างมีประสิทธิภาพสูงโดยใช้งบประมาณในการคิดเพียงเล็กน้อย งานการให้เหตุผลที่ซับซ้อนมากขึ้น เช่น การนับและการประมาณน้ำหนัก จะได้รับประโยชน์จากงบประมาณการคิดที่มากขึ้น ซึ่งช่วยให้คุณปรับสมดุลความต้องการการตอบสนองที่มีเวลาในการตอบสนองต่ำกับผลลัพธ์ที่มีความแม่นยำสูงสำหรับงานที่ท้าทายมากขึ้น
ดูข้อมูลเพิ่มเติมเกี่ยวกับงบประมาณการคิดได้ที่หน้าความสามารถหลักของการคิด
ความสามารถของ AI ในการดำเนินการได้เองสำหรับหุ่นยนต์
ส่วนนี้จะอธิบายความสามารถต่างๆ ของ Gemini Robotics-ER 1.5 โดยแสดงวิธีใช้โมเดลสำหรับการรับรู้ การให้เหตุผล และการวางแผนของหุ่นยนต์
ตัวอย่างในส่วนนี้แสดงความสามารถตั้งแต่การชี้และค้นหาออบเจ็กต์ในรูปภาพไปจนถึงการวางแผนวิถีและจัดการงานระยะยาว เพื่อความสะดวก เราได้ลดข้อมูลโค้ดเพื่อแสดงพรอมต์
และการเรียกใช้ generate_content
API คุณดูโค้ดที่เรียกใช้ได้ทั้งหมดและ
ตัวอย่างเพิ่มเติมได้ใน
Robotics cookbook
การชี้ไปยังวัตถุ
การชี้และค้นหาออบเจ็กต์ในรูปภาพหรือเฟรมวิดีโอเป็นกรณีการใช้งานทั่วไปสำหรับโมเดลวิชันและภาษา (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 [].
"""
เอาต์พุตแสดงให้เห็นว่าระบบติดตามปากกาและแล็ปท็อปในเฟรมวิดีโอ
ดูโค้ดที่เรียกใช้ได้ทั้งหมดได้ที่ สูตรอาหารสำหรับหุ่นยนต์
การตรวจหาวัตถุและกรอบล้อมรอบ
นอกจากจุดเดียวแล้ว โมเดลยังสามารถแสดงกรอบล้อมรอบ 2 มิติ ซึ่งให้ ภูมิภาคสี่เหลี่ยมผืนผ้าที่ล้อมรอบวัตถุ
ตัวอย่างนี้ขอขอบเขต 2 มิติสำหรับวัตถุที่ระบุได้บนโต๊ะ โมเดลได้รับคำสั่งให้จำกัดเอาต์พุตไว้ที่ 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)
การตอบกลับจะมีพิกัด 2 มิติของออบเจ็กต์ที่ตอบคำถามของผู้ใช้ ในกรณีนี้คือออบเจ็กต์ที่ควรย้ายออกเพื่อให้มีที่วางแล็ปท็อป
[
{"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 จำลองที่ออกแบบมาสำหรับการดำเนินการหยิบและวาง งานคือ หยิบบล็อกสีน้ำเงินแล้ววางลงในชามสีส้ม
โค้ดที่เรียกใช้ได้ทั้งหมดจะอยู่ในตำราการทำอาหารสำหรับหุ่นยนต์ เช่นเดียวกับตัวอย่างอื่นๆ ในหน้านี้
ขั้นตอนแรกคือการค้นหารายการทั้ง 2 รายการด้วยพรอมต์ต่อไปนี้
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)
ต่อไปนี้คือคำตอบที่เป็นไปได้ของโมเดลสำหรับงานนี้ เอาต์พุตแสดง โมเดลที่สร้างโค้ดสำหรับการซูมเข้าในรูปภาพเพื่อให้อ่านหน้าจอได้ดีขึ้น นอกจากนี้ ยังแสดงกระบวนการคิดเกี่ยวกับการปรับค่าใช้จ่ายที่ใช้ในการ ครอบตัดด้วย ดูเอาต์พุตตัวอย่างทั้งหมดได้ที่Robotics cookbook
# 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 อย่างมีประสิทธิภาพเป็นสิ่งสำคัญอย่างยิ่งต่อการเพิ่มประสิทธิภาพและความแม่นยำของแอปพลิเคชันหุ่นยนต์ ส่วนนี้จะอธิบายแนวทางปฏิบัติแนะนำและกลยุทธ์สำคัญสำหรับการสร้างพรอมต์ การจัดการข้อมูลภาพ และการจัดโครงสร้างงานเพื่อให้ได้ผลลัพธ์ที่เชื่อถือได้มากที่สุด
ใช้ภาษาที่ชัดเจนและเข้าใจง่าย
ใช้ภาษาที่เป็นธรรมชาติ: โมเดล Gemini ออกแบบมาเพื่อทำความเข้าใจ ภาษาที่เป็นธรรมชาติและภาษาที่ใช้ในการสนทนา สร้างโครงสร้างพรอมต์ในลักษณะที่ชัดเจนในเชิงความหมายและสะท้อนวิธีที่บุคคลจะให้คำสั่งตามธรรมชาติ
ใช้คำศัพท์ที่ใช้กันทั่วไป: เลือกใช้ภาษาที่ใช้กันทั่วไปในชีวิตประจำวันแทน คำศัพท์เฉพาะทางหรือคำศัพท์เฉพาะ หากโมเดลไม่ตอบสนองตามที่คาดไว้ต่อคำหนึ่งๆ ให้ลองเปลี่ยนคำนั้นเป็นคำพ้องความหมายที่ใช้กันทั่วไป
เพิ่มประสิทธิภาพอินพุตภาพ
ซูมเข้าเพื่อดูรายละเอียด: เมื่อต้องจัดการกับวัตถุที่มีขนาดเล็กหรือ แยกแยะได้ยากในภาพมุมกว้าง ให้ใช้ฟังก์ชันกรอบล้อมรอบเพื่อ แยกวัตถุที่สนใจ จากนั้นคุณสามารถครอบตัดรูปภาพให้เหลือเฉพาะส่วนที่เลือกนี้ แล้วส่งรูปภาพใหม่ที่โฟกัสไปยังโมเดลเพื่อรับการวิเคราะห์ที่ละเอียดยิ่งขึ้น
ทดลองใช้แสงและสี: การรับรู้ของโมเดลอาจได้รับผลกระทบจากสภาพแสงที่ท้าทายและคอนทราสต์ของสีที่ไม่ดี
แบ่งปัญหาที่ซับซ้อนออกเป็นขั้นตอนย่อยๆ การจัดการแต่ละขั้นตอนย่อยๆ ทีละขั้นตอนจะช่วยให้คุณแนะนำโมเดลให้ได้ผลลัพธ์ที่แม่นยำและประสบความสำเร็จมากขึ้น
ปรับปรุงความแม่นยำผ่านฉันทามติ สำหรับงานที่ต้องการความแม่นยำสูง คุณสามารถค้นหาโมเดลหลายครั้งด้วยพรอมต์เดียวกัน การหาค่าเฉลี่ยของผลลัพธ์ที่ได้จะช่วยให้คุณได้ "ฉันทามติ" ซึ่งมักจะแม่นยำและเชื่อถือได้มากกว่า
ข้อจำกัด
โปรดคำนึงถึงข้อจำกัดต่อไปนี้เมื่อพัฒนาด้วย Gemini Robotics-ER 1.5
- สถานะเวอร์ชันตัวอย่าง: ปัจจุบันโมเดลอยู่ในเวอร์ชันตัวอย่าง API และ ความสามารถอาจมีการเปลี่ยนแปลง และอาจไม่เหมาะสําหรับแอปพลิเคชันที่สําคัญต่อการผลิต หากไม่มีการทดสอบอย่างละเอียด
- เวลาในการตอบสนอง: คำค้นหาที่ซับซ้อน อินพุตความละเอียดสูง หรือ
thinking_budget
อาจทำให้เวลาในการประมวลผลเพิ่มขึ้น - คำตอบที่ไม่สมเหตุสมผล: เช่นเดียวกับโมเดลภาษาขนาดใหญ่ทั้งหมด Gemini Robotics-ER 1.5 อาจ "ตอบคำถามที่ไม่สมเหตุสมผล" หรือให้ข้อมูลที่ไม่ถูกต้องในบางครั้ง โดยเฉพาะ สำหรับพรอมต์ที่ไม่ชัดเจนหรืออินพุตที่อยู่นอกเหนือการกระจาย
- ขึ้นอยู่กับคุณภาพของพรอมต์: คุณภาพของเอาต์พุตของโมเดลขึ้นอยู่กับความชัดเจนและความเฉพาะเจาะจงของพรอมต์อินพุตเป็นอย่างมาก พรอมต์ที่คลุมเครือ หรือมีโครงสร้างไม่ดีอาจทำให้ได้ผลลัพธ์ที่ไม่ดี
- ค่าใช้จ่ายในการคำนวณ: การเรียกใช้โมเดล โดยเฉพาะอย่างยิ่งเมื่อมีอินพุตวิดีโอหรือ
thinking_budget
สูง จะใช้ทรัพยากรการคำนวณและทำให้เกิดค่าใช้จ่าย ดูรายละเอียดเพิ่มเติมได้ที่หน้าการคิด - ประเภทอินพุต: ดูรายละเอียดเกี่ยวกับข้อจำกัดของแต่ละโหมดได้ในหัวข้อต่อไปนี้
ประกาศเกี่ยวกับนโยบายความเป็นส่วนตัว
คุณรับทราบว่าโมเดลที่อ้างอิงในเอกสารนี้ ("โมเดลหุ่นยนต์") ใช้ประโยชน์จากข้อมูลวิดีโอและเสียงเพื่อใช้งานและเคลื่อนที่ฮาร์ดแวร์ตามคำสั่งของคุณ ดังนั้น คุณอาจใช้งานโมเดลหุ่นยนต์ในลักษณะที่โมเดลหุ่นยนต์จะเก็บรวบรวมข้อมูลจากบุคคลที่ระบุตัวตนได้ เช่น ข้อมูลเสียง รูปภาพ และข้อมูลความเหมือน ("ข้อมูลส่วนตัว") หากเลือกที่จะใช้งานโมเดลหุ่นยนต์ในลักษณะที่เก็บรวบรวม ข้อมูลส่วนบุคคล คุณยอมรับว่าจะไม่อนุญาตให้บุคคลที่ระบุตัวตนได้ โต้ตอบหรืออยู่ในพื้นที่รอบๆ โมเดลหุ่นยนต์ จนกว่าบุคคลที่ระบุตัวตนได้ดังกล่าวจะได้รับการแจ้งเตือนอย่างเพียงพอ และยินยอมให้ Google อาจให้และใช้ข้อมูลส่วนบุคคลของบุคคลดังกล่าว ตามที่ระบุไว้ในข้อกำหนดในการให้บริการเพิ่มเติมของ Gemini API ที่https://ai.google.dev/gemini-api/terms ("ข้อกำหนด") รวมถึงตามส่วนที่ชื่อว่า "วิธีที่ Google ใช้ข้อมูลของคุณ" คุณจะตรวจสอบว่าประกาศดังกล่าวอนุญาตให้เก็บรวบรวมและใช้ข้อมูลส่วนบุคคลตามที่ระบุไว้ในข้อกำหนด และคุณจะพยายามอย่างเต็มที่ในเชิงพาณิชย์เพื่อลดการเก็บรวบรวมและการ เผยแพร่ข้อมูลส่วนบุคคลโดยใช้เทคนิคต่างๆ เช่น การเบลอใบหน้าและการ ใช้งานโมเดลหุ่นยนต์ในพื้นที่ที่ไม่มีบุคคลที่ระบุตัวตนได้ ตามขอบเขตที่สามารถทำได้
ราคา
ดูข้อมูลโดยละเอียดเกี่ยวกับการกำหนดราคาและภูมิภาคที่พร้อมให้บริการได้ที่หน้าการกำหนดราคา
ขั้นตอนถัดไป
- สำรวจความสามารถอื่นๆ และทดลองใช้พรอมต์และอินพุตต่างๆ ต่อไป เพื่อค้นพบการใช้งานเพิ่มเติมสำหรับ Gemini Robotics-ER 1.5 ดูตัวอย่างเพิ่มเติมได้ที่ตำราการทำอาหารสำหรับหุ่นยนต์
- ดูข้อมูลเกี่ยวกับวิธีสร้างโมเดลหุ่นยนต์ Gemini โดยคำนึงถึงความปลอดภัยได้ที่หน้าความปลอดภัยด้านหุ่นยนต์ของ Google DeepMind
- อ่านข้อมูลอัปเดตล่าสุดเกี่ยวกับโมเดล Gemini Robotics ได้ที่หน้า Landing Page ของ Gemini Robotics