Train an AutoML Edge model using the Vertex AI API

You create an AutoML model directly in the Google Cloud console, or by creating a training pipeline programmatically, using the API or one of the Vertex AI client libraries.

This model is created using a prepared dataset provided by you using the console or the API. The Vertex AI API uses the items from the dataset to train the model, test it, and evaluate model performance. Review the evaluations results, adjust the training dataset as needed, and create a new training pipeline using the improved dataset.

Model training can take several hours to complete. The Vertex AI API enables you to get the status of training.

Create an AutoML Edge training pipeline

When you have a dataset with a representative set of training items, you are ready to create an AutoML Edge training pipeline.

Select a data type.

Image

Select the tab below for your objective:

Classification

At training time you can choose the type of AutoML Edge model you want, depending on your specific use case:

  • low latency (MOBILE_TF_LOW_LATENCY_1)
  • general purpose usage (MOBILE_TF_VERSATILE_1)
  • higher prediction quality (MOBILE_TF_HIGH_ACCURACY_1)

Select the tab below for your language or environment:

REST

Before using any of the request data, make the following replacements:

  • LOCATION: Region where dataset is located and Model is created. For example, us-central1.
  • PROJECT: Your project ID.
  • TRAININGPIPELINE_DISPLAYNAME: Required. A display name for the trainingPipeline.
  • DATASET_ID: The ID number for the dataset to use for training.
  • fractionSplit: Optional. One of several possible ML use split options for your data. For fractionSplit, values must sum to 1. For example:
    • {"trainingFraction": "0.7","validationFraction": "0.15","testFraction": "0.15"}
  • MODEL_DISPLAYNAME*: A display name for the model uploaded (created) by the TrainingPipeline.
  • MODEL_DESCRIPTION*: A description for the model.
  • modelToUpload.labels*: Any set of key-value pairs to organize your models. For example:
    • "env": "prod"
    • "tier": "backend"
  • EDGE_MODELTYPE: The type of Edge model to train. The options are:
    • MOBILE_TF_LOW_LATENCY_1
    • MOBILE_TF_VERSATILE_1
    • MOBILE_TF_HIGH_ACCURACY_1
  • NODE_HOUR_BUDGET: The actual training cost will be equal or less than this value. For Edge models the budget must be: 1,000 - 100,000 milli node hours (inclusive).
  • PROJECT_NUMBER: Project number for your project

HTTP method and URL:

POST http://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT/locations/LOCATION/trainingPipelines

Request JSON body:

{
  "displayName": "TRAININGPIPELINE_DISPLAYNAME",
  "inputDataConfig": {
    "datasetId": "DATASET_ID",
    "fractionSplit": {
      "trainingFraction": "DECIMAL",
      "validationFraction": "DECIMAL",
      "testFraction": "DECIMAL"
    }
  },
  "modelToUpload": {
    "displayName": "MODEL_DISPLAYNAME",
    "description": "MODEL_DESCRIPTION",
    "labels": {
      "KEY": "VALUE"
    }
  },
  "trainingTaskDefinition": "gs://google-cloud-aiplatform/schema/trainingjob/definition/automl_image_classification_1.0.0.yaml",
  "trainingTaskInputs": {
    "multiLabel": "false",
    "modelType": ["EDGE_MODELTYPE"],
    "budgetMilliNodeHours": NODE_HOUR_BUDGET
  }
}

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 "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"http://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT/locations/LOCATION/trainingPipelines"

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" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "http://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT/locations/LOCATION/trainingPipelines" | Select-Object -Expand Content

The response contains information about specifications as well as the TRAININGPIPELINE_ID.

You can get the status of the trainingPipeline job using the TRAININGPIPELINE_ID.

Classification

At training time you can choose the type of AutoML Edge model you want, depending on your specific use case:

  • low latency (MOBILE_TF_LOW_LATENCY_1)
  • general purpose usage (MOBILE_TF_VERSATILE_1)
  • higher prediction quality (MOBILE_TF_HIGH_ACCURACY_1)

Select the tab below for your language or environment:

REST

Before using any of the request data, make the following replacements:

  • LOCATION: Region where dataset is located and Model is created. For example, us-central1.
  • PROJECT: Your project ID.
  • TRAININGPIPELINE_DISPLAYNAME: Required. A display name for the trainingPipeline.
  • DATASET_ID: The ID number for the dataset to use for training.
  • fractionSplit: Optional. One of several possible ML use split options for your data. For fractionSplit, values must sum to 1. For example:
    • {"trainingFraction": "0.7","validationFraction": "0.15","testFraction": "0.15"}
  • MODEL_DISPLAYNAME*: A display name for the model uploaded (created) by the TrainingPipeline.
  • MODEL_DESCRIPTION*: A description for the model.
  • modelToUpload.labels*: Any set of key-value pairs to organize your models. For example:
    • "env": "prod"
    • "tier": "backend"
  • EDGE_MODELTYPE: The type of Edge model to train. The options are:
    • MOBILE_TF_LOW_LATENCY_1
    • MOBILE_TF_VERSATILE_1
    • MOBILE_TF_HIGH_ACCURACY_1
  • NODE_HOUR_BUDGET: The actual training cost will be equal or less than this value. For Edge models the budget must be: 1,000 - 100,000 milli node hours (inclusive).
  • PROJECT_NUMBER: Project number for your project

HTTP method and URL:

POST http://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT/locations/LOCATION/trainingPipelines

Request JSON body:

{
  "displayName": "TRAININGPIPELINE_DISPLAYNAME",
  "inputDataConfig": {
    "datasetId": "DATASET_ID",
    "fractionSplit": {
      "trainingFraction": "DECIMAL",
      "validationFraction": "DECIMAL",
      "testFraction": "DECIMAL"
    }
  },
  "modelToUpload": {
    "displayName": "MODEL_DISPLAYNAME",
    "description": "MODEL_DESCRIPTION",
    "labels": {
      "KEY": "VALUE"
    }
  },
  "trainingTaskDefinition": "gs://google-cloud-aiplatform/schema/trainingjob/definition/automl_image_classification_1.0.0.yaml",
  "trainingTaskInputs": {
    "multiLabel": "true",
    "modelType": ["EDGE_MODELTYPE"],
    "budgetMilliNodeHours": NODE_HOUR_BUDGET
  }
}

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 "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"http://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT/locations/LOCATION/trainingPipelines"

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" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "http://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT/locations/LOCATION/trainingPipelines" | Select-Object -Expand Content

The response contains information about specifications as well as the TRAININGPIPELINE_ID.

You can get the status of the trainingPipeline job using the TRAININGPIPELINE_ID.

Object detection

At training time you can choose the type of AutoML Edge model you want, depending on your specific use case:

  • low latency (MOBILE_TF_LOW_LATENCY_1)
  • general purpose usage (MOBILE_TF_VERSATILE_1)
  • higher prediction quality (MOBILE_TF_HIGH_ACCURACY_1)

Select the tab below for your language or environment:

REST

Before using any of the request data, make the following replacements:

  • LOCATION: Region where dataset is located and Model is created. For example, us-central1.
  • PROJECT: Your project ID.
  • TRAININGPIPELINE_DISPLAYNAME: Required. A display name for the trainingPipeline.
  • DATASET_ID: The ID number for the dataset to use for training.
  • fractionSplit: Optional. One of several possible ML use split options for your data. For fractionSplit, values must sum to 1. For example:
    • {"trainingFraction": "0.7","validationFraction": "0.15","testFraction": "0.15"}
  • MODEL_DISPLAYNAME*: A display name for the model uploaded (created) by the TrainingPipeline.
  • MODEL_DESCRIPTION*: A description for the model.
  • modelToUpload.labels*: Any set of key-value pairs to organize your models. For example:
    • "env": "prod"
    • "tier": "backend"
  • EDGE_MODELTYPE: The type of Edge model to train. The options are:
    • MOBILE_TF_LOW_LATENCY_1
    • MOBILE_TF_VERSATILE_1
    • MOBILE_TF_HIGH_ACCURACY_1
  • NODE_HOUR_BUDGET: The actual training cost will be equal or less than this value. For Cloud models the budget must be: 20,000 - 900,000 milli node hours (inclusive). The default value is 216,000 which represents one day in wall time, assuming 9 nodes are used.
  • PROJECT_NUMBER: Project number for your project

HTTP method and URL:

POST http://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT/locations/LOCATION/trainingPipelines

Request JSON body:

{
  "displayName": "TRAININGPIPELINE_DISPLAYNAME",
  "inputDataConfig": {
    "datasetId": "DATASET_ID",
    "fractionSplit": {
      "trainingFraction": "DECIMAL",
      "validationFraction": "DECIMAL",
      "testFraction": "DECIMAL"
    }
  },
  "modelToUpload": {
    "displayName": "MODEL_DISPLAYNAME",
    "description": "MODEL_DESCRIPTION",
    "labels": {
      "KEY": "VALUE"
    }
  },
  "trainingTaskDefinition": "gs://google-cloud-aiplatform/schema/trainingjob/definition/automl_image_object_detection_1.0.0.yaml",
  "trainingTaskInputs": {
    "modelType": ["EDGE_MODELTYPE"],
    "budgetMilliNodeHours": NODE_HOUR_BUDGET
  }
}

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 "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"http://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT/locations/LOCATION/trainingPipelines"

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" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "http://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT/locations/LOCATION/trainingPipelines" | Select-Object -Expand Content

The response contains information about specifications as well as the TRAININGPIPELINE_ID.

You can get the status of the trainingPipeline job using the TRAININGPIPELINE_ID.

Video

Select the tab below for your objective:

Action recognition

At training time, choose the following AutoML edge type:

  • MOBILE_VERSATILE_1: general purpose usage

REST

Before using any of the request data, make the following replacements:

  • PROJECT: Your project ID.
  • LOCATION: Region where dataset is located and Model is created. For example, us-central1.
  • TRAINING_PIPELINE_DISPLAY_NAME: Required. A display name for the TrainingPipeline.
  • DATASET_ID: ID for the training Dataset.
  • TRAINING_FRACTION, TEST_FRACTION: The fractionSplit object is optional; you use it to control your data split. For more information about controlling data split, see see About data splits for AutoML models. For example:
    • {"trainingFraction": "0.8","validationFraction": "0","testFraction": "0.2"}
  • MODEL_DISPLAY_NAME: Display name of the trained Model.
  • MODEL_DESCRIPTION: A description for the Model.
  • MODEL_LABELS: Any set of key-value pairs to organize your models. For example:
    • "env": "prod"
    • "tier": "backend"
  • EDGE_MODEL_TYPE:
    • MOBILE_VERSATILE_1: general purpose usage
  • PROJECT_NUMBER: Project number for your project

HTTP method and URL:

POST http://LOCATION-aiplatform.googleapis.com/beta1/projects/PROJECT/locations/LOCATION/trainingPipelines

Request JSON body:

{
  "displayName": "TRAINING_PIPELINE_DISPLAY_NAME",
  "inputDataConfig": {
    "datasetId": "DATASET_ID",
    "fractionSplit": {
      "trainingFraction": "TRAINING_FRACTION",
      "validationFraction": "0",
      "testFraction": "TEST_FRACTION"
    }
  },
  "modelToUpload": {
    "displayName": "MODEL_DISPLAY_NAME",
    "description": "MODEL_DESCRIPTION",
    "labels": {
      "KEY": "VALUE"
    }
  },
  "trainingTaskDefinition": "gs://google-cloud-aiplatform/schema/trainingjob/definition/automl_video_action_recognition_1.0.0.yaml",
  "trainingTaskInputs": {
    "modelType": ["EDGE_MODEL_TYPE"],
  }
}

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 "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"http://LOCATION-aiplatform.googleapis.com/beta1/projects/PROJECT/locations/LOCATION/trainingPipelines"

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" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "http://LOCATION-aiplatform.googleapis.com/beta1/projects/PROJECT/locations/LOCATION/trainingPipelines" | Select-Object -Expand Content

The response contains information about specifications as well as the TRAININGPIPELINE_ID.

You can get the status of the trainingPipeline progress to see when it finishes.

Classification

At training time, choose the following AutoML edge type:

  • MOBILE_VERSATILE_1: general purpose usage

REST

Before using any of the request data, make the following replacements:

  • PROJECT: Your project ID.
  • LOCATION: Region where dataset is located and Model is created. For example, us-central1.
  • TRAINING_PIPELINE_DISPLAY_NAME: Required. A display name for the TrainingPipeline.
  • DATASET_ID: ID for the training Dataset.
  • TRAINING_FRACTION, TEST_FRACTION: The fractionSplit object is optional; you use it to control your data split. For more information about controlling data split, see see About data splits for AutoML models. For example:
    • {"trainingFraction": "0.8","validationFraction": "0","testFraction": "0.2"}
  • MODEL_DISPLAY_NAME: Display name of the trained Model.
  • MODEL_DESCRIPTION: A description for the Model.
  • MODEL_LABELS: Any set of key-value pairs to organize your models. For example:
    • "env": "prod"
    • "tier": "backend"
  • EDGE_MODEL_TYPE:
    • MOBILE_VERSATILE_1: general purpose usage
  • PROJECT_NUMBER: Project number for your project

HTTP method and URL:

POST http://LOCATION-aiplatform.googleapis.com/beta1/projects/PROJECT/locations/LOCATION/trainingPipelines

Request JSON body:

{
  "displayName": "TRAINING_PIPELINE_DISPLAY_NAME",
  "inputDataConfig": {
    "datasetId": "DATASET_ID",
    "fractionSplit": {
      "trainingFraction": "TRAINING_FRACTION",
      "validationFraction": "0",
      "testFraction": "TEST_FRACTION"
    }
  },
  "modelToUpload": {
    "displayName": "MODEL_DISPLAY_NAME",
    "description": "MODEL_DESCRIPTION",
    "labels": {
      "KEY": "VALUE"
    }
  },
  "trainingTaskDefinition": "gs://google-cloud-aiplatform/schema/trainingjob/definition/automl_video_classification_1.0.0.yaml",
  "trainingTaskInputs": {
    "modelType": ["EDGE_MODEL_TYPE"],
  }
}

To send your request, choose one of these options:

curl