Azure Custom Vision Error: Invalid status code 'Unauthorized'

Khalid Obaid 15 Reputation points
2023-12-20T16:08:31.55+00:00

Hi I am using the tutorial on Azure Custom Vision Object Detector Quick Start to setup the prediction endpoint. I created a project and trained it (detector) via the webportal. I then published my iteration to the Prediction API. Then I use a python script to test the prediction API. Within the script I get the project using the trainer.get_project("projectID") call. The project ID and name match with what I have on the webportal which means it has worked fine. I then try to test the prediction API using the "predictor.detect_image(project.id, publish_iteration_name, test_data)" call.

However, at this point I get the following error:

"azure.cognitiveservices.vision.customvision.prediction.models._models_py3.CustomVisionErrorException: Operation returned an invalid status code 'Unauthorized"

Can someone help me what the issue could be. I am using the correct API keys and Endpoint details.

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

1 answer

Sort by: Most helpful
  1. Khalid Obaid 15 Reputation points
    2023-12-20T16:35:04.0466667+00:00

    I was able to solve the issue, but I guess there is a mistake in the version on Azure Custom Vision Object Detector Quick Start.

    The call below uses the variable "ENDPOINT" which is set to the "VISION_TRAINING_ENDPOINT" which is actually for the trainer. The ENDPOINT for the predictor should be set to "VISION_PREDICTION_ENDPOINT". I was able to solve the issue by this minor change. Please correct this mistake in the Quick Start guide as well.

    predictor = CustomVisionPredictionClient(ENDPOINT, prediction_credentials)
    
    2 people found this answer 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.