CustomVision:操作返回了无效的状态代码:'NotFound'

时间:2018-07-31 10:22:32

标签: c# computer-vision prediction azure-cognitive-services

我正在使用NuGet软件包Microsoft.Cognitive.CustomVision.Prediction版本1.2.0。我创建了一个试验项目,并用一些图像对其进行了训练。现在,当我尝试使用PredicionEndpoint调用API进行预测时,系统会引发异常:Microsoft.Rest.HttpOperationException

当我调试代码并检查异常时,它说:

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

这是我的代码:

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是图像的正确流,我可以将其输出到项目特定的视图。

调用endpoint.PredictImage(...)时会引发异常。

1 个答案:

答案 0 :(得分:2)

问题是,您应该按照GithUb issue I created所述将其中一个训练交互标记为default