Managing models

You create a custom model by training it using a prepared dataset. Cloud AutoML Video Intelligence Object Tracking uses the items from the dataset to train the model, test it, and evaluate its performance. You review the results, adjust the training dataset as needed, and train a new model using the improved dataset.

Training a model can take several hours to complete. The AutoML API enables you to check the status of training.

Since Cloud AutoML Video Intelligence Object Tracking creates a new model each time you start training, your project can include numerous models. You can get a list of the models in your project and can delete models you no longer need.

The maximum lifespan for a custom model is two years. You must create and train a new model to continue tracking objects after that amount of time.

Using curl

To make it more convenient to run the curl samples in this topic, set the following environment variable. Replace project-id with the name of your GCP project.

export PROJECT_ID="project-id"

Training models

When you have a dataset with a solid set of labeled training items, you can create and train the custom model.

Command-line

  • Replace dataset-id with the ID of your dataset. The ID is the last element of the name of your dataset. For example, if the name of your dataset is projects/434039606874/locations/us-central1/datasets/VOT6312181905852727296, then the ID of your dataset is VOT6312181905852727296.
curl -X POST \
  -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
  -H "Content-Type: application/json" \
  https://automl.googleapis.com/v1beta1/projects/${PROJECT_ID}/locations/us-central1/models \
  -d '{
    "displayName": "test_model",
    "dataset_id": "dataset-id",
    "videoObjectTrackingModelMetadata": {},
  }'

You should see output similar to the following. You can use the operation ID to get the status of the task. For an example, see Getting the status of an operation.

{
  "name": "projects/434039606874/locations/us-central1/operations/VOT7938913757193830400",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.automl.v1beta1.OperationMetadata",
    "createTime": "2019-01-10T00:32:11.930145Z",
    "updateTime": "2019-01-10T00:32:11.930145Z",
    "createModelDetails": {
      "modelDisplayName": "test_model_01"
    },
  }
}

Java

/*
 * Please include the following imports to run this sample.
 *
 * import com.google.api.gax.longrunning.OperationFuture;
 * import com.google.cloud.automl.v1beta1.AutoMlClient;
 * import com.google.cloud.automl.v1beta1.CreateModelRequest;
 * import com.google.cloud.automl.v1beta1.LocationName;
 * import com.google.cloud.automl.v1beta1.Model;
 * import com.google.cloud.automl.v1beta1.OperationMetadata;
 * import com.google.cloud.automl.v1beta1.VideoObjectTrackingModelMetadata;
 */

/**
 * Create a model
 *
 * @param displayName The name of the model to show in the interface. The name can be up to 32
 *     characters long and can consist only of ASCII Latin letters A-Z and a-z, underscores (_),
 *     and ASCII digits 0-9. Must be unique within the scope of the provided GCP Project and
 *     Location.
 * @param datasetId Required. The resource ID of the dataset used to create the model. The dataset
 *     must come from the same ancestor project and location.
 * @param project Required. Your Google Cloud Project ID.
 */
public static void sampleCreateModel(String displayName, String datasetId, String project) {
  try (AutoMlClient autoMlClient = AutoMlClient.create()) {
    // displayName = "My_Model_Name_123";
    // datasetId = "[Dataset ID]";
    // project = "[Google Cloud Project ID]";
    LocationName parent = LocationName.of(project, "us-central1");

    // Initialized video_object_tracking_model_metadata field must be provided.
    // This specifies this Dataset is to be used for video object tracking.
    VideoObjectTrackingModelMetadata videoObjectTrackingModelMetadata =
        VideoObjectTrackingModelMetadata.newBuilder().build();
    Model model =
        Model.newBuilder()
            .setDisplayName(displayName)
            .setDatasetId(datasetId)
            .setVideoObjectTrackingModelMetadata(videoObjectTrackingModelMetadata)
            .build();
    CreateModelRequest request =
        CreateModelRequest.newBuilder().setParent(parent.toString()).setModel(model).build();
    OperationFuture<Model, OperationMetadata> operation =
        autoMlClient.createModelOperationCallable().futureCall(request);

    // The long-running operation has started.

    // Store the operation name to poll for operation status:
    String operationName = operation.getName();
    System.out.printf("Started long-running operation: %s", operationName);
  } catch (Exception exception) {
    System.err.println("Failed to create the client due to: " + exception);
  }
}

Node.js


const automl = require('@google-cloud/automl').v1beta1;

/**
 * Create a model
 *
 * @param displayName {string} The name of the model to show in the interface.
 * The name can be up to 32 characters long and can consist only of
 * ASCII Latin letters A-Z and a-z, underscores (_), and ASCII digits 0-9.
 * Must be unique within the scope of the provided GCP Project and Location.
 * @param datasetId {string} Required. The resource ID of the dataset used to create the model.
 * The dataset must come from the same ancestor project and location.
 * @param project {string} Required. Your Google Cloud Project ID.
 */
async function sampleCreateModel(displayName, datasetId, project) {
  const client = new automl.AutoMlClient();
  // const displayName = 'My_Model_Name_123';
  // const datasetId = '[Dataset ID]';
  // const project = '[Google Cloud Project ID]';
  const formattedParent = client.locationPath(project, 'us-central1');

  // Initialized video_object_tracking_model_metadata field must be provided.
  // This specifies this Dataset is to be used for video object tracking.
  const videoObjectTrackingModelMetadata = {};
  const model = {
    displayName: displayName,
    datasetId: datasetId,
    videoObjectTrackingModelMetadata: videoObjectTrackingModelMetadata,
  };
  const request = {
    parent: formattedParent,
    model: model,
  };
  const [operation] = await client.createModel(request);

  // The long-running operation has started.

  // Store the operation name to poll for operation status:
  const name = operation.latestResponse.name;
  console.log(`Started long-running operation: ${name}`);
}

Python


from google.cloud import automl_v1beta1


def sample_create_model(display_name, dataset_id, project):
    """
    Create a model

    Args:
      display_name The name of the model to show in the interface.
      The name can be up to 32 characters long and can consist only of
      ASCII Latin letters A-Z and a-z, underscores (_), and ASCII digits 0-9.
      Must be unique within the scope of the provided GCP Project and Location.
      dataset_id Required. The resource ID of the dataset used to create the model.
      The dataset must come from the same ancestor project and location.
      project Required. Your Google Cloud Project ID.
    """

    client = automl_v1beta1.AutoMlClient()

    # display_name = 'My_Model_Name_123'
    # dataset_id = '[Dataset ID]'
    # project = '[Google Cloud Project ID]'
    parent = client.location_path(project, "us-central1")

    # Initialized video_object_tracking_model_metadata field must be provided.
    # This specifies this Dataset is to be used for video object tracking.
    video_object_tracking_model_metadata = {}
    model = {
        "display_name": display_name,
        "dataset_id": dataset_id,
        "video_object_tracking_model_metadata": video_object_tracking_model_metadata,
    }

    operation = client.create_model(parent, model).operation

    # The long-running operation to create model has started.
    # Store the operation name for operation status polling
    print(u"Started long-running operation: {}".format(operation.name))

Getting the status of an operation

You can check the status of a long-running task like importing items into a dataset or training a model using the operation ID from the response when you started the task.

Command-line

In the command below, replace operation-name with the full name of your operation. The full name has the format projects/{project-id}/locations/us-central1/operations/{operation-id}.

curl -X GET \
  -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
  -H "Content-Type: application/json" \
  https://automl.googleapis.com/v1beta1/operation-id

You should see output similar to the following for an import operation:

{
  "name": "projects/170799619488/locations/us-central1/operations/VOT2066219843102703616",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.automl.v1beta1.OperationMetadata",
    "createTime": "2019-01-09T23:47:07.030018Z",
    "updateTime": "2019-01-09T23:49:22.229599Z",
    "importDataDetails": {}
  },
  "done": true,
  "response": {
    "@type": "type.googleapis.com/google.protobuf.Empty"
  }
}
You should see output similar to the following for a create model operation:
{
  "name": "projects/434039606874/locations/us-central1/operations/VOT7938913757193830400",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.automl.v1beta1.OperationMetadata",
    "createTime": "2019-01-10T00:32:11.930145Z",
    "updateTime": "2019-01-10T00:32:11.930145Z",
    "createModelDetails": {
      "modelDisplayName": "test_model_01"
    },
  }
}

Java


/**
 * Get Long-Running Operation Status
 *
 * @param operationId Required. The ID of the operation.
 * @param project Required. Your Google Cloud Project ID.
 */
public static void sampleGetOperation(String project, String operationId) {
  try (AutoMlClient client = AutoMlClient.create()) {

    OperationsClient operationsClient = client.getOperationsClient();

    // project = '[Google Cloud Project ID]'
    // operation_id = '[Operation ID]'
    String name = String.format("projects/%s/locations/us-central1/operations/%s",
            project, operationId);

    Operation operation = operationsClient.getOperation(name);

    // Print Operation status and info
    System.out.printf("Operation Name: %s", (operation.getName()));
    System.out.printf("Done: %s", (operation.getDone()));
    System.out.printf("Response: %s",(operation.getResponse()));
    System.out.printf("Metadata: %s", (operation.getMetadata()));

  } catch (Exception exception) {
    System.err.println("Failed to create the client due to: " + exception);
  }
}

Python


from google.cloud import automl_v1beta1


def sample_get_operation(project, operation_id):
    """
    Get Long-Running Operation Status

    Args:
      project Required. Your Google Cloud Project ID.
      operation_id Required. The ID of the Operation.
    """

    client = automl_v1beta1.AutoMlClient()

    operations_client = client.transport._operations_client

    # project = '[Google Cloud Project ID]'
    # operation_id = '[Operation ID]'
    name = "projects/{}/locations/us-central1/operations/{}".format(
        project, operation_id
    )

    operation = operations_client.get_operation(name)

    # Print Operation status and info
    print(u"Operation Name: {}".format(operation.name))
    print(u"Done: {}".format(operation.done))
    print(u"Response: {}".format(operation.response))
    print(u"Metadata: {}".format(operation.metadata))

Cancelling an Operation

You can cancel an import, training, or batch prediction task using the operation ID.

Command-line

In the command below, replace operation-name with the full name of your operation. The full name has the format projects/{project-id}/locations/us-central1/operations/{operation-id}.

curl -X POST "Content-Type: application/json" \
  -H "Authorization: Bearer `gcloud auth application-default print-access-token`" \
  https://automl.googleapis.com/v1beta1/operation-name:cancel"

Java


/**
 * Cancel Long-Running Operation
 *
 * @param operationId Required. The ID of the operation.
 * @param project Required. Your Google Cloud Project ID.
 */
public static void sampleCancelOperation(String project, String operationId) {
  try (AutoMlClient client = AutoMlClient.create()) {

    OperationsClient operationsClient = client.getOperationsClient();

    // project = '[Google Cloud Project ID]'
    // operation_id = '[Operation ID]'
    String name = String.format("projects/%s/locations/us-central1/operations/%s",
            project, operationId);
    operationsClient.cancelOperation(name);

    System.out.printf("Cancelled operation: %s", name);
  } catch (Exception exception) {
    System.err.println("Failed to create the client due to: " + exception);
  }
}

Python


from google.cloud import automl_v1beta1


def sample_cancel_operation(project, operation_id):
    """
    Cancel Long-Running Operation

    Args:
      project Required. Your Google Cloud Project ID.
      operation_id Required. The ID of the Operation.
    """

    client = automl_v1beta1.AutoMlClient()

    operations_client = client.transport._operations_client

    # project = '[Google Cloud Project ID]'
    # operation_id = '[Operation ID]'
    name = "projects/{}/locations/us-central1/operations/{}".format(
        project, operation_id
    )

    operations_client.cancel_operation(name)

    print(u"Cancelled operation: {}".format(name))

Getting information about a model

When training is complete, you can get information about the newly created model.

The examples in this section return the basic metadata about a model. To get details about a model's accuracy and readiness, see Evaluating models.

Command-line

* Replace model-name with the full name of your model, from the response when you created the model. The full name has the format: projects/{project-id}/locations/us-central1/models/{model-id}
curl -X GET \
  -H "Authorization: Bearer $(gcloud auth application-default print-access-token)"
  -H "Content-Type: application/json" \
  https://automl.googleapis.com/v1beta1/model-name

You should see output similar to the following:

{
  "name": "projects/170799619488/locations/us-central1/models/VOT5199300216682971136",
  "displayName": "test_model_tiny",
  "datasetId": "VOT7851287078506594304",
  "createTime": "2019-01-11T02:23:46.620582Z",
  "updateTime": "2019-01-11T02:23:46.620582Z",
  "videoObjectTrackingModelMetadata": {}
}

Java

/*
 * Please include the following imports to run this sample.
 *
 * import com.google.cloud.automl.v1beta1.AutoMlClient;
 * import com.google.cloud.automl.v1beta1.GetModelRequest;
 * import com.google.cloud.automl.v1beta1.Model;
 * import com.google.cloud.automl.v1beta1.ModelName;
 */

/**
 * Get model and print model details
 *
 * @param modelId Model ID, e.g. VOT1234567890123456789
 * @param project Required. Your Google Cloud Project ID.
 */
public static void sampleGetModel(String modelId, String project) {
  try (AutoMlClient autoMlClient = AutoMlClient.create()) {
    // modelId = "[Model ID]";
    // project = "[Google Cloud Project ID]";
    ModelName name = ModelName.of(project, "us-central1", modelId);
    GetModelRequest request = GetModelRequest.newBuilder().setName(name.toString()).build();
    Model response = autoMlClient.getModel(request);
    Model model = response;
    // Print out the full name of the created model.
    //
    // This will have the format:
    //   projects/[Google Cloud Project Number]/locations/us-central1/models/VOT1234567890123456789
    //
    // The Model ID is the generated identifer in this path, e.g. VOT1234567890123456789
    // You will need this ID to perform operations on the model including predictions.
    //
    System.out.printf("Model name: %s\n", model.getName());
    // Print out the Display Name (the text you provided during creation)
    System.out.printf("Display name: %s\n", model.getDisplayName());
    // Print out the ID of the dataset used to create this model.
    //
    // Note: this is the Dataset ID, e.g. VOT1234567890123456789
    //
    System.out.printf("Dataset ID: %s\n", model.getDatasetId());
    System.out.printf("Create time: %s\n", model.getCreateTime());
    System.out.printf("Update time: %s\n", model.getUpdateTime());
  } catch (Exception exception) {
    System.err.println("Failed to create the client due to: " + exception);
  }
}

Node.js


const automl = require('@google-cloud/automl').v1beta1;

/**
 * Get model and print model details
 *
 * @param modelId {string} Model ID, e.g. VOT1234567890123456789
 * @param project {string} Required. Your Google Cloud Project ID.
 */
function sampleGetModel(modelId, project) {
  const client = new automl.AutoMlClient();
  // const modelId = '[Model ID]';
  // const project = '[Google Cloud Project ID]';
  const formattedName = client.modelPath(project, 'us-central1', modelId);
  client
    .getModel({name: formattedName})
    .then(responses => {
      const response = responses[0];
      const model = response;
      // Print out the full name of the created model.
      //
      // This will have the format:
      //   projects/[Google Cloud Project Number]/locations/us-central1/models/VOT1234567890123456789
      //
      // The Model ID is the generated identifer in this path, e.g. VOT1234567890123456789
      // You will need this ID to perform operations on the model including predictions.
      //
      console.log(`Model name: ${model.name}`);
      // Print out the Display Name (the text you provided during creation)
      console.log(`Display name: ${model.displayName}`);
      // Print out the ID of the dataset used to create this model.
      //
      // Note: this is the Dataset ID, e.g. VOT1234567890123456789
      //
      console.log(`Dataset ID: ${model.datasetId}`);
      console.log(`Create time: ${model.createTime}`);
      console.log(`Update time: ${model.updateTime}`);
    })
    .catch(err => {
      console.error(err);
    });
}

Python


from google.cloud import automl_v1beta1


def sample_get_model(model_id, project):
    """
    Get model and print model details

    Args:
      model_id Model ID, e.g. VOT1234567890123456789
      project Required. Your Google Cloud Project ID.
    """

    client = automl_v1beta1.AutoMlClient()

    # model_id = '[Model ID]'
    # project = '[Google Cloud Project ID]'
    name = client.model_path(project, "us-central1", model_id)

    response = client.get_model(name)
    model = response
    # Print out the full name of the created model.
    #
    # This will have the format:
    #   projects/[Google Cloud Project Number]/locations/us-central1/models/VOT1234567890123456789
    #
    # The Model ID is the generated identifer in this path, e.g. VOT1234567890123456789
    # You will need this ID to perform operations on the model including predictions.
    #
    print(u"Model name: {}".format(model.name))
    # Print out the Display Name (the text you provided during creation)
    print(u"Display name: {}".format(model.display_name))
    # Print out the ID of the dataset used to create this model.
    #
    # Note: this is the Dataset ID, e.g. VOT1234567890123456789
    #
    print(u"Dataset ID: {}".format(model.dataset_id))
    print(u"Create time: {}".format(model.create_time))
    print(u"Update time: {}".format(model.update_time))

Listing models

A project can include numerous models. This section describes how to retrieve a list of the available models for a project.

Command-line

curl -X GET \
  -H "Authorization: Bearer $(gcloud auth application-default  \
print-access-token)" \
  -H "Content-Type: application/json" \
https://automl.googleapis.com/v1beta1/projects/${PROJECT_ID}/locations/us-central1/models

You should see output similar to the following:

{
  "model": [
    {
      "name": "projects/170799619488/locations/us-central1/models/VOT5199300216682971136",
      "displayName": "test_model_tiny",
      "datasetId": "VOT7851287078506594304",
      "createTime": "2019-01-11T02:23:46.620582Z",
      "updateTime": "2019-01-11T02:23:46.620582Z",
      "videoObjectTrackingModelMetadata": {}
    }
  ]
}

Java

/*
 * Please include the following imports to run this sample.
 *
 * import com.google.cloud.automl.v1beta1.AutoMlClient;
 * import com.google.cloud.automl.v1beta1.ListModelsRequest;
 * import com.google.cloud.automl.v1beta1.LocationName;
 * import com.google.cloud.automl.v1beta1.Model;
 */

/**
 * List models and print details of each dataset
 *
 * @param filter An expression for filtering the results of the request. This filters for Models
 *     which have video_object_tracking_model_metadata.
 * @param project Required. Your Google Cloud Project ID.
 */
public static void sampleListModels(String filter, String project) {
  try (AutoMlClient autoMlClient = AutoMlClient.create()) {
    // filter = "video_object_tracking_model_metadata:*";
    // project = "[Google Cloud Project ID]";
    LocationName parent = LocationName.of(project, "us-central1");
    ListModelsRequest request =
        ListModelsRequest.newBuilder().setParent(parent.toString()).setFilter(filter).build();
    for (Model responseItem : autoMlClient.listModels(request).iterateAll()) {
      Model model = responseItem;
      // Print out the full name of the created model.
      //
      // This will have the format:
      //   projects/[Google Cloud Project Number]/locations/us-central1/models/VOT1234567890123456789
      //
      // The Model ID is the generated identifer in this path, e.g. VOT1234567890123456789
      // You will need this ID to perform operations on the model including predictions.
      //
      System.out.printf("Model name: %s\n", model.getName());
      // Print out the Display Name (the text you provided during creation)
      System.out.printf("Display name: %s\n", model.getDisplayName());
      // Print out the ID of the dataset used to create this model.
      //
      // Note: this is the Dataset ID, e.g. VOT1234567890123456789
      //
      System.out.printf("Dataset ID: %s\n", model.getDatasetId());
      System.out.printf("Create time: %s\n", model.getCreateTime());
      System.out.printf("Update time: %s\n", model.getUpdateTime());
    }
  } catch (Exception exception) {
    System.err.println("Failed to create the client due to: " + exception);
  }
}

Node.js


const automl = require('@google-cloud/automl').v1beta1;

/**
 * List models and print details of each dataset
 *
 * @param filter {string} An expression for filtering the results of the request.
 * This filters for Models which have video_object_tracking_model_metadata.
 * @param project {string} Required. Your Google Cloud Project ID.
 */
function sampleListModels(filter, project) {
  const client = new automl.AutoMlClient();
  // Iterate over all elements.
  // const filter = 'video_object_tracking_model_metadata:*';
  // const project = '[Google Cloud Project ID]';
  const formattedParent = client.locationPath(project, 'us-central1');
  const request = {
    parent: formattedParent,
    filter: filter,
  };

  client
    .listModels(request)
    .then(responses => {
      const resources = responses[0];
      for (const resource of resources) {
        const model = resource;
        // Print out the full name of the created model.
        //
        // This will have the format:
        //   projects/[Google Cloud Project Number]/locations/us-central1/models/VOT1234567890123456789
        //
        // The Model ID is the generated identifer in this path, e.g. VOT1234567890123456789
        // You will need this ID to perform operations on the model including predictions.
        //
        console.log(`Model name: ${model.name}`);
        // Print out the Display Name (the text you provided during creation)
        console.log(`Display name: ${model.displayName}`);
        // Print out the ID of the dataset used to create this model.
        //
        // Note: this is the Dataset ID, e.g. VOT1234567890123456789
        //
        console.log(`Dataset ID: ${model.datasetId}`);
        console.log(`Create time: ${model.createTime}`);
        console.log(`Update time: ${model.updateTime}`);
      }
    })
    .catch(err => {
      console.error(err);
    });
}

Python


from google.cloud import automl_v1beta1


def sample_list_models(filter_, project):
    """
    List models and print details of each dataset

    Args:
      filter_ An expression for filtering the results of the request.
      This filters for Models which have video_object_tracking_model_metadata.
      project Required. Your Google Cloud Project ID.
    """

    client = automl_v1beta1.AutoMlClient()

    # filter_ = 'video_object_tracking_model_metadata:*'
    # project = '[Google Cloud Project ID]'
    parent = client.location_path(project, "us-central1")

    # Iterate over all results
    for response_item in client.list_models(parent, filter_=filter_):
        model = response_item
        # Print out the full name of the created model.
        #
        # This will have the format:
        #   projects/[Google Cloud Project Number]/locations/us-central1/models/VOT1234567890123456789
        #
        # The Model ID is the generated identifer in this path, e.g. VOT1234567890123456789
        # You will need this ID to perform operations on the model including predictions.
        #
        print(u"Model name: {}".format(model.name))
        # Print out the Display Name (the text you provided during creation)
        print(u"Display name: {}".format(model.display_name))
        # Print out the ID of the dataset used to create this model.
        #
        # Note: this is the Dataset ID, e.g. VOT1234567890123456789
        #
        print(u"Dataset ID: {}".format(model.dataset_id))
        print(u"Create time: {}".format(model.create_time))
        print(u"Update time: {}".format(model.update_time))

Deleting a model

The following example deletes a model.

Command-line

  • Replace model-name with the full name of your model, from the response when you created the model. The full name has the format: projects/{project-id}/locations/us-central1/models/{model-id}
curl -X DELETE \
  -H "Authorization: Bearer $(gcloud auth application-default  \
print-access-token)" \
  -H "Content-Type: application/json" \
https://automl.googleapis.com/v1beta1/model-name

You should see output similar to the following. You can use the operation ID to get the status of the delete operation. For an example, see Getting the Status of an Operation.

{
  "name": "projects/965859579216/locations/us-central1/operations/VOT8561378076003401728",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.automl.v1beta1.OperationMetadata",
    "createTime": "2019-01-11T21:47:11.938851Z",
    "updateTime": "2019-01-11T21:47:11.938851Z",
    "deleteDetails": {},
  },
  "done": true,
  "response": {
    "@type": "type.googleapis.com/google.protobuf.Empty"
  }
}

Java

/*
 * Please include the following imports to run this sample.
 *
 * import com.google.cloud.automl.v1beta1.AutoMlClient;
 * import com.google.cloud.automl.v1beta1.DeleteModelRequest;
 * import com.google.cloud.automl.v1beta1.ModelName;
 * import com.google.protobuf.Empty;
 */

/**
 * Delete Model
 *
 * @param modelId Model ID, e.g. VOT1234567890123456789
 * @param project Required. Your Google Cloud Project ID.
 */
public static void sampleDeleteModel(String modelId, String project) {
  try (AutoMlClient autoMlClient = AutoMlClient.create()) {
    // modelId = "[Model ID]";
    // project = "[Google Cloud Project ID]";
    ModelName name = ModelName.of(project, "us-central1", modelId);
    DeleteModelRequest request = DeleteModelRequest.newBuilder().setName(name.toString()).build();
    autoMlClient.deleteModelAsync(request).get();
    System.out.println("Deleted Model.");
  } catch (Exception exception) {
    System.err.println("Failed to create the client due to: " + exception);
  }
}

Node.js


const automl = require('@google-cloud/automl').v1beta1;

/**
 * Delete Model
 *
 * @param modelId {string} Model ID, e.g. VOT1234567890123456789
 * @param project {string} Required. Your Google Cloud Project ID.
 */
async function sampleDeleteModel(modelId, project) {
  const client = new automl.AutoMlClient();
  // const modelId = '[Model ID]';
  // const project = '[Google Cloud Project ID]';
  const formattedName = client.modelPath(project, 'us-central1', modelId);

  // Create a job whose results you can either wait for now, or get later
  const [operation] = await client.deleteModel({name: formattedName});

  // Get a Promise representation of the final result of the job
  const [response] = await operation.promise();

  console.log(`Deleted Model.`);
}

Python


from google.cloud import automl_v1beta1


def sample_delete_model(model_id, project):
    """
    Delete Model

    Args:
      model_id Model ID, e.g. VOT1234567890123456789
      project Required. Your Google Cloud Project ID.
    """

    client = automl_v1beta1.AutoMlClient()

    # model_id = '[Model ID]'
    # project = '[Google Cloud Project ID]'
    name = client.model_path(project, "us-central1", model_id)

    operation = client.delete_model(name)

    print(u"Waiting for operation to complete...")
    response = operation.result()

    print(u"Deleted Model.")

Was this page helpful? Let us know how we did:

Send feedback about...

AutoML Video Intelligence Object Tracking Documentation