SimilarProduct Insight not working in visual search API
Martin Meyer
0
Reputation points
Hi
i have this trying to find similiar products for an image of an product. Following the documentation
i just need put "SimilarProducts" in the invodedSkills of the api call
but i not get any answer with this code
endpoint = "https://api.bing.microsoft.com/v7.0/images/visualsearch"
image_url = "https://m.media-amazon.com/images/I/71CBk3JtF6L.__AC_SY300_SX300_QL70_ML2_.jpg"
# Specify the image insights token
knowledge_request = {
"imageInfo": {
"url": image_url # Provide the URL of the image you want insights for
#"imageInsightsToken": "ccid_cixTCTqz*cp_D7F0A068A89FA15BECFF781E1353DC4F"
},
"knowledgeRequest" : {
"invokedSkills": ["SimilarProducts"],
}
}
# Set the unique boundary
boundary = "boundary_1234abcd"
# Prepare the headers with multipart form-data
headers = {
"Ocp-Apim-Subscription-Key": subscription_key,
"Content-Type": f"multipart/form-data; boundary={boundary}"
}
# Format the multipart form-data body
body = (
f"--{boundary}\r\n"
f"Content-Disposition: form-data; name=\"knowledgeRequest\"\r\n\r\n"
f"{json.dumps(knowledge_request)}\r\n"
f"--{boundary}--"
)
# Send the POST request
response = requests.post(endpoint, headers=headers, data=body)
i get this response for an amazon product image
{"_type": "ImageKnowledge", "instrumentation": {"_type": "ResponseInstrumentation"}, "tags": [{"displayName": "", "actions": []}], "image": {"imageInsightsToken": "ccid_cixTCTqz*cp_D7F0A068A89FA15BECFF781E1353DC4F"}, "debugInfo": {}}
Sign in to answer