সক্রিয় দৃষ্টি

জেমিনি রোবোটিক্স ইআর মডেলগুলো উত্তর দেওয়ার আগে ছবি নিয়ে কাজ করতে এবং লজিক প্রয়োগ করতে পাইথন কোড লিখতে ও চালাতে পারে। এই পৃষ্ঠায় কোড চালানোর কিছু উদাহরণ দেওয়া হয়েছে: জুম ও ক্রপ সহ বস্তু শনাক্তকরণ, যন্ত্রের পাঠ, তরলের পরিমাপ, সার্কিট বোর্ডের পাঠ এবং ছবিতে টীকা সংযোজন।

এই উদাহরণগুলিকে আপনার নিজস্ব ব্যবহারের জন্য উপযোগী করতে, প্রম্পট টেক্সট এবং আপলোড করা ইমেজ ফাইলটি আপনার নিজের ফাইল দিয়ে প্রতিস্থাপন করুন। এছাড়াও, আপনার অ্যাপ্লিকেশনের প্রয়োজনীয় আউটপুট কাঠামোর সাথে মেলানোর জন্য আপনি প্রম্পটে অনুরোধ করা JSON স্কিমাটি পরিবর্তন করতে পারেন, অথবা আউটপুট ফরম্যাট এবং নির্ভুলতা নিশ্চিত করতে একটি system_instruction যোগ করতে পারেন।

সম্পূর্ণভাবে কার্যকর কোডের জন্য রোবোটিক্স কুকবুকটি দেখুন।

চিন্তার স্তর

আপনি ল্যাটেন্সির বিনিময়ে নির্ভুলতা বাড়াতে মডেলের চিন্তার স্তর নিয়ন্ত্রণ করতে পারেন। বস্তু শনাক্তকরণের মতো স্থানিক কাজগুলো কম চিন্তার স্তরে ভালো কাজ করে। গণনা বা ওজন অনুমানের মতো জটিল কাজগুলো উচ্চতর চিন্তার স্তর থেকে উপকৃত হয়।

নিম্নলিখিত উদাহরণটি একটি জটিল গণনার কাজের জন্য চিন্তার স্তরকে high পর্যায়ে নির্ধারণ করে:

পাইথন

from google import genai

client = genai.Client()

uploaded_file = client.files.upload(file="scene.jpeg")

interaction = client.interactions.create(
    model="gemini-robotics-er-2-preview",
    input=[
        {
            "type": "image",
            "uri": uploaded_file.uri,
            "mime_type": uploaded_file.mime_type
        },
        {"type": "text", "text": "Identify and count all objects on the table."}
    ],
    generation_config={
        "thinking_level": "high"  # Use "minimal" or "low" for faster spatial tasks
    }
)

print(interaction.output_text)

বিস্তারিত জানতে ‘চিন্তাভাবনা’ দেখুন।

বস্তু শনাক্তকরণ (জুম এবং ক্রপ)

নিম্নলিখিত উদাহরণটি অবজেক্ট শনাক্ত করার এবং বাউন্ডিং বক্স ফেরত দেওয়ার সময় একটি ছবিকে আরও স্পষ্ট দেখার জন্য কোড এক্সিকিউশন ব্যবহার করে।

পাইথন

from google import genai

client = genai.Client()

uploaded_file = client.files.upload(file="sorting.jpeg")

prompt = """
Return JSON in the format {label: val, y: val, x: val, y2: val, x2: val} for
the compostable objects in this scene. Please Zoom and crop the image for a
clearer view. Return an annotated image of the final result with the bounding
boxes drawn on it to the API caller as a part of your process.
"""

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

print(interaction.output_text)

মডেলের আউটপুটটি নিম্নলিখিত json রেসপন্সের অনুরূপ হবে:

[
  {"label": "compostable", "y": 256, "x": 482, "y2": 295, "x2": 546},
  {"label": "compostable", "y": 317, "x": 478, "y2": 350, "x2": 542},
  {"label": "compostable", "y": 586, "x": 556, "y2": 668, "x2": 595},
  {"label": "compostable", "y": 463, "x": 669, "y2": 511, "x2": 718},
  {"label": "compostable", "y": 178, "x": 565, "y2": 250, "x2": 609}
]

নিচের ছবিতে মডেল থেকে প্রাপ্ত বাক্সগুলো দেখানো হয়েছে।

পাওয়া বস্তুগুলির বাউন্ডিং বক্স দেখানোর একটি উদাহরণ

একটি অ্যানালগ গেজ পড়ুন এবং যুক্তি প্রয়োগ করুন

নিম্নলিখিত উদাহরণটি দেখায় কিভাবে মডেলটি ব্যবহার করে একটি অ্যানালগ গেজ থেকে পাঠ নেওয়া যায় এবং সময়ের গণনা করা যায়। এটি একটি JSON আউটপুট নিশ্চিত করতে একটি সিস্টেম নির্দেশনা ব্যবহার করে।

পাইথন

from google import genai

client = genai.Client()

uploaded_file = client.files.upload(file="gauge.jpeg")

interaction = client.interactions.create(
    model="gemini-robotics-er-2-preview",
    system_instruction="Be precise. When JSON is requested, reply with ONLY that JSON (no preface, no code block).",
    input=[
        {
            "type": "image",
            "uri": uploaded_file.uri,
            "mime_type": uploaded_file.mime_type
        },
        {"type": "text", "text": """Read the current value from this gauge. Then, calculate how long
        it will take at the current rate for the value to reach maximum.
        Reply in JSON: {"current_value": val, "max_value": val,
        "time_to_max_minutes": val}"""}
    ],
    tools=[{"type": "code_execution"}]
)

print(interaction.output_text)

একটি পাত্রে তরল পরিমাপ করুন

নিম্নলিখিত উদাহরণটি দেখায় কিভাবে কোড এক্সিকিউশন ব্যবহার করে একটি পাত্রে তরলের স্তর পরিমাপ করা যায়।

পাইথন

from google import genai

client = genai.Client()

uploaded_file = client.files.upload(file="fluid.jpeg")

interaction = client.interactions.create(
    model="gemini-robotics-er-2-preview",
    system_instruction="Be precise. When JSON is requested, reply with ONLY that JSON (no preface, no code block).",
    input=[
        {
            "type": "image",
            "uri": uploaded_file.uri,
            "mime_type": uploaded_file.mime_type
        },
        {"type": "text", "text": """Measure the amount of fluid in the container. Reply in JSON:
        {"fluid_level_ml": val, "container_capacity_ml": val,
        "percentage_full": val}"""}
    ],
    tools=[{"type": "code_execution"}]
)

print(interaction.output_text)

সার্কিট বোর্ডের চিহ্নগুলো পড়ুন

নিম্নলিখিত উদাহরণটি দেখায় কিভাবে কোড এক্সিকিউশন ব্যবহার করে একটি সার্কিট বোর্ডের চিহ্নগুলি পড়া যায়।

পাইথন

from google import genai

client = genai.Client()

uploaded_file = client.files.upload(file="circuit_board.jpeg")

interaction = client.interactions.create(
    model="gemini-robotics-er-2-preview",
    system_instruction="Be precise. When JSON is requested, reply with ONLY that JSON (no preface, no code block).",
    input=[
        {
            "type": "image",
            "uri": uploaded_file.uri,
            "mime_type": uploaded_file.mime_type
        },
        {"type": "text", "text": """Read all visible component labels and markings on this circuit
        board. Reply in JSON: {"components": [{"label": val,
        "location": [y, x]}]}"""}
    ],
    tools=[{"type": "code_execution"}]
)

print(interaction.output_text)

সার্কিট বোর্ডের উপর চিহ্ন দেখানোর একটি উদাহরণ।

ছবির টীকা

নিম্নলিখিত উদাহরণটি দেখায় কিভাবে কোড এক্সিকিউশন ব্যবহার করে একটি ছবিতে টীকা যোগ করা যায় (যেমন, অপসারণের নির্দেশাবলীর জন্য তীরচিহ্ন আঁকা) এবং পরিবর্তিত ছবিটি ফেরত দেওয়া যায়।

পাইথন

from google import genai

client = genai.Client()

# Load your image
uploaded_file = client.files.upload(file="sorting.jpeg")

prompt = """
Look at this image and return it as an annotated version using arrows of
different colors to represent which items should go in which bins for
disposal. You must return the final image to the API caller.
"""

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

print(interaction.output_text)

নিম্নলিখিতটি একটি উদাহরণ চিত্র ইনপুট।

একটি ঘড়ির পাঠ দেখানোর উদাহরণ

মডেলের আউটপুটটি নিম্নলিখিতের অনুরূপ হবে:

  The annotated image shows the suggested disposal locations for the items on the table:
  - **Green bin (Compost/Organic)**: Green chili, red chili, grapes, and cherries.
  - **Blue bin (Recycling)**: Yellow crushed can and plastic container.
  - **Black bin (Trash)**: Chocolate bar wrapper, Welch's packet, and white tissue.

এরপর কী?

  • টাস্ক অর্কেস্ট্রেশন — কাস্টম রোবট এপিআই ব্যবহার করে দীর্ঘমেয়াদী কাজ সম্পাদন।
  • স্ট্রিমিং সহ রোবোটিক্স — রিয়েল-টাইম দ্বিমুখী স্ট্রিমিং (শুধুমাত্র জেমিনি রোবোটিক্স ইআর ২-এর জন্য)।
  • ভিডিও বোঝা — মুহূর্ত শনাক্তকরণ এবং অগ্রগতি শ্রেণিবিন্যাস (শুধুমাত্র জেমিনি রোবোটিক্স ইআর ২-এর জন্য)।