ImageObjectDetectionJob Class

Configuration for AutoML Image Object Detection job.

Inheritance
azure.ai.ml.entities._job.automl.image.automl_image_object_detection_base.AutoMLImageObjectDetectionBase
ImageObjectDetectionJob

Constructor

ImageObjectDetectionJob(*, primary_metric: str | ObjectDetectionPrimaryMetrics | None = None, **kwargs: Any)

Keyword-Only Parameters

Name Description
primary_metric
Optional[str, <xref:azure.ai.ml.ObjectDetectionPrimaryMetrics>]

The primary metric to use for optimization.

Examples

creating an automl image object detection job


   from azure.ai.ml import automl, Input
   from azure.ai.ml.constants import AssetTypes
   from azure.ai.ml.automl import ObjectDetectionPrimaryMetrics

   image_object_detection_job = automl.ImageObjectDetectionJob(
       experiment_name="my_experiment",
       compute="my_compute",
       training_data=Input(type=AssetTypes.MLTABLE, path="./training-mltable-folder"),
       validation_data=Input(type=AssetTypes.MLTABLE, path="./validation-mltable-folder"),
       tags={"my_custom_tag": "My custom value"},
       primary_metric=ObjectDetectionPrimaryMetrics.MEAN_AVERAGE_PRECISION,
   )

Methods

dump

Dumps the job content into a file in YAML format.

extend_search_space

Add search space for AutoML Image Object Detection and Image Instance Segmentation tasks.

set_data

Data settings for all AutoML Image jobs.

set_limits

Limit settings for all AutoML Image Jobs.

set_sweep

Sweep settings for all AutoML Image jobs.

set_training_parameters

Setting Image training parameters for for AutoML Image Object Detection and Image Instance Segmentation tasks.

dump

Dumps the job content into a file in YAML format.

dump(dest: str | PathLike | IO, **kwargs: Any) -> None

Parameters

Name Description
dest
Required
Union[<xref:PathLike>, str, IO[AnyStr]]

The local path or file stream to write the YAML content to. If dest is a file path, a new file will be created. If dest is an open file, the file will be written to directly.

Exceptions

Type Description

Raised if dest is a file path and the file already exists.

Raised if dest is an open file and the file is not writable.

extend_search_space

Add search space for AutoML Image Object Detection and Image Instance Segmentation tasks.

extend_search_space(value: SearchSpace | List[SearchSpace]) -> None

Parameters

Name Description
value
Required

Search through the parameter space

Exceptions

Type Description

Raised if dest is a file path and the file already exists.

Raised if dest is an open file and the file is not writable.

set_data

Data settings for all AutoML Image jobs.

set_data(*, training_data: Input, target_column_name: str, validation_data: Input | None = None, validation_data_size: float | None = None) -> None

Keyword-Only Parameters

Name Description
training_data

Required. Training data.

target_column_name

Required. Target column name.

validation_data

Optional. Validation data.

validation_data_size

Optional. The fraction of training dataset that needs to be set aside for validation purpose. Values should be in range (0.0 , 1.0). Applied only when validation dataset is not provided.

Returns

Type Description

None

Exceptions

Type Description

Raised if dest is a file path and the file already exists.

Raised if dest is an open file and the file is not writable.

set_limits

Limit settings for all AutoML Image Jobs.

set_limits(*, max_concurrent_trials: int | None = None, max_trials: int | None = None, timeout_minutes: int | None = None) -> None

Keyword-Only Parameters

Name Description
max_concurrent_trials

Maximum number of trials to run concurrently.

max_trials

Maximum number of trials to run. Defaults to None.

timeout_minutes

AutoML job timeout.

Returns

Type Description

None

Exceptions

Type Description

Raised if dest is a file path and the file already exists.

Raised if dest is an open file and the file is not writable.

set_sweep

Sweep settings for all AutoML Image jobs.

set_sweep(*, sampling_algorithm: str | Random | Grid | Bayesian, early_termination: BanditPolicy | MedianStoppingPolicy | TruncationSelectionPolicy | None = None) -> None

Keyword-Only Parameters

Name Description
sampling_algorithm

Required. Type of the hyperparameter sampling algorithms. Possible values include: "Grid", "Random", "Bayesian".

early_termination

Type of early termination policy.

Returns

Type Description

None

Exceptions

Type Description

Raised if dest is a file path and the file already exists.

Raised if dest is an open file and the file is not writable.

set_training_parameters

Setting Image training parameters for for AutoML Image Object Detection and Image Instance Segmentation tasks.

set_training_parameters(*, advanced_settings: str | None = None, ams_gradient: bool | None = None, beta1: float | None = None, beta2: float | None = None, checkpoint_frequency: int | None = None, checkpoint_run_id: str | None = None, distributed: bool | None = None, early_stopping: bool | None = None, early_stopping_delay: int | None = None, early_stopping_patience: int | None = None, enable_onnx_normalization: bool | None = None, evaluation_frequency: int | None = None, gradient_accumulation_step: int | None = None, layers_to_freeze: int | None = None, learning_rate: float | None = None, learning_rate_scheduler: str | LearningRateScheduler | None = None, model_name: str | None = None, momentum: float | None = None, nesterov: bool | None = None, number_of_epochs: int | None = None, number_of_workers: int | None = None, optimizer: str | StochasticOptimizer | None = None, random_seed: int | None = None, step_lr_gamma: float | None = None, step_lr_step_size: int | None = None, training_batch_size: int | None = None, validation_batch_size: int | None = None, warmup_cosine_lr_cycles: float | None = None, warmup_cosine_lr_warmup_epochs: int | None = None, weight_decay: float | None = None, box_detections_per_image: int | None = None, box_score_threshold: float | None = None, image_size: int | None = None, max_size: int | None = None, min_size: int | None = None, model_size: str | ModelSize | None = None, multi_scale: bool | None = None, nms_iou_threshold: float | None = None, tile_grid_size: str | None = None, tile_overlap_ratio: float | None = None, tile_predictions_nms_threshold: float | None = None, validation_iou_threshold: float | None = None, validation_metric_type: str | ValidationMetricType | None = None, log_training_metrics: str | LogTrainingMetrics | None = None, log_validation_loss: str | LogValidationLoss | None = None) -> None

Keyword-Only Parameters

Name Description
advanced_settings
str

Settings for advanced scenarios.

ams_gradient

Enable AMSGrad when optimizer is 'adam' or 'adamw'.

beta1

Value of 'beta1' when optimizer is 'adam' or 'adamw'. Must be a float in the range [0, 1].

beta2

Value of 'beta2' when optimizer is 'adam' or 'adamw'. Must be a float in the range [0, 1].

checkpoint_frequency
int

Frequency to store model checkpoints. Must be a positive integer.

checkpoint_run_id
str

The id of a previous run that has a pretrained checkpoint for incremental training.

distributed

Whether to use distributed training.

early_stopping

Enable early stopping logic during training.

early_stopping_delay
int

Minimum number of epochs or validation evaluations to wait before primary metric improvement is tracked for early stopping. Must be a positive integer.

early_stopping_patience
int

Minimum number of epochs or validation evaluations with no primary metric improvement before the run is stopped. Must be a positive integer.

enable_onnx_normalization

Enable normalization when exporting ONNX model.

evaluation_frequency
int

Frequency to evaluate validation dataset to get metric scores. Must be a positive integer.

gradient_accumulation_step
int

Gradient accumulation means running a configured number of "GradAccumulationStep" steps without updating the model weights while accumulating the gradients of those steps, and then using the accumulated gradients to compute the weight updates. Must be a positive integer.

layers_to_freeze

Number of layers to freeze for the model. Must be a positive integer. For instance, passing 2 as value for 'seresnext' means freezing layer0 and layer1. For a full list of models supported and details on layer freeze, please see: https://docs.microsoft.com/en-us/azure/machine-learning/reference-automl-images-hyperparameters#model-agnostic-hyperparameters. # pylint: disable=line-too-long

learning_rate

Initial learning rate. Must be a float in the range [0, 1].

learning_rate_scheduler

Type of learning rate scheduler. Must be 'warmup_cosine' or 'step'. Possible values include: "None", "WarmupCosine", "Step".

model_name

Name of the model to use for training. For more information on the available models please visit the official documentation: https://docs.microsoft.com/en-us/azure/machine-learning/how-to-auto-train-image-models.

momentum

Value of momentum when optimizer is 'sgd'. Must be a float in the range [0, 1].

nesterov

Enable nesterov when optimizer is 'sgd'.

number_of_epochs
int

Number of training epochs. Must be a positive integer.

number_of_workers
int

Number of data loader workers. Must be a non-negative integer.

optimizer

Type of optimizer. Possible values include: "None", "Sgd", "Adam", "Adamw".

random_seed
int

Random seed to be used when using deterministic training.

step_lr_gamma

Value of gamma when learning rate scheduler is 'step'. Must be a float in the range [0, 1].

step_lr_step_size
int

Value of step size when learning rate scheduler is 'step'. Must be a positive integer.

training_batch_size
int

Training batch size. Must be a positive integer.

validation_batch_size
int

Validation batch size. Must be a positive integer.

warmup_cosine_lr_cycles

Value of cosine cycle when learning rate scheduler is 'warmup_cosine'. Must be a float in the range [0, 1].

warmup_cosine_lr_warmup_epochs
int

Value of warmup epochs when learning rate scheduler is 'warmup_cosine'. Must be a positive integer.

weight_decay

Value of weight decay when optimizer is 'sgd', 'adam', or 'adamw'. Must be a float in the range[0, 1].

box_detections_per_image

Maximum number of detections per image, for all classes. Must be a positive integer. Note: This settings is not supported for the 'yolov5' algorithm.

box_score_threshold

During inference, only return proposals with a classification score greater than BoxScoreThreshold. Must be a float in the range[0, 1].

image_size

Image size for training and validation. Must be a positive integer. Note: The training run may get into CUDA OOM if the size is too big. Note: This settings is only supported for the 'yolov5' algorithm.

max_size

Maximum size of the image to be rescaled before feeding it to the backbone. Must be a positive integer. Note: training run may get into CUDA OOM if the size is too big. Note: This settings is not supported for the 'yolov5' algorithm.

min_size

Minimum size of the image to be rescaled before feeding it to the backbone. Must be a positive integer. Note: training run may get into CUDA OOM if the size is too big. Note: This settings is not supported for the 'yolov5' algorithm.

model_size

Model size. Must be 'small', 'medium', 'large', or 'extra_large'. Note: training run may get into CUDA OOM if the model size is too big. Note: This settings is only supported for the 'yolov5' algorithm.

multi_scale

Enable multi-scale image by varying image size by +/- 50%. Note: training run may get into CUDA OOM if no sufficient GPU memory. Note: This settings is only supported for the 'yolov5' algorithm.

nms_iou_threshold

IOU threshold used during inference in NMS post processing. Must be float in the range [0, 1].

tile_grid_size

The grid size to use for tiling each image. Note: TileGridSize must not be None to enable small object detection logic. A string containing two integers in mxn format.

tile_overlap_ratio

Overlap ratio between adjacent tiles in each dimension. Must be float in the range [0, 1).

tile_predictions_nms_threshold

The IOU threshold to use to perform NMS while merging predictions from tiles and image. Used in validation/ inference. Must be float in the range [0, 1]. NMS: Non-maximum suppression.

validation_iou_threshold

IOU threshold to use when computing validation metric. Must be float in the range [0, 1].

validation_metric_type

Metric computation method to use for validation metrics. Must be 'none', 'coco', 'voc', or 'coco_voc'.

log_training_metrics
str or <xref:azure.mgmt.machinelearningservices.models.LogTrainingMetrics>

indicates whether or not to log training metrics. Must be 'Enable' or 'Disable'

log_validation_loss
str or <xref:azure.mgmt.machinelearningservices.models.LogValidationLoss>

indicates whether or not to log validation loss. Must be 'Enable' or 'Disable'

Exceptions

Type Description

Raised if dest is a file path and the file already exists.

Raised if dest is an open file and the file is not writable.

Attributes

base_path

The base path of the resource.

Returns

Type Description
str

The base path of the resource.

creation_context

The creation context of the resource.

Returns

Type Description

The creation metadata for the resource.

id

The resource ID.

Returns

Type Description

The global ID of the resource, an Azure Resource Manager (ARM) ID.

inputs

limits

Returns the limit settings for all AutoML Image jobs.

Returns

Type Description

The limit settings.

log_files

Job output files.

Returns

Type Description

The dictionary of log names and URLs.

log_verbosity

Returns the verbosity of the logger.

Returns

Type Description
<xref:azure.ai.ml._restclient.v2023_04_01_preview.models.LogVerbosity>

The log verbosity.

outputs

primary_metric

search_space

status

The status of the job.

Common values returned include "Running", "Completed", and "Failed". All possible values are:

  • NotStarted - This is a temporary state that client-side Run objects are in before cloud submission.

  • Starting - The Run has started being processed in the cloud. The caller has a run ID at this point.

  • Provisioning - On-demand compute is being created for a given job submission.

  • Preparing - The run environment is being prepared and is in one of two stages:

    • Docker image build

    • conda environment setup

  • Queued - The job is queued on the compute target. For example, in BatchAI, the job is in a queued state

    while waiting for all the requested nodes to be ready.

  • Running - The job has started to run on the compute target.

  • Finalizing - User code execution has completed, and the run is in post-processing stages.

  • CancelRequested - Cancellation has been requested for the job.

  • Completed - The run has completed successfully. This includes both the user code execution and run

    post-processing stages.

  • Failed - The run failed. Usually the Error property on a run will provide details as to why.

  • Canceled - Follows a cancellation request and indicates that the run is now successfully cancelled.

  • NotResponding - For runs that have Heartbeats enabled, no heartbeat has been recently sent.

Returns

Type Description

Status of the job.

studio_url

Azure ML studio endpoint.

Returns

Type Description

The URL to the job details page.

sweep

Returns the sweep settings for all AutoML Image jobs.

Returns

Type Description

The sweep settings.

task_type

Get task type.

Returns

Type Description
str

The type of task to run. Possible values include: "classification", "regression", "forecasting".

test_data

Get test data.

Returns

Type Description

Test data input

training_data

Get training data.

Returns

Type Description

Training data input

training_parameters

type

The type of the job.

Returns

Type Description

The type of the job.

validation_data

Get validation data.

Returns

Type Description

Validation data input