我正在使用 NuGet 包Microsoft.Cognitive.CustomVision.Prediction
版本1.2.0
。我创建了 1 个试验项目并用一些图像对其进行了训练。现在,当我尝试使用 API 调用 API 进行预测时PredicionEndpoint
,系统抛出异常: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(...)
.
问题是您应该将其中一个训练交互标记为default
如中提到的我创建的 GithUb 问题 https://github.com/Microsoft/Cognitive-CustomVision-Windows/issues/19.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)