Managing models
A model is trained using a prepared dataset that you provide. AutoML Video Intelligence Classification 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 Classification creates a new model each time you start training, your project may 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 classifying content 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 are ready to create and train the model.
Web UI
-
Open the AutoML Video UI and navigate to the Datasets page.
-
Select the dataset that you want to use to train the 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 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 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/VCN3104518874390609379
, then the ID of your dataset isVCN3104518874390609379
. - 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:
{ "displayName": "test_model", "dataset_id": "dataset-id", "videoClassificationModelMetadata": {} }
To send your request, choose one of these options:
curl
Save the request body in a file named 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 named 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
{ "name": "projects/project-number/locations/location-id/operations/operation-id", "metadata": { "@type": "type.googleapis.com/google.cloud.automl.v1beta1.OperationMetadata", "progressPercentage": 100, "createTime": "2020-02-27T01:56:28.395640Z", "updateTime": "2020-02-27T02:04:12.336070Z" }, "done": true, "response": { "@type": "type.googleapis.com/google.cloud.automl.v1beta1.Model", "name": "projects/project-number/locations/location-id/models/operation-id", "createTime": "2020-02-27T02:00:22.329970Z", "videoClassificationModelMetadata": { "trainBudget": "1", "trainCost": "1", "stopReason": "BUDGET_REACHED" }, "displayName": "a_98487760535e48319dd204e6394670" } }
Java
To authenticate to AutoML Video, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Node.js
To authenticate to AutoML Video, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Python
To authenticate to AutoML Video, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
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 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-name: The full name of your model provided by the response when you created the model. The full name has the format: projects/project-number/locations/location-id/models/model-id
- dataset-id: replace with the dataset identifier for your dataset
(not the display name). For example:
VCN3940649673949184000
- project-number: the number of your project
HTTP method and URL:
GET https://automl.googleapis.com/v1beta1/model-name/modelEvaluations
Request JSON body:
{ "displayName": "test_model", "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
To authenticate to AutoML Video, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Node.js
To authenticate to AutoML Video, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Python
To authenticate to AutoML Video, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
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 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:
- model-name: The full name of your model provided by the response when you created the model. The full name has the format: projects/project-number/locations/location-id/models
- 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/models
To send your request, expand one of these options:
You should receive a JSON response similar to the following:
Java
To authenticate to AutoML Video, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Node.js
To authenticate to AutoML Video, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Python
To authenticate to AutoML Video, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Deleting a model
The following example deletes a model.
Web UI
- Navigate to the Models page in the AutoML Video 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:
- model-id: replace with the identifier 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:
DELETE https://automl.googleapis.com/v1beta1/projects/project-number/locations/test/models/model-id
To send your request, expand one of these options:
You should receive a JSON response similar to the following:
Java
To authenticate to AutoML Video, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Node.js
To authenticate to AutoML Video, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Python
To authenticate to AutoML Video, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.