共用方式為


CLI (v2) 自動化 ML 映射物件偵測作業 YAML 架構

適用於:Azure CLI ml 延伸模組 v2 (目前)

您可以在 找到 https://azuremlsdk2.blob.core.windows.net/preview/0.0.1/autoMLImageObjectDetectionJob.schema.json來源 JSON 架構。

注意

本文件中詳述的 YAML 語法是以最新版 ML CLI v2 延伸模組的 JSON 結構描述為基礎。 此語法僅保證能與最新版的 ML CLI v2 延伸模組搭配運作。 您可以在 https://azuremlschemasprod.azureedge.net/ 找到舊版延伸模組的結構描述。

YAML 語法

如需 YAML 語法中所有索引鍵的資訊,請參閱 影像分類工作的 YAML 語法 。 在這裡,我們只描述與影像分類工作所指定的索引鍵相比,具有不同值的索引鍵。

機碼 類型 描述 允許的值 預設值
task 常量 必要。 AutoML 工作的類型。 image_object_detection image_object_detection
primary_metric 字串 AutoML 將針對模型選取進行優化的計量。 mean_average_precision mean_average_precision
training_parameters 物體 包含作業定型參數的字典。 提供具有下列各節所列索引鍵的物件。
- 適用於 yolov5 的模型特定超參數 (如果您使用 yolov5 進行物件偵測)
- 模型無從驗證超參數
- 對象偵測和實例分割工作特定的超參數

如需範例,請參閱 支援的模型架構 一節。

備註

命令az ml job可用來管理 Azure 機器學習 作業。

範例

範例 GitHub 存放庫中有範例可用。 與影像物件偵測作業相關的范例如下所示。

YAML:AutoML 影像物件偵測作業

$schema: https://azuremlsdk2.blob.core.windows.net/preview/0.0.1/autoMLJob.schema.json
type: automl

# <experiment_name>
experiment_name: dpv2-cli-automl-image-object-detection-experiment
# </experiment_name>
description: An Image Object Detection job using fridge items dataset

# <compute_settings>
compute: azureml:gpu-cluster
# </compute_settings>

# <task_settings>
task: image_object_detection
log_verbosity: debug
primary_metric: mean_average_precision
# </task_settings>

# <mltable_settings>
target_column_name: label
training_data:
  # Update the path, if prepare_data.py is using data_path other than "./data"
  path: data/training-mltable-folder
  type: mltable
validation_data:
  # Update the path, if prepare_data.py is using data_path other than "./data"
  path: data/validation-mltable-folder
  type: mltable
# </mltable_settings>

# <limit_settings>
limits:
  timeout_minutes: 60
  max_trials: 10
  max_concurrent_trials: 2
# </limit_settings>

# <fixed_settings>
training_parameters:
  early_stopping: True
  evaluation_frequency: 1
# </fixed_settings>

# <sweep_settings>
sweep:
  sampling_algorithm: random
  early_termination:
    type: bandit
    evaluation_interval: 2
    slack_factor: 0.2
    delay_evaluation: 6
# </sweep_settings>

# <search_space_settings>
search_space:
  - model_name:
      type: choice
      values: [yolov5]
    learning_rate:
      type: uniform
      min_value: 0.0001
      max_value: 0.01
    model_size:
      type: choice
      values: ['small', 'medium']
  - model_name:
      type: choice
      values: [fasterrcnn_resnet50_fpn]
    learning_rate:
      type: uniform
      min_value: 0.0001
      max_value: 0.001
    optimizer:
      type: choice
      values: ['sgd', 'adam', 'adamw']
    min_size:
      type: choice
      values: [600, 800]
# </search_space_settings>

YAML:AutoML 映射物件偵測管線作業

$schema: https://azuremlschemas.azureedge.net/latest/pipelineJob.schema.json
type: pipeline

description: Pipeline using AutoML Image Object Detection task

display_name: pipeline-with-image-object-detection
experiment_name: pipeline-with-automl

settings:
  default_compute: azureml:gpu-cluster

inputs:
  image_object_detection_training_data:
    type: mltable
    # Update the path, if prepare_data.py is using data_path other than "./data"
    path: data/training-mltable-folder
  image_object_detection_validation_data:
    type: mltable
    # Update the path, if prepare_data.py is using data_path other than "./data"
    path: data/validation-mltable-folder

jobs:
  image_object_detection_node:
    type: automl
    task: image_object_detection
    log_verbosity: info
    primary_metric: mean_average_precision
    limits:
      timeout_minutes: 180
      max_trials: 10
      max_concurrent_trials: 2
    target_column_name: label
    training_data: ${{parent.inputs.image_object_detection_training_data}}
    validation_data: ${{parent.inputs.image_object_detection_validation_data}}
    training_parameters:
      early_stopping: True
      evaluation_frequency: 1
    sweep:
      sampling_algorithm: random
      early_termination:
        type: bandit
        evaluation_interval: 2
        slack_factor: 0.2
        delay_evaluation: 6
    search_space:
      - model_name:
          type: choice
          values: [yolov5]
        learning_rate:
          type: uniform
          min_value: 0.0001
          max_value: 0.001
        model_size:
          type: choice
          values: ['small', 'medium']

      - model_name:
          type: choice
          values: [fasterrcnn_resnet50_fpn]
        learning_rate:
          type: uniform
          min_value: 0.0001
          max_value: 0.001
        optimizer:
          type: choice
          values: ['sgd', 'adam', 'adamw']
        min_size:
          type: choice
          values: [600, 800]
    # currently need to specify outputs "mlflow_model" explicitly to reference it in following nodes
    outputs:
      best_model:
        type: mlflow_model
  register_model_node:
    type: command
    component: file:./components/component_register_model.yaml
    inputs:
      model_input_path: ${{parent.jobs.image_object_detection_node.outputs.best_model}}
      model_base_name: fridge_items_object_detection_model

下一步