Azure-Samples / cognitive-services-dotnet-sdk-samples

Learn how to use the Cognitive Services SDKs with these samples
MIT License
117 stars 169 forks source link

'NotFoundIteration' Error when Calling DetectImage() for Object detection 'CustomVisionPredictionClient' #210

Open ShamineDsouza opened 3 years ago

ShamineDsouza commented 3 years ago

Microsoft.Azure.CognitiveServices.Vision.CustomVision.Prediction.Models.CustomVisionErrorException: 'Operation returned an invalid status code 'NotFound'' Error : Detail | Body | {Microsoft.Azure.CognitiveServices.Vision.CustomVision.Prediction.Models.CustomVisionError} | Microsoft.Azure.CognitiveServices.Vision.CustomVision.Prediction.Models.CustomVisionError   | Code | "NotFoundIteration" | string   | Message | "Invalid iteration" | string

Above is the error , I am getting when running to test the prediction model. Error is returned on this line of code var result = predictionApi.DetectImage(project.Id, lstIteration[0].Name, stream);

Sample Code :

private void TestIteration(CustomVisionPredictionClient predictionApi, Project project, IList lstIteration) { var imageFile = Server.MapPath("~/" + imgPath); using (var stream = File.OpenRead(imageFile)) { var result = predictionApi.DetectImage(project.Id, lstIteration[0].Name, stream); foreach (var c in result.Predictions) { Console.WriteLine($"\t{c.TagName}: {c.Probability:P1} [ {c.BoundingBox.Left}, {c.BoundingBox.Top}, {c.BoundingBox.Width}, {c.BoundingBox.Height} ]"); } } }

aitchkhan commented 2 years ago

what was the issue? getting a similar issue

ShamineDsouza commented 2 years ago

The iteration number mentioned is not correct. Check the iteration number in custom model, on which it is trained . The iteration number changes every time it is trained / predicted.

Eg: Iteration1 --> Iteration2