0

我正在尝试按照此处找到的 Azure 文档中的教程来获得一个基本的自定义视觉图像分类器:https ://docs.microsoft.com/en-us/azure/cognitive-services/custom-vision-service/ quickstarts/image-classification?pivots=programming-language-java

我逐字逐句地遵循本教程,并花了几天时间试图解决这个问题。我遇到的问题是在运行代码时我得到以下堆栈跟踪:

Parameter this.client.endpoint() is required and cannot be null.
java.lang.IllegalArgumentException: Parameter this.client.endpoint() is required and cannot be null.
    at com.microsoft.azure.cognitiveservices.vision.customvision.training.implementation.TrainingsImpl.createProjectWithServiceResponseAsync(TrainingsImpl.java:2313)
    at com.microsoft.azure.cognitiveservices.vision.customvision.training.implementation.TrainingsImpl$TrainingsCreateProjectParameters.execute(TrainingsImpl.java:2401)
    at com.microsoft.azure.cognitiveservices.vision.customvision.samples.CustomVisionSamples.ImageClassification_Sample(CustomVisionSamples.java:67)
    at com.microsoft.azure.cognitiveservices.vision.customvision.samples.CustomVisionSamples.runSample(CustomVisionSamples.java:46)
    at com.microsoft.azure.cognitiveservices.vision.customvision.samples.CustomVisionSamples.main(CustomVisionSamples.java:374)

端点在这里定义并作为参数传递

final String Endpoint = System.getenv("AZURE_CUSTOMVISION_ENDPOINT");

            CustomVisionTrainingClient trainClient = CustomVisionTrainingManager.authenticate("https://{Endpoint}/customvision/v3.0/training/", CustomVisionTrainingClientKey).withEndpoint(Endpoint);
            CustomVisionPredictionClient predictClient = CustomVisionPredictionManager.authenticate("https://{Endpoint}/customvision/v3.0/prediction/", predictionApiKey).withEndpoint(Endpoint);

虽然本教程没有明确说明这样做,但我尝试使用 PowerShell 手动设置系统环境变量 AZURE_CUSTOMVISION_ENDPOINT ,无论有没有这个设置都不起作用。

我错过了什么吗?任何帮助将不胜感激!

4

1 回答 1

0

修复了我自己的问题。环境变量设置不正确,是空指针。我用纯文本替换了对字符串的 System.getenv 调用,这工作正常。

于 2020-07-10T12:12:02.147 回答