Java的谷歌AutoML NLP客户端的响应永远等待(无例外抛出)

问题描述 投票:1回答:1

我昨天训练的成功地我自己的NLP AutoML模型。我能够在GCP控制台做的相当准确的预测。一切都运行平稳。今天,我一直在试图基于这个例子https://github.com/GoogleCloudPlatform/java-docs-samples/blob/master/language/automl/src/main/java/com/google/cloud/language/samples/PredictionApi.java从Java客户端做预测

我用正确的专案编号和modelId,我从GCP控制台复制,但我永远在等待结果。即使几分钟后,仍然没有反应。有没有例外抛出。我用欧洲west3为computeRegion。

奇怪的是,我还使用Java客户端,谷歌NLP情感分析和它的作品没有问题,并立即返回响应(基于这个例子https://github.com/GoogleCloudPlatform/java-docs-samples/blob/master/language/cloud-client/src/main/java/com/example/language/QuickstartSample.java

这两个客户端连接到相同的GCP项目(具有相同的专案编号),但其中只有一个工作正常。

你请有一些什么线索可能是错的?

谢谢你提前任何提示

这是代码:

公共类PredictionApi {

public static void main(String[] args) throws IOException {
    PredictionApi predictionApi = new PredictionApi();
    predictionApi.predict("projectId", "us-central1", "modelId");
}

private void predict(String projectId, String computeRegion, String modelId) throws IOException {
    PredictionServiceClient predictionClient = PredictionServiceClient.create();
    ModelName name = ModelName.of(projectId, computeRegion, modelId);
    String content = "BERLIN Germany and China want to sign two agreements to deepen their cooperation in the financial sector later this week a German government document seen by Reuters showed on Wednesday";
    TextSnippet textSnippet =
            TextSnippet.newBuilder().setContent(content).setMimeType("text/plain").build();
    ExamplePayload payload = ExamplePayload.newBuilder().setTextSnippet(textSnippet).build();

    Map<String, String> params = new HashMap<String, String>();
    PredictResponse response = predictionClient.predict(name, payload, params);

    System.out.println("Prediction results:");
    for (AnnotationPayload annotationPayload : response.getPayloadList()) {
        System.out.println("Predicted Class name :" + annotationPayload.getDisplayName());
        System.out.println(
                "Predicted Class Score :" + annotationPayload.getClassification().getScore());
    }
}

}

java google-cloud-platform google-natural-language google-cloud-automl
1个回答
0
投票

不支持europe-west3。所有训练的automl模型在us-central1目前担任。你应该在理论上得到了一些错误,如您在another stackoverflow post报道什么。我有点惊讶,你没有从服务器收到任何错误消息。你介意分享您的客户端代码?

© www.soinside.com 2019 - 2024. All rights reserved.