BadRequest Error when using predicitionAPI to classify images

Linabury, Cale 0 Reputation points
2023-10-19T01:14:56.9433333+00:00

Hello,

I'm currently working on a project implementing custom vision in a HoloLens 2 app. I'm working through the tutorial at https://video2.skills-academy.com/en-us/training/modules/azure-cloud-services-tutorials/ and have made it to the step "integrate azure custom vision" I have my custom vision project set up and some tags that we've trained images for. Everything works so far with the guide, the hololens is taking photos and sending them through the trainingAPI and they show up on our custom vision web portal, but predicitons do not seem to be working. I've narrowed it down to the DetectImage function when it builds the http request to send to the custom vision service. The response message errors and gives BadRequest with the request message being

▶RequestMessage"Method: POST, RequestUri: 'https://customvisionobjdettest-prediction.cognitiveservices.azure.com//customvision/v3.0/prediction/myprojectID/classify/iterations/Toasters/image', Version: 1.1, Content: System.Net.Http.ByteArrayContent, Headers:\r\n{\r\nPrediction-Key: mypredicitionkey\r\nContent-Length: 45769\r\n}"System.Net.Http.HttpRequestMessageI've verified that the key and the projectID are correct as I have a similar script using the custom vision libraries that was working but can't seem to figure out what might be wrong here. I was wondering if anyone could offer any help, if you need more information or anything else let me know.

Thanks

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.
233 questions
HoloLens Development
HoloLens Development
HoloLens: A family of Microsoft self-contained, holographic devices that enable engagement with digital content and interaction with holograms in the surrounding environment.Development: The process of researching, productizing, and refining new or existing technologies.
388 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Zahid Kola 0 Reputation points
    2023-12-16T00:42:15.52+00:00

    Thank you for reaching out for help with your HoloLens 2 project. It sounds like you're having issues with the DetectImage function in the Azure Cloud Services tutorial. Specifically, you're getting a BadRequest error with a request message that includes the Prediction-Key and Content-Length headers.

    First, I would recommend double-checking that the Prediction-Key and projectID in the request message match the values you have set up in your Custom Vision project. It's possible that there's a discrepancy between the values you're using in your code and the values in your Custom Vision project.

    Another potential issue could be with the content of the request message. The error message mentions that the Content-Length is 45769, which suggests that the request is including a large amount of data. It's possible that the request is including unnecessary data, or that the data is not properly formatted.

    I would recommend checking the documentation for the Custom Vision service to ensure that you're formatting the request correctly. Additionally, you may want to try using a tool like Fiddler or Postman to inspect the HTTP request and response messages to see if there are any issues with the request that you're not aware of.

    Finally, it's possible that there's an issue with the Custom Vision service itself. I would recommend checking the Azure status page to see if there are any known issues with the service. If there are any issues, you may need to wait for them to be resolved before you can continue working on your project.

    I hope these suggestions are helpful in resolving the issue you're experiencing.

    0 comments No comments