我正在尝试完成AI School https://aischool.microsoft.com/en-us/services/learning-paths/sketch2code/sketch2code-lab/train-an-object-detection-model
的此sketch2code教程教程的第9步说:
输入运行命令
dotnet
,然后按Enter键。
我正在使用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
答案 0 :(得分:0)
您必须更新Microsoft.Azure.CognitiveServices.Vision.CustomVision.Training程序包。
打开您的终端并转到“导入”文件夹
运行以下命令dotnet add package Microsoft.Azure.CognitiveServices.Vision.CustomVision.Training --version 2.0.0
打开Program.cs并替换以下行:
TrainingApi trainingApi = new TrainingApi() { ApiKey = trainingKey };
有这行:
CustomVisionTrainingClient trainingApi = new CustomVisionTrainingClient(new ApiKeyServiceClientCredentials(trainingKey)) {Endpoint = endpoint};
请确保使用customvision.ai
中的ENDPOINT替换您的ENDPOINT