Class AutoMLVideoTrainingJob (1.19.1)

AutoMLVideoTrainingJob(
    display_name: Optional[str] = None,
    prediction_type: str = "classification",
    model_type: str = "CLOUD",
    project: Optional[str] = None,
    location: Optional[str] = None,
    credentials: Optional[google.auth.credentials.Credentials] = None,
    labels: Optional[Dict[str, str]] = None,
    training_encryption_spec_key_name: Optional[str] = None,
    model_encryption_spec_key_name: Optional[str] = None,
)

Constructs a AutoML Video Training Job.

Parameters

Name Description
display_name str

Required. The user-defined name of this TrainingPipeline.

prediction_type str

The type of prediction the Model is to produce, one of: "classification" - A video classification model classifies shots and segments in your videos according to your own defined labels. "object_tracking" - A video object tracking model detects and tracks multiple objects in shots and segments. You can use these models to track objects in your videos according to your own pre-defined, custom labels. "action_recognition" - A video action recognition model pinpoints the location of actions with short temporal durations (1 second).

project str

Optional. Project to run training in. Overrides project set in aiplatform.init.

location str

Optional. Location to run training in. Overrides location set in aiplatform.init.

credentials auth_credentials.Credentials

Optional. Custom credentials to use to run call training service. Overrides credentials set in aiplatform.init.

labels Dict[str, str]

Optional. The labels with user-defined metadata to organize TrainingPipelines. Label keys and values can be no longer than 64 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. See https://goo.gl/xmQnxf for more information and examples of labels.

training_encryption_spec_key_name Optional[str]

Optional. The Cloud KMS resource identifier of the customer managed encryption key used to protect the training pipeline. Has the form: projects/my-project/locations/my-region/keyRings/my-kr/cryptoKeys/my-key. The key needs to be in the same region as where the compute resource is created. If set, this TrainingPipeline will be secured by this key. Note: Model trained by this TrainingPipeline is also secured by this key if model_to_upload is not set separately. Overrides encryption_spec_key_name set in aiplatform.init.

model_encryption_spec_key_name Optional[str]

Optional. The Cloud KMS resource identifier of the customer managed encryption key used to protect the model. Has the form: projects/my-project/locations/my-region/keyRings/my-kr/cryptoKeys/my-key. The key needs to be in the same region as where the compute resource is created. If set, the trained Model will be secured by this key. Overrides encryption_spec_key_name set in aiplatform.init.

Inheritance

builtins.object > google.cloud.aiplatform.base.VertexAiResourceNoun > builtins.object > google.cloud.aiplatform.base.FutureManager > google.cloud.aiplatform.base.VertexAiResourceNounWithFutureManager > builtins.object > abc.ABC > google.cloud.aiplatform.base.DoneMixin > google.cloud.aiplatform.base.StatefulResource > google.cloud.aiplatform.base.VertexAiStatefulResource > google.cloud.aiplatform.training_jobs._TrainingJob > AutoMLVideoTrainingJob

Properties

create_time

Time this resource was created.

display_name

Display name of this resource.

encryption_spec

Customer-managed encryption key options for this Vertex AI resource.

If this is set, then all resources created by this Vertex AI resource will be encrypted with the provided encryption key.

end_time

Time when the TrainingJob resource entered the PIPELINE_STATE_SUCCEEDED, PIPELINE_STATE_FAILED, PIPELINE_STATE_CANCELLED state.

error

Detailed error info for this TrainingJob resource. Only populated when the TrainingJob's state is PIPELINE_STATE_FAILED or PIPELINE_STATE_CANCELLED.

gca_resource

The underlying resource proto representation.

has_failed

Returns True if training has failed.

False otherwise.

labels

User-defined labels containing metadata about this resource.

Read more about labels at https://goo.gl/xmQnxf

name

Name of this resource.

resource_name

Full qualified resource name.

start_time

Time when the TrainingJob entered the PIPELINE_STATE_RUNNING for the first time.

state

Current training state.

update_time

Time this resource was last updated.

Methods

cancel

cancel()

Starts asynchronous cancellation on the TrainingJob. The server makes a best effort to cancel the job, but success is not guaranteed. On successful cancellation, the TrainingJob is not deleted; instead it becomes a job with state set to CANCELLED.

Exceptions
Type Description
RuntimeError If this TrainingJob has not started running.

delete

delete(sync: bool = True)

Deletes this Vertex AI resource. WARNING: This deletion is permanent.

Parameter
Name Description
sync bool

Whether to execute this deletion synchronously. If False, this method will be executed in concurrent Future and any downstream object will be immediately returned and synced when the Future has completed.

done

done()

Method indicating whether a job has completed.

get

get(
    resource_name: str,
    project: Optional[str] = None,
    location: Optional[str] = None,
    credentials: Optional[google.auth.credentials.Credentials] = None,
)

Get Training Job for the given resource_name.

Parameters
Name Description
resource_name str

Required. A fully-qualified resource name or ID.

project str

Optional project to retrieve training job from. If not set, project set in aiplatform.init will be used.

location str

Optional location to retrieve training job from. If not set, location set in aiplatform.init will be used.

credentials auth_credentials.Credentials

Custom credentials to use to upload this model. Overrides credentials set in aiplatform.init.

Exceptions
Type Description
ValueError If the retrieved training job's training task definition doesn't match the custom training task definition.

get_model

get_model(sync=True)

Vertex AI Model produced by this training, if one was produced.

Parameter
Name Description
sync bool

Whether to execute this method synchronously. If False, this method will be executed in concurrent Future and any downstream object will be immediately returned and synced when the Future has completed.

Exceptions
Type Description
RuntimeError If training failed or if a model was not produced by this training.
Returns
Type Description
model Vertex AI Model produced by this training

list

list(
    filter: Optional[str] = None,
    order_by: Optional[str] = None,
    project: Optional[str] = None,
    location: Optional[str] = None,
    credentials: Optional[google.auth.credentials.Credentials] = None,
)

List all instances of this TrainingJob resource.

Example Usage:

aiplatform.CustomTrainingJob.list( filter='display_name="experiment_a27"', order_by='create_time desc' )

Parameters
Name Description
filter str

Optional. An expression for filtering the results of the request. For field names both snake_case and camelCase are supported.

order_by str

Optional. A comma-separated list of fields to order by, sorted in ascending order. Use "desc" after a field name for descending. Supported fields: display_name, create_time, update_time

project str

Optional. Project to retrieve list from. If not set, project set in aiplatform.init will be used.

location str

Optional. Location to retrieve list from. If not set, location set in aiplatform.init will be used.

credentials auth_credentials.Credentials

Optional. Custom credentials to use to retrieve list. Overrides credentials set in aiplatform.init.

run

run(
    dataset: google.cloud.aiplatform.datasets.video_dataset.VideoDataset,
    training_fraction_split: Optional[float] = None,
    test_fraction_split: Optional[float] = None,
    training_filter_split: Optional[str] = None,
    test_filter_split: Optional[str] = None,
    model_display_name: Optional[str] = None,
    model_labels: Optional[Dict[str, str]] = None,
    model_id: Optional[str] = None,
    parent_model: Optional[str] = None,
    is_default_version: Optional[bool] = True,
    model_version_aliases: Optional[Sequence[str]] = None,
    model_version_description: Optional[str] = None,
    sync: bool = True,
    create_request_timeout: Optional[float] = None,
)

Runs the AutoML Video training job and returns a model.

If training on a Vertex AI dataset, you can use one of the following split configurations: Data fraction splits: training_fraction_split, and test_fraction_split may optionally be provided, they must sum to up to 1. If none of the fractions are set, by default roughly 80% of data will be used for training, and 20% for test.

Data filter splits:
Assigns input data to training, validation, and test sets
based on the given filters, data pieces not matched by any
filter are ignored. Currently only supported for Datasets
containing DataItems.
If any of the filters in this message are to match nothing, then
they can be set as '-' (the minus sign).
If using filter splits, all of `training_filter_split`, `validation_filter_split` and
`test_filter_split` must be provided.
Supported only for unstructured Datasets.
Parameters
Name Description
dataset datasets.VideoDataset

Required. The dataset within the same Project from which data will be used to train the Model. The Dataset must use schema compatible with Model being trained, and what is compatible should be described in the used TrainingPipeline's [training_task_definition] [google.cloud.aiplatform.v1beta1.TrainingPipeline.training_task_definition]. For tabular Datasets, all their data is exported to training, to pick and choose from.

training_fraction_split float

Optional. The fraction of the input data that is to be used to train the Model. This is ignored if Dataset is not provided.

test_fraction_split float

Optional. The fraction of the input data that is to be used to evaluate the Model. This is ignored if Dataset is not provided.

training_filter_split str

Optional. A filter on DataItems of the Dataset. DataItems that match this filter are used to train the Model. A filter with same syntax as the one used in DatasetService.ListDataItems may be used. If a single DataItem is matched by more than one of the FilterSplit filters, then it is assigned to the first set that applies to it in the training, validation, test order. This is ignored if Dataset is not provided.

test_filter_split str

Optional. A filter on DataItems of the Dataset. DataItems that match this filter are used to test the Model. A filter with same syntax as the one used in DatasetService.ListDataItems may be used. If a single DataItem is matched by more than one of the FilterSplit filters, then it is assigned to the first set that applies to it in the training, validation, test order. This is ignored if Dataset is not provided.

model_display_name str

Optional. The display name of the managed Vertex AI Model. The name can be up to 128 characters long and can be consist of any UTF-8 characters. If not provided upon creation, the job's display_name is used.

model_labels Dict[str, str]

Optional. The labels with user-defined metadata to organize your Models. Label keys and values can be no longer than 64 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. See https://goo.gl/xmQnxf for more information and examples of labels.

model_id str

Optional. The ID to use for the Model produced by this job, which will become the final component of the model resource name. This value may be up to 63 characters, and valid characters are [a-z0-9_-]. The first character cannot be a number or hyphen.

parent_model str

Optional. The resource name or model ID of an existing model. The new model uploaded by this job will be a version of parent_model. Only set this field when training a new version of an existing model.

is_default_version bool

Optional. When set to True, the newly uploaded model version will automatically have alias "default" included. Subsequent uses of the model produced by this job without a version specified will use this "default" version. When set to False, the "default" alias will not be moved. Actions targeting the model version produced by this job will need to specifically reference this version by ID or alias. New model uploads, i.e. version 1, will always be "default" aliased.

model_version_aliases Sequence[str]

Optional. User provided version aliases so that the model version uploaded by this job can be referenced via alias instead of auto-generated version ID. A default version alias will be created for the first version of the model. The format is a-z][a-zA-Z0-9-]{0,126}[a-z0-9]

model_version_description str

Optional. The description of the model version being uploaded by this job.

create_request_timeout float

Optional. The timeout for the create request in seconds.

Exceptions
Type Description
RuntimeError If Training job has already been run or is waiting to run.
Returns
Type Description
model The trained Vertex AI Model resource or None if training did not produce a Vertex AI Model.

to_dict

to_dict()

Returns the resource proto as a dictionary.

wait

wait()

Helper method that blocks until all futures are complete.

wait_for_resource_creation

wait_for_resource_creation()

Waits until resource has been created.