我正在学习AI School在sketch2code应用程序上提供的教程(链接:https://aischool.microsoft.com/en-us/services/learning-paths/sketch2code/sketch2code-lab/train-an-object-detection-model)
我已经按照指示将我的训练密钥粘贴到program.cs文件中,当我运行"dotnet run"命令时,它会给我以下错误:
未处理的异常:Microsoft.Rest.HttpOperationException:操作返回了无效的状态代码"未授权"位于Microsoft.Azure.CongnitiveServices.Vision.CustomVision.TrainingApi.GetDomainsWithHttpMessagesAsync(字典`2 customHeaders,CancellationToken cancellionToken(在Microsoft.Azure.CongnitiveServices.Vision.CustomVision.Training。TrainingApiExtensions.GetDomainsAsync(ITrainingApi操作,CancellationToken取消令牌(在Microsoft.Azure.CongnitiveServices.Vision.CustomVision.Training。TrainingApiExtensions.GetDomains(ITrainingApi操作(在C:\Users\DELL_PC\Desktop\BE Project\AISchoolTutorials\skitch2code\Import\Program.cs:line 29 中的Import.Program.Main(String[]args(
有什么帮助吗?
您必须更新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};
确保从customer.ai 将ENDPOINT替换为您的