SimilarProduct Insight not working in visual search API

Martin Meyer 0 Reputation points
2024-11-06T23:34:23.5533333+00:00

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": {}}

Bing Visual Search
Bing Visual Search
A Bing service that gives you rich insights to help build compelling image applications on the device of your choice.
25 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.