C# CustomVision:操作返回的状态代码无效:';未找到';

C# CustomVision:操作返回的状态代码无效:';未找到';,c#,computer-vision,prediction,azure-cognitive-services,C#,Computer Vision,Prediction,Azure Cognitive Services,我正在使用NuGet软件包Microsoft.Cognitive.CustomVision.Predictionversion1.2.0。我创建了一个试用项目,并用一些图片对其进行了培训。现在,当我尝试使用PredicionEndpoint调用API进行预测时,系统抛出一个异常:Microsoft.Rest.HttpOperationException 当我调试代码并检查异常时,它会显示: {"Operation returned an invalid status code 'NotFound

我正在使用NuGet软件包Microsoft.Cognitive.CustomVision.Prediction
version
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(…)
时引发异常问题是您应该将其中一个培训交互标记为
默认值
,如中所述。

可能它不喜欢项目ID的GUID?尝试使用
CustomVision.Training
NuGet软件包,您可以获得项目列表。从那里可以按项目名称对它们进行筛选。一旦你把你的项目拿到那里,你就可以使用
Id
属性来调用
PredictImage
了。我试着这样做,但是我得到了同样的结果。我还比较了检索到的GUID和我之前和之后使用的GUID,但都是一样的。嗯,你需要使用流吗?图像URL本身会不会不起作用?请看,很抱歉,我无法再检查,因为我不再使用自定义vision。我的案例中不存在“默认设置”链接/按钮。可能是他们更新了UI。。。对不起,我不再和CustomVision合作了,所以我帮不了你。