জেমিনি মডেলগুলো একেবারে গোড়া থেকেই মাল্টিমোডাল হিসেবে তৈরি করা হয়েছে, যা বিশেষায়িত এমএল মডেলকে প্রশিক্ষণ না দিয়েই ইমেজ ক্যাপশনিং, ক্লাসিফিকেশন এবং ভিজ্যুয়াল কোয়েশ্চেন অ্যানসারিং-এর মতো বিস্তৃত পরিসরের ইমেজ প্রসেসিং ও কম্পিউটার ভিশন টাস্ক সম্পাদনের সুযোগ করে দেয়।
তাদের সাধারণ মাল্টিমোডাল সক্ষমতার পাশাপাশি, জেমিনি মডেলগুলো অতিরিক্ত প্রশিক্ষণের মাধ্যমে অবজেক্ট ডিটেকশন এবং সেগমেন্টেশনের মতো নির্দিষ্ট ব্যবহারের ক্ষেত্রে উন্নততর নির্ভুলতা প্রদান করে।
মিথুন রাশিতে ছবি পাঠানো হচ্ছে
আপনি বিভিন্ন পদ্ধতি ব্যবহার করে জেমিনিতে ইনপুট হিসেবে ছবি সরবরাহ করতে পারেন:
- URL ব্যবহার করে ছবি পাঠানো : সর্বজনীনভাবে প্রবেশযোগ্য ছবির জন্য আদর্শ।
- ইনলাইন ইমেজ ডেটা প্রদান : বেস৬৪-এনকোডেড ইমেজ ডেটার জন্য।
- ফাইল এপিআই ব্যবহার করে ছবি আপলোড করা : বড় আকারের ফাইলের জন্য অথবা একাধিক অনুরোধে ছবি পুনরায় ব্যবহার করার জন্য এটি সুপারিশ করা হয়।
URL ব্যবহার করে ছবি পাঠানো
আপনি ফাইলস এপিআই (Files API) ব্যবহার করে একটি ছবি আপলোড করতে পারেন এবং অনুরোধে তা পাস করতে পারেন:
পাইথন
from google import genai
client = genai.Client()
uploaded_file = client.files.upload(file="path/to/organ.jpg")
interaction = client.interactions.create(
model="gemini-3.7-flash",
input=[
{"type": "text", "text": "Caption this image."},
{
"type": "image",
"uri": uploaded_file.uri,
"mime_type": uploaded_file.mime_type
}
]
)
print(interaction.output_text)
জাভাস্ক্রিপ্ট
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const uploadedFile = await client.files.upload({
file: "path/to/organ.jpg",
config: { mimeType: "image/jpeg" }
});
const interaction = await client.interactions.create({
model: "gemini-3.7-flash",
input: [
{type: "text", text: "Caption this image."},
{
type: "image",
uri: uploadedFile.uri,
mime_type: uploadedFile.mimeType
}
]
});
console.log(interaction.output_text);
বিশ্রাম
# First upload the file using the Files API, then use the URI:
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "gemini-3.7-flash",
"input": [
{"type": "text", "text": "Caption this image."},
{
"type": "image",
"uri": "YOUR_FILE_URI",
"mime_type": "image/jpeg"
}
]
}'
ইনলাইন ইমেজ ডেটা পাস করা
আপনি ছবির ডেটা বেস৬৪-এনকোডেড স্ট্রিং হিসেবে প্রদান করতে পারেন:
পাইথন
import base64
from google import genai
with open('path/to/small-sample.jpg', 'rb') as f:
image_bytes = f.read()
client = genai.Client()
interaction = client.interactions.create(
model="gemini-3.7-flash",
input=[
{"type": "text", "text": "Caption this image."},
{
"type": "image",
"data": base64.b64encode(image_bytes).decode('utf-8'),
"mime_type": "image/jpeg"
}
]
)
print(interaction.output_text)
জাভাস্ক্রিপ্ট
import { GoogleGenAI } from "@google/genai";
import * as fs from "node:fs";
const client = new GoogleGenAI({});
const base64ImageFile = fs.readFileSync("path/to/small-sample.jpg", {
encoding: "base64",
});
const interaction = await client.interactions.create({
model: "gemini-3.7-flash",
input: [
{type: "text", text: "Caption this image."},
{
type: "image",
data: base64ImageFile,
mime_type: "image/jpeg"
}
]
});
console.log(interaction.output_text);
বিশ্রাম
IMG_PATH="/path/to/your/image1.jpg"
if [[ "$(base64 --version 2>&1)" = *"FreeBSD"* ]]; then
B64FLAGS="--input"
else
B64FLAGS="-w0"
fi
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "gemini-3.7-flash",
"input": [
{"type": "text", "text": "Caption this image."},
{
"type": "image",
"data": "'"$(base64 $B64FLAGS $IMG_PATH)"'",
"mime_type": "image/jpeg"
}
]
}'
ফাইল এপিআই ব্যবহার করে ছবি আপলোড করা
বড় ফাইলের জন্য অথবা একই ইমেজ ফাইল বারবার ব্যবহার করার জন্য ফাইলস এপিআই (Files API) ব্যবহার করুন। ফাইলস এপিআই গাইডটি দেখুন।
পাইথন
from google import genai
client = genai.Client()
my_file = client.files.upload(file="path/to/sample.jpg")
interaction = client.interactions.create(
model="gemini-3.7-flash",
input=[
{"type": "text", "text": "Caption this image."},
{
"type": "image",
"uri": my_file.uri,
"mime_type": my_file.mime_type
}
]
)
print(interaction.output_text)
জাভাস্ক্রিপ্ট
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const myfile = await client.files.upload({
file: "path/to/sample.jpg",
config: { mimeType: "image/jpeg" },
});
const interaction = await client.interactions.create({
model: "gemini-3.7-flash",
input: [
{type: "text", text: "Caption this image."},
{
type: "image",
uri: myfile.uri,
mime_type: myfile.mimeType
}
]
});
console.log(interaction.output_text);
বিশ্রাম
# First upload the file (see Files API guide for details)
# Then use the file URI in the request:
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "gemini-3.7-flash",
"input": [
{"type": "text", "text": "Caption this image."},
{
"type": "image",
"uri": "YOUR_FILE_URI",
"mime_type": "image/jpeg"
}
]
}'
একাধিক ছবি দিয়ে প্রম্পট করা
input অ্যারেতে একাধিক ইমেজ অবজেক্ট অন্তর্ভুক্ত করার মাধ্যমে আপনি একটিমাত্র প্রম্পটে একাধিক ছবি প্রদান করতে পারেন:
পাইথন
from google import genai
client = genai.Client()
interaction = client.interactions.create(
model="gemini-3.7-flash",
input=[
{"type": "text", "text": "What is different between these two images?"},
{
"type": "image",
"uri": "https://example.com/image1.jpg",
"mime_type": "image/jpeg"
},
{
"type": "image",
"uri": "https://example.com/image2.jpg",
"mime_type": "image/jpeg"
}
]
)
print(interaction.output_text)
জাভাস্ক্রিপ্ট
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
model: "gemini-3.7-flash",
input: [
{type: "text", text: "What is different between these two images?"},
{
type: "image",
uri: "https://example.com/image1.jpg",
mime_type: "image/jpeg"
},
{
type: "image",
uri: "https://example.com/image2.jpg",
mime_type: "image/jpeg"
}
]
});
console.log(interaction.output_text);
বিশ্রাম
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "gemini-3.7-flash",
"input": [
{"type": "text", "text": "What is different between these two images?"},
{
"type": "image",
"uri": "https://example.com/image1.jpg",
"mime_type": "image/jpeg"
},
{
"type": "image",
"uri": "https://example.com/image2.jpg",
"mime_type": "image/jpeg"
}
]
}'
বস্তু সনাক্তকরণ
একটি ছবিতে বস্তু শনাক্ত করতে এবং সেগুলোর বাউন্ডিং বক্সের স্থানাঙ্ক পেতে মডেলগুলোকে প্রশিক্ষণ দেওয়া হয়। ছবির আকারের সাপেক্ষে, এই স্থানাঙ্কগুলো [0, 1000] পরিসরে পরিবর্তিত হয়। আপনার মূল ছবির আকারের উপর ভিত্তি করে এই স্থানাঙ্কগুলোকে ডিস্কেল করতে হবে।
পাইথন
from google import genai
from pydantic import BaseModel, Field
from typing import List
import json
client = genai.Client()
prompt = "Detect the all of the prominent items in the image. The box_2d should be [ymin, xmin, ymax, xmax] normalized to 0-1000."
class BoundingBox(BaseModel):
box_2d: List[int] = Field(description="The 2D bounding box of the item as [ymin, xmin, ymax, xmax] normalized to 0-1000.")
mask: List[List[int]] = Field(description="The segmentation mask of the item as a polygon of [x,y] coordinates, normalized to 0-1000.")
label: str = Field(description="A descriptive label for the item.")
class BoundingBoxes(BaseModel):
boxes: List[BoundingBox]
interaction = client.interactions.create(
model="gemini-3.7-flash",
input=[
{"type": "text", "text": prompt},
{
"type": "image",
"uri": "https://example.com/image.png",
"mime_type": "image/png"
}
],
response_format={
"type": "text",
"mime_type": "application/json",
"schema": BoundingBoxes.model_json_schema()
}
)
bounding_boxes = BoundingBoxes.model_validate_json(interaction.output_text)
print(bounding_boxes)
জাভাস্ক্রিপ্ট
import { GoogleGenAI } from "@google/genai";
import * as z from "zod";
const client = new GoogleGenAI({});
const prompt = "Detect the all of the prominent items in the image. The box_2d should be [ymin, xmin, ymax, xmax] normalized to 0-1000.";
const boundingBoxesSchema = z.object({
boxes: z.array(z.object({
box_2d: z.array(z.number()),
mask: z.array(z.array(z.number())),
label: z.string()
}))
});
const interaction = await client.interactions.create({
model: "gemini-3.7-flash",
input: [
{ type: "text",