CustomVision: Operation returned an invalid status code: 'NotFound'

与世无争的帅哥 提交于 2019-12-11 02:33:48

问题


I'm using the NuGet package Microsoft.Cognitive.CustomVision.Prediction version 1.2.0. I created 1 trial project and trained it with a few images. Now when I try to call the API for a prediction using the PredicionEndpoint, the system throws an exception: Microsoft.Rest.HttpOperationException.

When I debug the code and inspect the exception, it says:

{"Operation returned an invalid status code 'NotFound'"}

This is my code:

var attachmentStream = await httpClient.GetStreamAsync(imageUrl);

PredictionEndpoint endpoint = new PredictionEndpoint() {
 ApiKey = "MY_CORRECT_PREDICTION_KEY"
};

var predictions = new ImagePredictionResultModel();

try {
 predictions = endpoint.PredictImage(new Guid("MY_CORRECT_PROJECT_ID"), attachmentStream);
} catch (Microsoft.Rest.HttpOperationException exception) {
 await context.PostAsync(exception.Body.ToString());
 await context.PostAsync(exception.Data.ToString());
}

foreach(var c in predictions.Predictions) {
  Console.WriteLine($ "{c.Tag}: {c.Probability}");
}

attachmentStream is a correct stream of an image, I am able to output it to a project-specific view.

The exception gets thrown when calling endpoint.PredictImage(...).


回答1:


The issue was that you should mark one of the training interations as default as mentioned in the GithUb issue I created.



来源:https://stackoverflow.com/questions/51611116/customvision-operation-returned-an-invalid-status-code-notfound

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!