Azure-Samples / Azure-Samples/cognitive-services-dotnet-sdk-samples
'NotFoundIteration' Error when Calling DetectImage() for Object detection 'CustomVisionPredictionClient'
- Dominant language
- C#
- Stars
- 123
- Forks
- 166
- PR merge metrics
- No merged PRs in 30d
Description
**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} ]");
}
}
}
Contributor guide
Assessment
This issue has not been assessed yet.