Comparáid Ilíomhá
Ar an leathanach seo
Anailís a Dhéanamh ar Ilíomhá in Aon Iarratas Amháin
Is é ceann de bhuntáistí móra Grok Vision an cumas líon gan teorainn íomhánna a sheoladh in aon iarratas amháin. Osclaíonn sé seo deiseanna uathúla le haghaidh comparáide, rianaithe sealadaigh, agus tras-anailíse nach féidir le APIanna aon-íomhá a thairiscint.
Struchtúr an Iarratais Ilíomhá
Tá an formáid simplí: cuir oiread oibiachtaí input_image agus is gá leis an eagar input, á n-idirghabháil le téacs chun an anailís a threorú:
response = client.responses.create(
model="grok-4.5",
input=[
{"type": "input_text", "text": "Image A:"},
{"type": "input_image", "image_url": url_image_a},
{"type": "input_text", "text": "Image B:"},
{"type": "input_image", "image_url": url_image_b},
{"type": "input_text", "text": "Compare these two images in detail."}
]
)
Cuidíonn lipéadú gach íomhá le téacs (“Image A”, “Image B”) leis an tsamhail a freagra a struchtúrú agus tagairt shoiléir a dhéanamh do gach íomhá.
Cás Úsáide: Comparáid Roimh/Ina Dhiaidh
Idealach le haghaidh rianú tionscadail, athchóirithe, deartha, nó rialú cáilíochta:
def comparer_avant_apres(url_avant, url_apres):
prompt = """Compare these two images (before and after) and identify:
1. The main changes
2. Elements that have not changed
3. Visible improvements
4. Any potential issues introduced
Present your response as a structured list."""
response = client.responses.create(
model="grok-4.5",
input=[
{"type": "input_text", "text": "BEFORE:"},
{"type": "input_image", "image_url": url_avant, "detail": "high"},
{"type": "input_text", "text": "AFTER:"},
{"type": "input_image", "image_url": url_apres, "detail": "high"},
{"type": "input_text", "text": prompt}
],
store=False
)
return response.output_text
Cás Úsáide: Rianú Sealadach
Rianaigh éabhlóid suímh, táirge, nó próisis le himeacht ama:
def analyser_evolution(images_chronologiques):
"""images_chronologiques: list of {"url": ..., "date": ...}"""
input_data = []
for img in images_chronologiques:
input_data.append({
"type": "input_text",
"text": f"Photo from {img['date']}:"
})
input_data.append({
"type": "input_image",
"image_url": img["url"],
"detail": "auto"
})
input_data.append({
"type": "input_text",
"text": """Analyze the chronological evolution visible in
these images. Identify progressive changes, trends,
and any notable events between the different dates."""
})
response = client.responses.create(
model="grok-4.5",
input=input_data,
store=False
)
return response.output_text
Cás Úsáide: Rialú Cáilíochta
Déan comparáid idir táirge monaraíochta agus a mhúnla tagartha:
def controle_qualite(url_reference, url_produit):
prompt = """Compare the photographed product to the reference model.
Identify:
1. Compliance (what matches the model)
2. Non-compliance (deviations, defects, differences)
3. Severity of each non-compliance (minor, major, critical)
Return a JSON with:
{
"compliant": true/false,
"score": 0-100,
"compliances": [...],
"non_compliances": [
{"description": "...", "severity": "minor|major|critical"}
]
}"""
response = client.responses.create(
model="grok-4.5",
input=[
{"type": "input_text", "text": "REFERENCE (expected model):"},
{"type": "input_image", "image_url": url_reference, "detail": "high"},
{"type": "input_text", "text": "PRODUCT to check:"},
{"type": "input_image", "image_url": url_produit, "detail": "high"},
{"type": "input_text", "text": prompt}
],
store=False
)
return response.output_text
Cás Úsáide: Anailís Iomaíochta
Déan comparáid idir comhéadain, pacáistiú, nó cur i láthair táirgí ó chomórtas:
def analyser_concurrence(images_concurrents):
"""images_concurrents: [{"brand": "...", "url": "..."}]"""
input_data = []
for concurrent in images_concurrents:
input_data.append({
"type": "input_text",
"text": f"{concurrent['brand']}:"
})
input_data.append({
"type": "input_image",
"image_url": concurrent["url"],
"detail": "auto"
})
input_data.append({
"type": "input_text",
"text": """Compare these competitor products/interfaces.
For each, identify visual strengths and weaknesses.
Provide a positioning recommendation."""
})
response = client.responses.create(
model="grok-4.5",
input=input_data,
store=False
)
return response.output_text
Iarratais Ilíomhá a Optamú
Nuair a sheolann tú go leor íomhánna, méadaíonn tomhaltas token go tapa. Seo roinnt straitéisí optamaithe:
Leibhéal an Mhionsonraithe a Choigeartú
Úsáid low le haghaidh comparáidí ginearálta agus high ach amháin nuair a dhéanann tú anailís ar mhionsonraí:
# Comparáid ghinearálta: tá low leordhóthanach
detail = "low" # ~256 tokens per image
# Anailís ar lochtanna: teastaíonn high
detail = "high" # ~1024-1792 tokens per image
Teorainn a Chur le Líon na nÍomhánna in aghaidh an Iarratais
Cé nach bhfuil aon teorainn chrua ann, d’fhéadfadh cáilíocht na hanailíse laghdú le níos mó ná 10-15 íomhá. Tá comhthéacs críochta ag an tsamhail agus caithfidh sí é a dháileadh ar gach íomhá:
# Má tá níos mó ná 10 íomhá ann, próiseáil i mbaitseanna
def analyser_par_lots(images, taille_lot=10):
resultats = []
for i in range(0, len(images), taille_lot):
lot = images[i:i + taille_lot]
resultat = analyser_lot(lot)
resultats.append(resultat)
return fusionner_resultats(resultats)
Íomhánna a Athrú Méide
Má tá tú ag déanamh comparáide idir grianghraif ardtaifigh le haghaidh anailíse ginearálta, athraigh a méid sula seolann tú iad chun token a laghdú:
def preparer_pour_comparaison(chemin, taille_max=(800, 800)):
img = Image.open(chemin)
img.thumbnail(taille_max)
# ... encode to base64
Príomhphointí
- Tá líon na n-íomhánna in aghaidh an iarratais gan teorainn — is buntáiste lárnach é seo de chuid API xAI
- Lipéadaigh gach íomhá le téacs chun an anailís a struchtúrú
- Coigeartaigh an paraiméadar
detailde réir chineál na comparáide - Thar 10-15 íomhá, próiseáil i mbaitseanna chun cáilíocht a choinneáil
- Áirítear ar chásanna úsáide: roimh/ina dhiaidh, rianú sealadach, rialú cáilíochta, anailís iomaíochta