Search in sources :

Example 1 with ImageObjectDetectionModelDeploymentMetadata

use of com.google.cloud.automl.v1beta1.ImageObjectDetectionModelDeploymentMetadata in project java-automl by googleapis.

the class ObjectDetectionDeployModelNodeCount method objectDetectionDeployModelNodeCount.

static void objectDetectionDeployModelNodeCount(String projectId, String modelId) throws IOException, ExecutionException, InterruptedException {
    // the "close" method on the client to safely clean up any remaining background resources.
    try (AutoMlClient client = AutoMlClient.create()) {
        // Get the full path of the model.
        ModelName modelFullId = ModelName.of(projectId, "us-central1", modelId);
        // Set how many nodes the model is deployed on
        ImageObjectDetectionModelDeploymentMetadata deploymentMetadata = ImageObjectDetectionModelDeploymentMetadata.newBuilder().setNodeCount(2).build();
        DeployModelRequest request = DeployModelRequest.newBuilder().setName(modelFullId.toString()).setImageObjectDetectionModelDeploymentMetadata(deploymentMetadata).build();
        // Deploy the model
        OperationFuture<Empty, OperationMetadata> future = client.deployModelAsync(request);
        future.get();
        System.out.println("Model deployment on 2 nodes finished");
    }
}
Also used : DeployModelRequest(com.google.cloud.automl.v1beta1.DeployModelRequest) Empty(com.google.protobuf.Empty) ModelName(com.google.cloud.automl.v1beta1.ModelName) ImageObjectDetectionModelDeploymentMetadata(com.google.cloud.automl.v1beta1.ImageObjectDetectionModelDeploymentMetadata) OperationMetadata(com.google.cloud.automl.v1beta1.OperationMetadata) AutoMlClient(com.google.cloud.automl.v1beta1.AutoMlClient)

Example 2 with ImageObjectDetectionModelDeploymentMetadata

use of com.google.cloud.automl.v1beta1.ImageObjectDetectionModelDeploymentMetadata in project java-automl by googleapis.

the class VisionObjectDetectionDeployModelNodeCount method visionObjectDetectionDeployModelNodeCount.

// Deploy a model for prediction with a specified node count (can be used to redeploy a model)
static void visionObjectDetectionDeployModelNodeCount(String projectId, String modelId) throws IOException, ExecutionException, InterruptedException {
    // the "close" method on the client to safely clean up any remaining background resources.
    try (AutoMlClient client = AutoMlClient.create()) {
        // Get the full path of the model.
        ModelName modelFullId = ModelName.of(projectId, "us-central1", modelId);
        ImageObjectDetectionModelDeploymentMetadata metadata = ImageObjectDetectionModelDeploymentMetadata.newBuilder().setNodeCount(2).build();
        DeployModelRequest request = DeployModelRequest.newBuilder().setName(modelFullId.toString()).setImageObjectDetectionModelDeploymentMetadata(metadata).build();
        OperationFuture<Empty, OperationMetadata> future = client.deployModelAsync(request);
        future.get();
        System.out.println("Model deployment finished");
    }
}
Also used : DeployModelRequest(com.google.cloud.automl.v1.DeployModelRequest) Empty(com.google.protobuf.Empty) ModelName(com.google.cloud.automl.v1.ModelName) ImageObjectDetectionModelDeploymentMetadata(com.google.cloud.automl.v1.ImageObjectDetectionModelDeploymentMetadata) OperationMetadata(com.google.cloud.automl.v1.OperationMetadata) AutoMlClient(com.google.cloud.automl.v1.AutoMlClient)

Aggregations

Empty (com.google.protobuf.Empty)2 AutoMlClient (com.google.cloud.automl.v1.AutoMlClient)1 DeployModelRequest (com.google.cloud.automl.v1.DeployModelRequest)1 ImageObjectDetectionModelDeploymentMetadata (com.google.cloud.automl.v1.ImageObjectDetectionModelDeploymentMetadata)1 ModelName (com.google.cloud.automl.v1.ModelName)1 OperationMetadata (com.google.cloud.automl.v1.OperationMetadata)1 AutoMlClient (com.google.cloud.automl.v1beta1.AutoMlClient)1 DeployModelRequest (com.google.cloud.automl.v1beta1.DeployModelRequest)1 ImageObjectDetectionModelDeploymentMetadata (com.google.cloud.automl.v1beta1.ImageObjectDetectionModelDeploymentMetadata)1 ModelName (com.google.cloud.automl.v1beta1.ModelName)1 OperationMetadata (com.google.cloud.automl.v1beta1.OperationMetadata)1