自定义视觉预测API - 无法找到迭代? [英] Custom Vision Prediction API - unable to find iteration?

查看:87
本文介绍了自定义视觉预测API - 无法找到迭代?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我是
我正在尝试使用API​​密钥和API端点访问我的预测迭代。但是,我不断收到错误消息:"操作返回了无效的状态代码'NotFound'"

经过研究,我发现其他人遇到了这个问题并通过 表示解决了通过CustomVision.ai界面(特别是"性能"选项卡)进行默认迭代。 奇怪的是,我无法找到"默认设置"。选择迭代时
选项。


如果这确实不是我的错误的根本原因,我将包含我的代码片段:

 var publishedName =" Iteration 2" ;; 
string predictionKey = mypredictionkey;
CustomVisionPredictionClient endpoint = new CustomVisionPredictionClient()
{
ApiKey = predictionKey,
Endpoint =" https://microsoft.com/customvision/v3.0/Prediction/mykey/分类/迭代/迭代%202 /图像"
};


//将文件内容复制到请求流。
byte [] fileContents;
StreamReader sourceStream;
using(sourceStream = new StreamReader(FileUpload1.PostedFile.InputStream))
{
fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
}

testImage = new MemoryStream(fileContents);
Guid ProjectID = new Guid("myprojectid");
Console.WriteLine("做出预测:");
var result = endpoint.ClassifyImage(ProjectID,publishedName,testImage);
//错误发生在这里:{"操作返回了无效的状态代码'NotFound'"}
//循环每个预测并写出结果
foreach(结果中的var c) 。预测)
{
Console.WriteLine($" \t {c.TagName}:{c.Probability:P1}");
}

感谢您的时间和精力。


解决方案

您好,


我认为您的问题类似于
one


在自定义视觉门户中
home
选择您正在使用的项目,然后选择Performance选项卡。在页面左侧您将看到Iterations。选择您想要的迭代并选择Prediction URL。这将打开一个新对话框,其中包含图像URL和图像
文件的URL。在此URL中,迭代ID是传递的参数,复制ID并在您的应用程序中使用它。



" ;如上所示,"默认"按钮也应出现在"预测URL"按钮旁边。这使得迭代默认,在这种情况下您不需要在URL中使用迭代ID。



------------------------------- -------------------------------------------------- --------------------------
$
如果您发现此帖子有帮助,请给它一个"有用的"投票。 

如果有帮助,请记得将回复标记为答案。


Hello,
I am trying to access my Prediction Iteration using the API Key and the API Endpoint. However, I keep getting an error that says: "Operation returned an invalid status code 'NotFound'"
After researching, I have found that others have had this problem and resolved it by indicating a default iteration through the CustomVision.ai interface (specifically the Performance tab).  Strangely, I am unable to find the "Make default" option when I select an iteration.

In the case that this is indeed NOT the root cause of my error, I am going to include a snippet of my code:

                        var publishedName = "Iteration 2";
                        string predictionKey = mypredictionkey;
                        CustomVisionPredictionClient endpoint = new CustomVisionPredictionClient()
                        {
                            ApiKey = predictionKey,
                            Endpoint = "https://microsoft.com/customvision/v3.0/Prediction/mykey/classify/iterations/Iteration%202/image"
                        };


                        // Copy the contents of the file to the request stream.
                        byte[] fileContents;
                        StreamReader sourceStream;
                        using (sourceStream = new StreamReader(FileUpload1.PostedFile.InputStream))
                        {
                            fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
                        }

                        testImage = new MemoryStream(fileContents);
                        Guid ProjectID = new Guid("myprojectid");
                        Console.WriteLine("Making a prediction:");
                        var result = endpoint.ClassifyImage(ProjectID, publishedName, testImage);
//error happens here: {"Operation returned an invalid status code 'NotFound'"}
                        // Loop over each prediction and write out the results
                        foreach (var c in result.Predictions)
                        {
                            Console.WriteLine($"\t{c.TagName}: {c.Probability:P1}");
                        }

Thank you for your time and attention.

解决方案

Hello,

I think your issue is similar to this one.

In the custom vision portal home, Select the project you are using, then select the Performance Tab. On the left side of the page you would see Iterations. Select the Iteration that you want and select Prediction URL. This will open a new dialog which gives the URL's for image URL and image file. In this URL the iteration id is a parameter that is passed, Copy the id and use it in your application. 

The "Make default" button should also appear next to the "Predication URL" button as seen above. This makes the iteration default and you need not use the iteration id in the URL in that case.

-----------------------------------------------------------------------------------------------------------
If you found this post helpful, please give it a "Helpful" vote. 
Please remember to mark the replies as answers if they help.


这篇关于自定义视觉预测API - 无法找到迭代?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆