Anybody manged to work with CustomVision cognitive service from Microsoft ?

Hello,

I have been trying to work with CustomVision for 2 days without getting any success. I have tried several different libraries, including Microsoft's own (Microsoft.Azure.CognitiveServices.Vision.CustomVision.Prediction) and opened an issue on its github page.

The only times I have been been able to get a successful response (200 and not 404 status) was when I was using these libraries with Windows. But whenever I tried using the exact same library on an Android application based on Xamarin.Forms, I systematically got a 404 not found response from the API.

Last thing I tried was trying to run the sample in this official Xamarin tutorial but an exception gets thrown before even hitting the API call, and it's also important to note that the nuget library used here has been deprecated (Microsoft.Cognitive.CustomVision.Prediction) so at this point I'm really starting to feel like I will never be able to use this API with Xamarin anyway.

But I'm also wondering, are there actually even people out there who are successfully using this API with Xamarin.Forms?

Any insight or shared-experience on the subject would be appreciated, and thank you for taking the time to read me.

Answers

  • jezhjezh Member, Xamarin Team Xamurai

    Could you please post the full logs of the error you encountered?

  • BouzigouloumBouzigouloum Member ✭✭

    I initially had put all the relevant links in the post but it seems I can not post links yet.

    Here is the details of the exception getting thrown:
    Microsoft.Rest.HttpOperationException: 'Operation returned an invalid status code 'NotFound'

    And the stack trace:
    Microsoft.Azure.CognitiveServices.Vision.CustomVision.Prediction.CustomVisionPredictionClient.d__26.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Microsoft.Azure.CognitiveServices.Vision.CustomVision.Prediction.CustomVisionPredictionClientExtensions.d__4.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Microsoft.Azure.CognitiveServices.Vision.CustomVision.Prediction.CustomVisionPredictionClientExtensions.PredictImage(ICustomVisionPredictionClient operations, Guid projectId, Stream imageData, Nullable`1 iterationId, String application)

  • utekaiutekai USMember ✭✭✭

    More details on your call and which not found is it. The service, or the operation.

    West coast data center was needed last time used this service.

  • BouzigouloumBouzigouloum Member ✭✭

    The "not found" error is the message of an exception thrown by the HttpClient, when receiving a 404 response to its request.

    Here is a code snippet:

    HttpClient httpClient = new HttpClient();
    CustomVisionPredictionClient customVisionPredictionClient = new CustomVisionPredictionClient(httpClient, false)
    {
    ApiKey = PredictionKey,
    Endpoint = PredictionEndpoint,
    };
    using (var imageData = new FileStream(@"d:\input.png", FileMode.Open))
    {
    var result = customVisionPredictionClient.PredictImage(ProjectGuid, imageData);
    }
    

    I have tried the following endpoints: (please not that I removed "https.." because I can not post links)
    southcentralus.api.cognitive.microsoft.com/customvision/v2.0/Prediction southcentralus.api.cognitive.microsoft.com/customvision/Prediction/v1.0 southcentralus.api.cognitive.microsoft.com/customvision/v1.1/Prediction

    Again, I was able to obtain a successful response from the API using the deprecated Microsoft.Cognitive.CustomVision.Prediction client using any of these endpoints, so it does not seem that this is the cause of the issue.

  • utekaiutekai USMember ✭✭✭
    edited March 20

    Try using 'westcentralus'rather than southcentral.

    West coast data center as already posted.

    This may help you get a grip.

    And note the data center used in this beginner's walkthrough.

  • BouzigouloumBouzigouloum Member ✭✭
    edited March 22

    Thank you for your suggestions, I tried changing "southcentral" for "westcentralus" but did not have more success unfortunately.

Sign In or Register to comment.