Managing models
A model is trained using a prepared dataset that you provide. AutoML Video Intelligence Object Tracking uses the items from the your dataset to train, test, and evaluate the model's performance. Next, you should 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 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 model is two years. You must create and train a new model to continue tracking objects after that amount of time.
Using curl or PowerShell
To make it more convenient to run the curl
(or PowerShell) samples in this
topic, set the following environment variable. Replace project-id with the name
of your Google Cloud 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 model.
Web UI
-
Open the AutoML Video Object Tracking UI and navigate to the Datasets page.
-
Select the dataset that you want to use to train the your model.
The display name of the selected dataset appears in the title bar, and the page lists the individual items in the dataset along with their labels.
-
When you are done reviewing the dataset, click the Train tab just below the title bar.
The training page provides a basic analysis of your dataset and advises you about whether it is adequate for training. If AutoML Video Object Tracking suggests changes, consider returning to the Videos page and adding items or labels.
- When the dataset is ready, click Start Training to create a new model or Train New Model if you want to create an additional model.
REST
Before using any of the request data, make the following replacements:
- dataset-id: the name of your target dataset.
For example,
my_dataset_01
display name). - model-name: replace with a name that you choose for your model.
- Note:
- project-number: number of your project
- location-id: the Cloud region where annotation
should take place. Supported cloud regions are:
us-east1
,us-west1
,europe-west1
,asia-east1
. If no region is specified, a region will be determined based on video file location.
HTTP method and URL:
POST https://automl.googleapis.com/v1beta1/projects/project-number/locations/location-id/models
Request JSON body:
{ "datasetId": "dataset-id", "displayName": "model-name", "videoObjectTrackingModelMetadata": {}, }
To send your request, choose one of these options:
curl
Save the request body in a file called request.json
,
and execute the following command:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "x-goog-user-project: project-number" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://automl.googleapis.com/v1beta1/projects/project-number/locations/location-id/models"
PowerShell
Save the request body in a file called request.json
,
and execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred"; "x-goog-user-project" = "project-number" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://automl.googleapis.com/v1beta1/projects/project-number/locations/location-id/models" | Select-Object -Expand Content
VOT1741767155885539328
.
Java
Node.js
Python
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.
REST
Before using any of the request data, make the following replacements:
- operation-id: the ID of the long-running operation created
for the request and provided in the response when you started the
operation, for example
VOT12345....
- Note:
- project-number: number of your project
- location-id: the Cloud region where annotation
should take place. Supported cloud regions are:
us-east1
,us-west1
,europe-west1
,asia-east1
. If no region is specified, a region will be determined based on video file location.
HTTP method and URL:
GET https://automl.googleapis.com/v1beta1/projects/project-number/locations/location-id/operations/operation-id
To send your request, choose one of these options:
curl
Execute the following command:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "x-goog-user-project: project-number" \
"https://automl.googleapis.com/v1beta1/projects/project-number/locations/location-id/operations/operation-id"
PowerShell
Execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred"; "x-goog-user-project" = "project-number" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://automl.googleapis.com/v1beta1/projects/project-number/locations/location-id/operations/operation-id" | Select-Object -Expand Content
done: true
with no errors listed, as shown in the example above.
- operation-name: the name of the operation as
returned by AutoML Video Intelligence Object Tracking API. The operation name has the format
projects/project-number/locations/location-id/operations/operation-id
Java
Node.js
Python
Cancel an Operation
You can cancel an import, training, or batch prediction task using the operation ID.
REST
Before using any of the request data, make the following replacements:
- operation id: provided in the response when you started the operation, for example VOT123....
- Note:
- project-id: your GCP project ID
- location-id: the Cloud region where annotation
should take place. Supported cloud regions are:
us-east1
,us-west1
,europe-west1
,asia-east1
. If no region is specified, a region will be determined based on video file location.
HTTP method and URL:
POST https://automl.googleapis.com/v1beta1/projects/project-id/locations/location-id/operations/operation-id:cancel
To send your request, expand one of these options:
You should receive a successful status code (2xx) and an empty response.
Java
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.
Web UI
-
Navigate to the Models page in the AutoML Video Object Tracking UI.
- Click the name of the model that you want to view.
REST
Before using any of the request data, make the following replacements:
- model-id:the ID of your model is from the response when you created the model.
The ID is the last element of the name of your model. For example:
- model name: projects/project-number/locations/location-id/models/model-id
- model id: model-id
- dataset-id: replace with the dataset identifier for your dataset
(not the display name). For example:
VOT3940649673949184000
- project-number: the number of your project
HTTP method and URL:
GET https://automl.googleapis.com/v1beta1/projects/project-id/locations/location-id/models/model-id
Request JSON body:
{ "displayName": "display-name", "dataset_id": "dataset-id", "videoClassificationModelMetadata": {} }
To send your request, expand one of these options:
You should receive a JSON response similar to the following:
Java
Node.js
Python
Listing models
A project can include numerous models. This section describes how to retrieve a list of the available models for a project.
Web UI
Navigate to the Models page in the AutoML Video Object Tracking UI to see the models in your project.
To see the models for a different project, select the project from the drop-down list in the upper right of the title bar.
REST
Before using any of the request data, make the following replacements:
- project-number: the number of your project
- location-id: the Cloud region where annotation should take
place. Supported cloud regions are:
us-east1
,us-west1
,europe-west1
,asia-east1
. If no region is specified, a region will be determined based on video file location.
HTTP method and URL:
GET https://automl.googleapis.com/v1beta1/projects/project-number/locations/location-id/models
To send your request, expand one of these options:
You should receive a JSON response similar to the following:
Java
Node.js
Python
Deleting a model
The following example deletes a model.
Web UI
-
Navigate to the Models page in the AutoML Video Object Tracking UI.
- Click the three-dot menu at the far right of the row you want to delete and select Delete.
- Click Confirm in the confirmation dialog box.
REST
Before using any of the request data, make the following replacements:
- project-number: the number of your project
- location-id: the Cloud region where annotation should take
place. Supported cloud regions are:
us-east1
,us-west1
,europe-west1
,asia-east1
. If no region is specified, a region will be determined based on video file location. - model-id: replace with the identifier for your model.
HTTP method and URL:
DELETE https://automl.googleapis.com/v1beta1/projects/project-number/locations/location-id/models/model-id
To send your request, expand one of these options:
You should receive a successful status code (2xx) and an empty response.
Java
Node.js
Python