use of com.google.cloud.automl.v1beta1.DeployModelRequest in project java-automl by googleapis.
the class ClassificationDeployModel method classificationDeployModel.
// Deploy a model
static void classificationDeployModel(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);
// Build deploy model request.
DeployModelRequest deployModelRequest = DeployModelRequest.newBuilder().setName(modelFullId.toString()).build();
// Deploy a model with the deploy model request.
OperationFuture<Empty, OperationMetadata> future = client.deployModelAsync(deployModelRequest);
future.get();
// Display the deployment details of model.
System.out.println("Model deployment finished");
}
}
use of com.google.cloud.automl.v1beta1.DeployModelRequest in project java-automl by googleapis.
the class VisionClassificationDeployModelNodeCount method visionClassificationDeployModelNodeCount.
// Deploy a model for prediction with a specified node count (can be used to redeploy a model)
static void visionClassificationDeployModelNodeCount(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);
ImageClassificationModelDeploymentMetadata metadata = ImageClassificationModelDeploymentMetadata.newBuilder().setNodeCount(2).build();
DeployModelRequest request = DeployModelRequest.newBuilder().setName(modelFullId.toString()).setImageClassificationModelDeploymentMetadata(metadata).build();
OperationFuture<Empty, OperationMetadata> future = client.deployModelAsync(request);
future.get();
System.out.println("Model deployment finished");
}
}
use of com.google.cloud.automl.v1beta1.DeployModelRequest in project java-automl by googleapis.
the class LanguageEntityExtractionPredictTest method setUp.
@Before
public void setUp() throws IOException, ExecutionException, InterruptedException {
// Verify that the model is deployed for prediction
try (AutoMlClient client = AutoMlClient.create()) {
ModelName modelFullId = ModelName.of(PROJECT_ID, "us-central1", MODEL_ID);
Model model = client.getModel(modelFullId);
if (model.getDeploymentState() == Model.DeploymentState.UNDEPLOYED) {
// Deploy the model if not deployed
DeployModelRequest request = DeployModelRequest.newBuilder().setName(modelFullId.toString()).build();
client.deployModelAsync(request).get();
}
}
bout = new ByteArrayOutputStream();
out = new PrintStream(bout);
originalPrintStream = System.out;
System.setOut(out);
}
use of com.google.cloud.automl.v1beta1.DeployModelRequest in project java-automl by googleapis.
the class LanguageTextClassificationPredictTest method setUp.
@Before
public void setUp() throws IOException, ExecutionException, InterruptedException {
// Verify that the model is deployed for prediction
try (AutoMlClient client = AutoMlClient.create()) {
ModelName modelFullId = ModelName.of(PROJECT_ID, "us-central1", MODEL_ID);
Model model = client.getModel(modelFullId);
if (model.getDeploymentState() == Model.DeploymentState.UNDEPLOYED) {
// Deploy the model if not deployed
DeployModelRequest request = DeployModelRequest.newBuilder().setName(modelFullId.toString()).build();
client.deployModelAsync(request).get();
}
}
bout = new ByteArrayOutputStream();
out = new PrintStream(bout);
originalPrintStream = System.out;
System.setOut(out);
}
use of com.google.cloud.automl.v1beta1.DeployModelRequest in project java-automl by googleapis.
the class VisionClassificationPredictTest method setUp.
@Before
public void setUp() throws IOException, ExecutionException, InterruptedException {
// Verify that the model is deployed for prediction
try (AutoMlClient client = AutoMlClient.create()) {
ModelName modelFullId = ModelName.of(PROJECT_ID, "us-central1", MODEL_ID);
Model model = client.getModel(modelFullId);
if (model.getDeploymentState() == Model.DeploymentState.UNDEPLOYED) {
// Deploy the model if not deployed
DeployModelRequest request = DeployModelRequest.newBuilder().setName(modelFullId.toString()).build();
client.deployModelAsync(request).get();
}
}
bout = new ByteArrayOutputStream();
out = new PrintStream(bout);
originalPrintStream = System.out;
System.setOut(out);
}
Aggregations