gpt4 book ai didi

azure - 获取 CustomVisionErrorException : Operation returned an invalid status code "BadRequest"

转载 作者:行者123 更新时间:2023-12-03 05:44:04 26 4
gpt4 key购买 nike

我尝试通过使用pickphoto跨媒体提交图像并获取预测结果来使用Microsoft.Azure.CognitiveServices.Vision.CustomVision.Prediction功能。我尝试将图像作为 url 或流传递,但不断收到错误请求。我知道我有正确的预测键和端点,因为我从事训练工作,告诉我这是将图像传递到方法中的方式。将 Cross Media 选取照片包中的图像转换为

的正确方法是什么
private async void UplodatePictureButton_Clicked(object sender, EventArgs e)
{
await CrossMedia.Current.Initialize();
MediaFile file;
if (!CrossMedia.Current.IsPickPhotoSupported)
{
await DisplayAlert("No upload", "Picking a photo is not supported", "OK");
return;

}
file = await CrossMedia.Current.PickPhotoAsync();
if (file == null)
{
return;
}

MainImage.Source = ImageSource.FromStream(() =>
{
var stream = file.GetStream();

return stream;
});


// Create the Api, passing in the training key
CustomVisionTrainingClient trainingApi = new CustomVisionTrainingClient()
{
ApiKey = trainingKey,
Endpoint = SouthCentralUsEndpointTraining
};
var projects = trainingApi.GetProjects();
var project = projects.FirstOrDefault(p => p.Name == "Car");
CustomVisionPredictionClient endpoint = new CustomVisionPredictionClient()
{
ApiKey = predictionKey,
Endpoint = SouthCentralUsEndpointPrediction
};


var result = endpoint.ClassifyImageUrl(project.Id, project.Name, new Microsoft.Azure.CognitiveServices.Vision.CustomVision.Prediction.Models.ImageUrl(file.Path));



foreach (var c in result.Predictions)
{
Console.WriteLine($"\t{c.TagName}: {c.Probability:P1}");
}


}

Unhandled Exception: Microsoft.Azure.CognitiveService.Vision.CustomerVision.Prediction.Models.CustomVisionErrorException: Operation returned an invalid status code "BadRequest" Expect a prediction.

这是代码的图片: code这是问题的图片: problem

最佳答案

我在尝试执行端点时收到相同的“错误请求消息”。DetectImage(projectId,iteractionName,stream)。问题是上周它运行得非常完美。我注意到只有 2 mb 左右的大图像才会出现这种情况

关于azure - 获取 CustomVisionErrorException : Operation returned an invalid status code "BadRequest",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56241300/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com