0

我正在尝试完成 AI School 的这个 sketch2code 教程https://aischool.microsoft.com/en-us/services/learning-paths/sketch2code/sketch2code-lab/train-an-object-detection-model

本教程的第 9 步说:

输入命令dotnet运行并按回车键。

我正在使用 Visual Studio 2019 这可能是问题吗?

Unhandled Exception: Microsoft.Rest.HttpOperationException: Operation returned an invalid status code 'Unauthorized'
   at Microsoft.Azure.CognitiveServices.Vision.CustomVision.Training.TrainingApi.GetDomainsWithHttpMessagesAsync(Dictionary`2 customHeaders, CancellationToken cancellationToken)
   at Microsoft.Azure.CognitiveServices.Vision.CustomVision.Training.TrainingApiExtensions.GetDomainsAsync(ITrainingApi operations, CancellationToken cancellatio
nToken)
   at Microsoft.Azure.CognitiveServices.Vision.CustomVision.Training.TrainingApiExtensions.GetDomains(ITrainingApi operations)
   at Import.Program.Main(String[] args) in C:\Users\Harry\Downloads\AISchoolTutorials\sketch2code\Import\Program.cs:line 29
4

1 回答 1

0

您必须更新 Microsoft.Azure.CognitiveServices.Vision.CustomVision.Training 包。

  1. 打开终端并转到导入文件夹

  2. 运行以下命令dotnet add package Microsoft.Azure.CognitiveServices.Vision.CustomVision.Training --version 2.0.0

  3. 打开 Program.cs 并替换这一行:

    TrainingApi trainingApi = new TrainingApi() { ApiKey = trainingKey };

    用这条线:

    CustomVisionTrainingClient trainingApi = new CustomVisionTrainingClient(new ApiKeyServiceClientCredentials(trainingKey)) {Endpoint = endpoint};

    确保用您来自customvision.ai的 ENDPOINT 替换

于 2020-07-10T12:41:47.203 回答