Since AutoML Vision Object Detection 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, get a specific model, update a model's node number, or delete models you no longer need.
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
To see a list of the available models using the AutoML Vision Object Detection UI, click the Models link at the top of the left navigation menu.
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-id: your GCP project ID.
HTTP method and URL:
GET https://automl.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/models
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-id" \
"https://automl.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/models"
PowerShell
Execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred"; "x-goog-user-project" = "project-id" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://automl.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/models" | Select-Object -Expand Content
You should receive a JSON response similar to the following example. This response shows information about two Cloud-hosted models.
{ "model": [ { "name": "projects/PROJECT_ID/locations/us-central1/models/MODEL_ID_1", "displayName": "DISPLAY_NAME_1", "datasetId": "DATASET_ID", "createTime": "2019-07-26T21:10:18.338846Z", "deploymentState": "UNDEPLOYED", "updateTime": "2019-08-07T22:24:07.720068Z", "imageObjectDetectionModelMetadata": { "modelType": "cloud-low-latency-1", "nodeQps": 1.2987012987012987, "stopReason": "MODEL_CONVERGED", "trainBudgetMilliNodeHours": "216000", "trainCostMilliNodeHours": "8230" } }, { "name": "projects/PROJECT_ID/locations/us-central1/models/MODEL_ID_2", "displayName": "DISPLAY_NAME_2", "datasetId": "DATASET_ID", "createTime": "2019-07-22T18:35:06.881193Z", "deploymentState": "UNDEPLOYED", "updateTime": "2019-07-22T19:58:44.980357Z", "imageObjectDetectionModelMetadata": { "modelType": "mobile-versatile-1", "nodeQps": -1, "stopReason": "MODEL_CONVERGED", "trainBudgetMilliNodeHours": "24000", "trainCostMilliNodeHours": "9367" } }, { "name": "projects/PROJECT_ID/locations/us-central1/models/MODEL_ID_3", "displayName": "DISPLAY_NAME_3", "datasetId": "DATASET_ID", "createTime": "2019-03-31T22:56:51.348238Z", "deploymentState": "UNDEPLOYED", "updateTime": "2019-07-22T18:42:44.594876Z", "imageObjectDetectionModelMetadata": { "modelType": "cloud-high-accuracy-1", "nodeQps": 0.6872852233676976 } } ] }
Go
Before trying this sample, follow the setup instructions for this language on the Client Libraries page.
Java
Before trying this sample, follow the setup instructions for this language on the Client Libraries page.
Node.js
Before trying this sample, follow the setup instructions for this language on the Client Libraries page.
Python
Before trying this sample, follow the setup instructions for this language on the Client Libraries page.
Additional languages
C#: Please follow the C# setup instructions on the client libraries page and then visit the AutoML Vision Object Detection reference documentation for .NET.
PHP: Please follow the PHP setup instructions on the client libraries page and then visit the AutoML Vision Object Detection reference documentation for PHP.
Ruby: Please follow the Ruby setup instructions on the client libraries page and then visit the AutoML Vision Object Detection reference documentation for Ruby.
Get a model
You can get a specific trained model to modify or for prediction.
Web UI
To see a list of the available models using the AutoML Vision Object Detection UI, click the Models link at the top of the left navigation menu.
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-id: your GCP project ID.
- model-id: the ID of your model, 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-id/locations/location-id/models/IOD4412217016962778756
- model id:
IOD4412217016962778756
- model name:
HTTP method and URL:
GET https://automl.googleapis.com/v1/projects/project-id/locations/us-central1/models/model-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-id" \
"https://automl.googleapis.com/v1/projects/project-id/locations/us-central1/models/model-id"
PowerShell
Execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred"; "x-goog-user-project" = "project-id" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://automl.googleapis.com/v1/projects/project-id/locations/us-central1/models/model-id" | Select-Object -Expand Content
You should receive a JSON response similar to the following:
{ "name": "projects/PROJECT_ID/locations/us-central1/models/MODEL_ID", "displayName": "DISPLAY_NAME", "datasetId": "DATASET_ID", "createTime": "2019-07-26T21:10:18.338846Z", "deploymentState": "UNDEPLOYED", "updateTime": "2019-07-26T22:28:57.464076Z", "imageObjectDetectionModelMetadata": { "modelType": "cloud-low-latency-1", "nodeQps": 1.2987012987012987, "stopReason": "MODEL_CONVERGED", "trainBudgetMilliNodeHours": "216000", "trainCostMilliNodeHours": "8230" } }
Java
Before trying this sample, follow the setup instructions for this language on the Client Libraries page.
Node.js
Before trying this sample, follow the setup instructions for this language on the Client Libraries page.
Python
Before trying this sample, follow the setup instructions for this language on the Client Libraries page.
Additional languages
C#: Please follow the C# setup instructions on the client libraries page and then visit the AutoML Vision Object Detection reference documentation for .NET.
PHP: Please follow the PHP setup instructions on the client libraries page and then visit the AutoML Vision Object Detection reference documentation for PHP.
Ruby: Please follow the Ruby setup instructions on the client libraries page and then visit the AutoML Vision Object Detection reference documentation for Ruby.
Update a model's node number
Once you have a trained deployed model you can update the number of nodes the model is deployed on to respond to your specific amount of traffic. For example, if you experience a higher amount of queries per second (QPS) than expected.
You can change this node number without first having to undeploy the model. Updating deployment will change the node number without interrupting your served prediction traffic.
Web UI
In the AutoML Vision Object Detection UI and select the Models tab (with lightbulb icon) in the left navigation bar to display the available models.
To view the models for a different project, select the project from the drop-down list in the upper right of the title bar.
- Select your deployed trained model.
- Select the Test & Use tab just below the title bar.
-
A message is displayed in a box at the top of the page that says "Your model is deployed and is available for online prediction requests". Select the Update deployment option to the side of this text.
- In the Update deployment window that opens select the new node number
to deploy your model on from the list. Node numbers display their estimated
prediction queries per second (QPS).
After selecting a new node number from the list select Update deployment to update the node number the model is deployed on.
- You will be returned to the Test & Use window where you see the text
box now displaying "Deploying model...".
After your model has successfully deployed on the new node number you will receive an email at the address associated with your project.
REST
The same method you use to initially use to deploy a model is used to change the deployed model's node number.Before using any of the request data, make the following replacements:
- project-id: your GCP project ID.
- model-id: the ID of your model, 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-id/locations/location-id/models/IOD4412217016962778756
- model id:
IOD4412217016962778756
- model name:
Field considerations:
nodeCount
- The number of nodes to deploy the model on. The value must be between 1 and 100, inclusive on both ends. A node is an abstraction of a machine resource, which can handle online prediction queries per second (QPS) as given in the model'sqps_per_node
.
HTTP method and URL:
POST https://automl.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/models/MODEL_ID:deploy
Request JSON body:
{ "imageObjectDetectionModelDeploymentMetadata": { "nodeCount": 2 } }
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-id" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://automl.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/models/MODEL_ID:deploy"
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-id" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://automl.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/models/MODEL_ID:deploy" | Select-Object -Expand Content
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 Working with long-running operations.
{ "name": "projects/PROJECT_ID/locations/us-central1/operations/OPERATION_ID", "metadata": { "@type": "type.googleapis.com/google.cloud.automl.v1.OperationMetadata", "createTime": "2019-08-07T22:00:20.692109Z", "updateTime": "2019-08-07T22:00:20.692109Z", "deployModelDetails": {} } }
Go
Before trying this sample, follow the setup instructions for this language on the Client Libraries page.
Java
Before trying this sample, follow the setup instructions for this language on the Client Libraries page.
Node.js
Before trying this sample, follow the setup instructions for this language on the Client Libraries page.
Python
Before trying this sample, follow the setup instructions for this language on the Client Libraries page.
Additional languages
C#: Please follow the C# setup instructions on the client libraries page and then visit the AutoML Vision Object Detection reference documentation for .NET.
PHP: Please follow the PHP setup instructions on the client libraries page and then visit the AutoML Vision Object Detection reference documentation for PHP.
Ruby: Please follow the Ruby setup instructions on the client libraries page and then visit the AutoML Vision Object Detection reference documentation for Ruby.
Deleting a model
You can delete a model resource by using the model ID.
Web UI
In the AutoML Vision Object Detection UI, click the lightbulb icon in the left navigation menu to display the list of available models.
Click the three-dot menu at the far right of the row you want to delete and select Delete model.
Click Delete in the confirmation dialog box.
REST
Before using any of the request data, make the following replacements:
- project-id: your GCP project ID.
- model-id: the ID of your model, 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-id/locations/location-id/models/IOD4412217016962778756
- model id:
IOD4412217016962778756
- model name:
HTTP method and URL:
DELETE https://automl.googleapis.com/v1/projects/PROJECT_ID/locations/us- central1/models/MODEL_ID
To send your request, choose one of these options:
curl
Execute the following command:
curl -X DELETE \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "x-goog-user-project: project-id" \
"https://automl.googleapis.com/v1/projects/PROJECT_ID/locations/us- central1/models/MODEL_ID"
PowerShell
Execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred"; "x-goog-user-project" = "project-id" }
Invoke-WebRequest `
-Method DELETE `
-Headers $headers `
-Uri "https://automl.googleapis.com/v1/projects/PROJECT_ID/locations/us- central1/models/MODEL_ID" | Select-Object -Expand Content
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 Working with long-running operations.
{ "name": "projects/PROJECT_ID/locations/us-central1/operations/OPERATION_ID", "metadata": { "@type": "type.googleapis.com/google.cloud.automl.v1.OperationMetadata", "createTime": "2018-11-01T15:59:36.196506Z", "updateTime": "2018-11-01T15:59:36.196506Z", "deleteDetails": {} } }
Go
Before trying this sample, follow the setup instructions for this language on the Client Libraries page.
Java
Before trying this sample, follow the setup instructions for this language on the Client Libraries page.
Node.js
Before trying this sample, follow the setup instructions for this language on the Client Libraries page.
Python
Before trying this sample, follow the setup instructions for this language on the Client Libraries page.
Additional languages
C#: Please follow the C# setup instructions on the client libraries page and then visit the AutoML Vision Object Detection reference documentation for .NET.
PHP: Please follow the PHP setup instructions on the client libraries page and then visit the AutoML Vision Object Detection reference documentation for PHP.
Ruby: Please follow the Ruby setup instructions on the client libraries page and then visit the AutoML Vision Object Detection reference documentation for Ruby.