How to fix error 404 "resource not found"?

Michiel Vlieger (student) 25 Reputation points
2024-05-02T15:02:13.58+00:00

I have trained a custom product recognition model based on this tutorial: https://learn.microsoft.com/en-us/azure/ai-services/computer-vision/how-to/shelf-model-customization.
The model is done training with status "succeeded". When I try to test the model by following the tutorial I get a 404 error with the message "resource not found". I've tried different things: restarting the whole tutorial with different regions, making different models, using postman, using curl command in cmd, using the two different keys. But I keep getting the same error. I copied the command straight from the tutorial: https://learn.microsoft.com/en-us/azure/ai-services/computer-vision/how-to/shelf-model-customization#analyze-shelves-with-a-custom-model.

The curl command looks like this:

curl.exe -H "Ocp-Apim-Subscription-Key: <my key was here>" -H "Content-Type: application/json" "<endpoint of computer vision>/computervision/productrecognition/aimodel/runs/test1?api-version=2023-04-01-preview" -d "{'url':'<link to image>'}"

What am I doing wrong or is the tutorial not up to date?

Region: west europe

Azure AI Custom Vision
Azure AI Custom Vision
An Azure artificial intelligence service and end-to-end platform for applying computer vision to specific domains.
249 questions
0 comments No comments
{count} vote

Accepted answer
  1. dupammi 8,535 Reputation points Microsoft Vendor
    2024-05-03T11:29:25.2766667+00:00

    Hi @Michiel Vlieger (student)

    Thank you for using the Microsoft Q&A forum.

    I tried to repro your use case from my end. First created and trained a custom Product recognition model, based on the tutorial provided in the question. It was successful.

    User's image

    Regarding your next question about the CURL command, I followed the ProductRecognition_Create form and the ProductRecognition_Get form of the API testing Console to find out that, it is required to send a PUT request followed by a GET request in CURL, reason being that the PUT request creates a new run for the model, and the GET request retrieves the results of that run. When you send a PUT request, you specify the name of the run, and the API creates a new run with that name. Then, when you send a GET request, you specify the same run name, and the API returns the results of that run.

    User's image

    It seems, you were receiving a 404 error because you were only sending a GET request, but you had not created a run for the model yet. By sending a PUT request first to create a new run, and then sending a GET request to retrieve the results of that run, you should be able to successfully test your custom product recognition model.

    The runname in the 1st CURL with PUT can be anything random, which you want the runname to be. Then use the same "run name" that you gave in the GET request as well.

    Here's the repro

    PUT

    curl.exe -v -X PUT -H "Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTIONKEY
    " -H "Content-Type: application/json" "YOUR_ENDPOINT
    /computervision/productrecognition/prdrecog1/runs/run22?api-version=2023-04-01-preview" -d "{ 'url':'https://learn.microsoft.com/en-us/azure/ai-services/computer-vision/media/shelf/rectification.png' }"
    
    

    Here I gave run22 as the "run name" param value. you can give anything. "prdrecog1" is my model name.

    GET

    curl.exe -v -X GET -H "Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTIONKEY" -H "Content-Type: application/json" "YOUR_ENDPOINT/computervision/productrecognition/prdrecog1/runs/run22?api-version=2023-04-01-preview"
    
    

    Here I used same run22 as the "run name" param value, that I gave in PUT.

    GET Output:

    User's image

    I hope this helps. Thank you.


    Please don't forget to click Accept Answer and Yes for was this answer helpful.

    3 people found this answer helpful.

0 additional answers

Sort by: Most helpful

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.