Могу ли я использовать объект gsUrl (ресурс хранилища Google) в качестве полезной нагрузки для AutoML Vision Predict API? - PullRequest
0 голосов
/ 20 апреля 2020

На странице примера AutoML Predict API ,

static void predict(***String projectId, String modelId, String filePath***) throws IOException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (PredictionServiceClient client = PredictionServiceClient.create()) {
      // Get the full path of the model.
      ModelName name = ModelName.of(projectId, "us-central1", modelId);
      ByteString content = ByteString.copyFrom(Files.readAllBytes(Paths.get(filePath)));
      Image image = Image.newBuilder().setImageBytes(content).build();
      ExamplePayload payload = ExamplePayload.newBuilder().setImage(image).build();
      PredictRequest predictRequest =
          PredictRequest.newBuilder()
              .setName(name.toString())
              .setPayload(payload)
              .putParams(
                  "score_threshold", "0.8") // [0.0-1.0] Only produce results higher than this value
              .build();

      PredictResponse response = client.predict(predictRequest);

      for (AnnotationPayload annotationPayload : response.getPayloadList()) {
        System.out.format("Predicted class name: %s\n", annotationPayload.getDisplayName());
        System.out.format(
            "Predicted class score: %.2f\n", annotationPayload.getClassification().getScore());
      }
    }

полезная нагрузка поступает из одного изображения вызывающей стороны. Но я загрузил изображения в одно Google Storage Bucket.

Я просто хочу позвонить в Predict API, чтобы получить мгновенный ответ.

Есть ли новый API или новый Payload Impl для разрешения выше? случай

...