Skip to content

Commit 1abff2d

Browse files
Merge pull request #210711 from sdgilley/sdg-patch
standardize Python/CLI tabs
2 parents 7fc318c + 546005b commit 1abff2d

5 files changed

+191
-98
lines changed

articles/machine-learning/how-to-auto-train-image-models.md

Lines changed: 81 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ ms.date: 07/13/2022
1515

1616
# Set up AutoML to train computer vision models
1717

18-
[!INCLUDE [sdk v2](../../includes/machine-learning-sdk-v2.md)]
19-
> [!div class="op_single_selector" title1="Select the version of Azure Machine Learning CLI extension you are using:"]
18+
[!INCLUDE [dev v2](../../includes/machine-learning-dev-v2.md)]
19+
> [!div class="op_single_selector" title1="Select the version of Azure Machine Learning you are using:"]
2020
> * [v1](v1/how-to-auto-train-image-models-v1.md)
2121
> * [v2 (current version)](how-to-auto-train-image-models.md)
2222
@@ -29,12 +29,17 @@ Automated ML supports model training for computer vision tasks like image classi
2929

3030
## Prerequisites
3131

32-
# [CLI v2](#tab/CLI-v2)
32+
# [Azure CLI](#tab/cli)
33+
[!INCLUDE [cli v2](../../includes/machine-learning-cli-v2.md)]
34+
3335

3436
* An Azure Machine Learning workspace. To create the workspace, see [Create workspace resources](quickstart-create-resources.md).
3537
* Install and [set up CLI (v2)](how-to-configure-cli.md#prerequisites) and make sure you install the `ml` extension.
3638

37-
# [Python SDK v2 (preview)](#tab/SDK-v2)
39+
# [Python SDK](#tab/python)
40+
41+
[!INCLUDE [sdk v2](../../includes/machine-learning-sdk-v2.md)]
42+
3843
* An Azure Machine Learning workspace. To create the workspace, see [Create workspace resources](quickstart-create-resources.md).
3944

4045
* The Azure Machine Learning Python SDK v2 (preview) installed.
@@ -68,7 +73,7 @@ image classification multi-label | CLI v2: `image_classification_multilabel` <br
6873
image object detection | CLI v2: `image_object_detection` <br> SDK v2: `image_object_detection()`
6974
image instance segmentation| CLI v2: `image_instance_segmentation` <br> SDK v2: `image_instance_segmentation()`
7075

71-
# [CLI v2](#tab/CLI-v2)
76+
# [Azure CLI](#tab/cli)
7277

7378
[!INCLUDE [cli v2](../../includes/machine-learning-cli-v2.md)]
7479

@@ -80,7 +85,11 @@ For example:
8085
task: image_object_detection
8186
```
8287

83-
# [Python SDK v2 (preview)](#tab/SDK-v2)
88+
# [Python SDK](#tab/python)
89+
90+
[!INCLUDE [sdk v2](../../includes/machine-learning-sdk-v2.md)]
91+
92+
8493
Based on the task type, you can create AutoML image jobs using task specific `automl` functions.
8594

8695
For example:
@@ -189,7 +198,7 @@ Once your data is in JSONL format, you can create training and validation `MLTab
189198

190199
Automated ML doesn't impose any constraints on training or validation data size for computer vision tasks. Maximum dataset size is only limited by the storage layer behind the dataset (i.e. blob store). There's no minimum number of images or labels. However, we recommend starting with a minimum of 10-15 samples per label to ensure the output model is sufficiently trained. The higher the total number of labels/classes, the more samples you need per label.
191200

192-
# [CLI v2](#tab/CLI-v2)
201+
# [Azure CLI](#tab/cli)
193202

194203
[!INCLUDE [cli v2](../../includes/machine-learning-cli-v2.md)]
195204

@@ -207,7 +216,9 @@ validation_data:
207216
type: mltable
208217
```
209218

210-
# [Python SDK v2 (preview)](#tab/SDK-v2)
219+
# [Python SDK](#tab/python)
220+
221+
[!INCLUDE [sdk v2](../../includes/machine-learning-sdk-v2.md)]
211222

212223
You can create data inputs from training and validation MLTable from your local directory or cloud storage with the following code:
213224

@@ -233,15 +244,17 @@ Provide a [compute target](concept-azure-machine-learning-architecture.md#comput
233244

234245
The compute target is passed in using the `compute` parameter. For example:
235246

236-
# [CLI v2](#tab/CLI-v2)
247+
# [Azure CLI](#tab/cli)
237248

238249
[!INCLUDE [cli v2](../../includes/machine-learning-cli-v2.md)]
239250

240251
```yaml
241252
compute: azureml:gpu-cluster
242253
```
243254

244-
# [Python SDK v2 (preview)](#tab/SDK-v2)
255+
# [Python SDK](#tab/python)
256+
257+
[!INCLUDE [sdk v2](../../includes/machine-learning-sdk-v2.md)]
245258

246259
```python
247260
from azure.ai.ml import automl
@@ -286,7 +299,7 @@ In general, deep learning model performance can often improve with more data. Da
286299

287300
Before doing a large sweep to search for the optimal models and hyperparameters, we recommend trying the default values to get a first baseline. Next, you can explore multiple hyperparameters for the same model before sweeping over multiple models and their parameters. This way, you can employ a more iterative approach, because with multiple models and multiple hyperparameters for each, the search space grows exponentially and you need more iterations to find optimal configurations.
288301

289-
# [CLI v2](#tab/CLI-v2)
302+
# [Azure CLI](#tab/cli)
290303

291304
[!INCLUDE [cli v2](../../includes/machine-learning-cli-v2.md)]
292305

@@ -296,7 +309,9 @@ If you wish to use the default hyperparameter values for a given algorithm (say
296309
image_model:
297310
model_name: "yolov5"
298311
```
299-
# [Python SDK v2 (preview)](#tab/SDK-v2)
312+
# [Python SDK](#tab/python)
313+
314+
[!INCLUDE [sdk v2](../../includes/machine-learning-sdk-v2.md)]
300315

301316
If you wish to use the default hyperparameter values for a given algorithm (say yolov5), you can specify it using model_name parameter in set_image_model method of the task specific `automl` job. For example,
302317

@@ -318,7 +333,7 @@ The primary metric used for model optimization and hyperparameter tuning depends
318333
### Experiment budget
319334

320335
You can optionally specify the maximum time budget for your AutoML Vision training job using the `timeout` parameter in the `limits` - the amount of time in minutes before the experiment terminates. If none specified, default experiment timeout is seven days (maximum 60 days). For example,
321-
# [CLI v2](#tab/CLI-v2)
336+
# [Azure CLI](#tab/cli)
322337

323338
[!INCLUDE [cli v2](../../includes/machine-learning-cli-v2.md)]
324339

@@ -327,7 +342,9 @@ limits:
327342
timeout: 60
328343
```
329344

330-
# [Python SDK v2 (preview)](#tab/SDK-v2)
345+
# [Python SDK](#tab/python)
346+
347+
[!INCLUDE [sdk v2](../../includes/machine-learning-sdk-v2.md)]
331348

332349
[!Notebook-python[] (~/azureml-examples-main/sdk/jobs/automl-standalone-jobs/automl-image-object-detection-task-fridge-items/automl-image-object-detection-task-fridge-items.ipynb?name=limit-settings)]
333350

@@ -385,7 +402,7 @@ Parameter | Detail
385402

386403
You can configure all the sweep related parameters as shown in the example below.
387404

388-
# [CLI v2](#tab/CLI-v2)
405+
# [Azure CLI](#tab/cli)
389406

390407
[!INCLUDE [cli v2](../../includes/machine-learning-cli-v2.md)]
391408

@@ -402,7 +419,9 @@ sweep:
402419
delay_evaluation: 6
403420
```
404421

405-
# [Python SDK v2 (preview)](#tab/SDK-v2)
422+
# [Python SDK](#tab/python)
423+
424+
[!INCLUDE [sdk v2](../../includes/machine-learning-sdk-v2.md)]
406425

407426
[!Notebook-python[] (~/azureml-examples-main/sdk/jobs/automl-standalone-jobs/automl-image-object-detection-task-fridge-items/automl-image-object-detection-task-fridge-items.ipynb?name=sweep-settings)]
408427

@@ -413,7 +432,7 @@ sweep:
413432

414433
You can pass fixed settings or parameters that don't change during the parameter space sweep as shown below.
415434

416-
# [CLI v2](#tab/CLI-v2)
435+
# [Azure CLI](#tab/cli)
417436

418437
[!INCLUDE [cli v2](../../includes/machine-learning-cli-v2.md)]
419438

@@ -424,7 +443,9 @@ image_model:
424443
```
425444

426445

427-
# [Python SDK v2 (preview)](#tab/SDK-v2)
446+
# [Python SDK](#tab/python)
447+
448+
[!INCLUDE [sdk v2](../../includes/machine-learning-sdk-v2.md)]
428449

429450
[!Notebook-python[] (~/azureml-examples-main/sdk/jobs/automl-standalone-jobs/automl-image-object-detection-task-fridge-items/automl-image-object-detection-task-fridge-items.ipynb?name=pass-arguments)]
430451

@@ -440,7 +461,7 @@ Once the training run is done, you have the option to further train the model by
440461

441462
You can pass the run ID that you want to load the checkpoint from.
442463

443-
# [CLI v2](#tab/CLI-v2)
464+
# [Azure CLI](#tab/cli)
444465

445466
[!INCLUDE [cli v2](../../includes/machine-learning-cli-v2.md)]
446467

@@ -450,7 +471,9 @@ image_model:
450471
```
451472

452473

453-
# [Python SDK v2 (preview)](#tab/SDK-v2)
474+
# [Python SDK](#tab/python)
475+
476+
[!INCLUDE [sdk v2](../../includes/machine-learning-sdk-v2.md)]
454477

455478
To find the run ID from the desired model, you can use the following code.
456479

@@ -500,7 +523,7 @@ automl_image_job_incremental = ml_client.jobs.create_or_update(
500523

501524

502525

503-
# [CLI v2](#tab/CLI-v2)
526+
# [Azure CLI](#tab/cli)
504527

505528
[!INCLUDE [cli v2](../../includes/machine-learning-cli-v2.md)]
506529

@@ -510,7 +533,9 @@ To submit your AutoML job, you run the following CLI v2 command with the path to
510533
az ml job create --file ./hello-automl-job-basic.yml --workspace-name [YOUR_AZURE_WORKSPACE] --resource-group [YOUR_AZURE_RESOURCE_GROUP] --subscription [YOUR_AZURE_SUBSCRIPTION]
511534
```
512535

513-
# [Python SDK v2 (preview)](#tab/SDK-v2)
536+
# [Python SDK](#tab/python)
537+
538+
[!INCLUDE [sdk v2](../../includes/machine-learning-sdk-v2.md)]
514539

515540
When you've configured your AutoML Job to the desired settings, you can submit the job.
516541

@@ -532,15 +557,17 @@ Once the run completes, you can register the model that was created from the bes
532557

533558
### Get the best run
534559

535-
536-
# [CLI v2](#tab/CLI-v2)
560+
# [Azure CLI](#tab/cli)
537561

538562
[!INCLUDE [cli v2](../../includes/machine-learning-cli-v2.md)]
563+
539564
```yaml
540565

541566
```
542567

543-
# [Python SDK v2 (preview)](#tab/SDK-v2)
568+
# [Python SDK](#tab/python)
569+
570+
[!INCLUDE [sdk v2](../../includes/machine-learning-sdk-v2.md)]
544571

545572
[!Notebook-python[] (~/azureml-examples-main/sdk/jobs/automl-standalone-jobs/automl-image-object-detection-task-fridge-items/automl-image-object-detection-task-fridge-items.ipynb?name=best_run)]
546573

@@ -553,14 +580,16 @@ Once the run completes, you can register the model that was created from the bes
553580

554581
Register the model either using the azureml path or your locally downloaded path.
555582

556-
# [CLI v2](#tab/CLI-v2)
583+
# [Azure CLI](#tab/cli)
557584

558585
[!INCLUDE [cli v2](../../includes/machine-learning-cli-v2.md)]
559586

560587
```azurecli
561588
az ml model create --name od-fridge-items-mlflow-model --version 1 --path azureml://jobs/$best_run/outputs/artifacts/outputs/mlflow-model/ --type mlflow_model --workspace-name [YOUR_AZURE_WORKSPACE] --resource-group [YOUR_AZURE_RESOURCE_GROUP] --subscription [YOUR_AZURE_SUBSCRIPTION]
562589
```
563-
# [Python SDK v2 (preview)](#tab/SDK-v2)
590+
# [Python SDK](#tab/python)
591+
592+
[!INCLUDE [sdk v2](../../includes/machine-learning-sdk-v2.md)]
564593

565594
[!Notebook-python[] (~/azureml-examples-main/sdk/jobs/automl-standalone-jobs/automl-image-object-detection-task-fridge-items/automl-image-object-detection-task-fridge-items.ipynb?name=register_model)]
566595
---
@@ -569,7 +598,7 @@ After you register the model you want to use, you can deploy it using the manage
569598

570599
### Configure online endpoint
571600

572-
# [CLI v2](#tab/CLI-v2)
601+
# [Azure CLI](#tab/cli)
573602

574603
[!INCLUDE [cli v2](../../includes/machine-learning-cli-v2.md)]
575604

@@ -579,7 +608,9 @@ name: od-fridge-items-endpoint
579608
auth_mode: key
580609
```
581610

582-
# [Python SDK v2 (preview)](#tab/SDK-v2)
611+
# [Python SDK](#tab/python)
612+
613+
[!INCLUDE [sdk v2](../../includes/machine-learning-sdk-v2.md)]
583614

584615
[!Notebook-python[] (~/azureml-examples-main/sdk/jobs/automl-standalone-jobs/automl-image-object-detection-task-fridge-items/automl-image-object-detection-task-fridge-items.ipynb?name=endpoint)]
585616

@@ -590,14 +621,16 @@ auth_mode: key
590621
Using the `MLClient` created earlier, we'll now create the Endpoint in the workspace. This command will start the endpoint creation and return a confirmation response while the endpoint creation continues.
591622

592623

593-
# [CLI v2](#tab/CLI-v2)
624+
# [Azure CLI](#tab/cli)
594625

595626
[!INCLUDE [cli v2](../../includes/machine-learning-cli-v2.md)]
596627
```azurecli
597628
az ml online-endpoint create --file .\create_endpoint.yml --workspace-name [YOUR_AZURE_WORKSPACE] --resource-group [YOUR_AZURE_RESOURCE_GROUP] --subscription [YOUR_AZURE_SUBSCRIPTION]
598629
```
599630

600-
# [Python SDK v2 (preview)](#tab/SDK-v2)
631+
# [Python SDK](#tab/python)
632+
633+
[!INCLUDE [sdk v2](../../includes/machine-learning-sdk-v2.md)]
601634

602635
[!Notebook-python[] (~/azureml-examples-main/sdk/jobs/automl-standalone-jobs/automl-image-object-detection-task-fridge-items/automl-image-object-detection-task-fridge-items.ipynb?name=create_endpoint)]
603636
---
@@ -607,7 +640,7 @@ az ml online-endpoint create --file .\create_endpoint.yml --workspace-name [YOUR
607640
A deployment is a set of resources required for hosting the model that does the actual inferencing. We'll create a deployment for our endpoint using the `ManagedOnlineDeployment` class. You can use either GPU or CPU VM SKUs for your deployment cluster.
608641

609642

610-
# [CLI v2](#tab/CLI-v2)
643+
# [Azure CLI](#tab/cli)
611644

612645
[!INCLUDE [cli v2](../../includes/machine-learning-cli-v2.md)]
613646

@@ -631,7 +664,9 @@ readiness_probe:
631664
initial_delay: 2000
632665
```
633666

634-
# [Python SDK v2 (preview)](#tab/SDK-v2)
667+
# [Python SDK](#tab/python)
668+
669+
[!INCLUDE [sdk v2](../../includes/machine-learning-sdk-v2.md)]
635670

636671
[!Notebook-python[] (~/azureml-examples-main/sdk/jobs/automl-standalone-jobs/automl-image-object-detection-task-fridge-items/automl-image-object-detection-task-fridge-items.ipynb?name=deploy)]
637672
---
@@ -641,31 +676,35 @@ readiness_probe:
641676

642677
Using the `MLClient` created earlier, we'll now create the deployment in the workspace. This command will start the deployment creation and return a confirmation response while the deployment creation continues.
643678

644-
# [CLI v2](#tab/CLI-v2)
679+
# [Azure CLI](#tab/cli)
645680

646681
[!INCLUDE [cli v2](../../includes/machine-learning-cli-v2.md)]
647682

648683
```azurecli
649684
az ml online-deployment create --file .\create_deployment.yml --workspace-name [YOUR_AZURE_WORKSPACE] --resource-group [YOUR_AZURE_RESOURCE_GROUP] --subscription [YOUR_AZURE_SUBSCRIPTION]
650685
```
651686

652-
# [Python SDK v2 (preview)](#tab/SDK-v2)
687+
# [Python SDK](#tab/python)
688+
689+
[!INCLUDE [sdk v2](../../includes/machine-learning-sdk-v2.md)]
653690

654691
[!Notebook-python[] (~/azureml-examples-main/sdk/jobs/automl-standalone-jobs/automl-image-object-detection-task-fridge-items/automl-image-object-detection-task-fridge-items.ipynb?name=create_deploy)]
655692
---
656693

657694
### update traffic:
658695
By default the current deployment is set to receive 0% traffic. you can set the traffic percentage current deployment should receive. Sum of traffic percentages of all the deployments with one end point shouldn't exceed 100%.
659696

660-
# [CLI v2](#tab/CLI-v2)
697+
# [Azure CLI](#tab/cli)
661698

662699
[!INCLUDE [cli v2](../../includes/machine-learning-cli-v2.md)]
663700

664701
```azurecli
665702
az ml online-endpoint update --name 'od-fridge-items-endpoint' --traffic 'od-fridge-items-mlflow-deploy=100' --workspace-name [YOUR_AZURE_WORKSPACE] --resource-group [YOUR_AZURE_RESOURCE_GROUP] --subscription [YOUR_AZURE_SUBSCRIPTION]
666703
```
667704

668-
# [Python SDK v2 (preview)](#tab/SDK-v2)
705+
# [Python SDK](#tab/python)
706+
707+
[!INCLUDE [sdk v2](../../includes/machine-learning-sdk-v2.md)]
669708

670709
[!Notebook-python[] (~/azureml-examples-main/sdk/jobs/automl-standalone-jobs/automl-image-object-detection-task-fridge-items/automl-image-object-detection-task-fridge-items.ipynb?name=update_traffic)]
671710
---
@@ -707,12 +746,15 @@ Review detailed code examples and use cases in the [GitHub notebook repository f
707746

708747

709748
## Code examples
710-
# [CLI v2](#tab/CLI-v2)
749+
750+
# [Azure CLI](#tab/cli)
711751

712752
Review detailed code examples and use cases in the [azureml-examples repository for automated machine learning samples](https://github.com/Azure/azureml-examples/tree/sdk-preview/cli/jobs/automl-standalone-jobs).
713753

714754

715-
# [Python SDK v2 (preview)](#tab/SDK-v2)
755+
# [Python SDK](#tab/python)
756+
757+
[!INCLUDE [sdk v2](../../includes/machine-learning-sdk-v2.md)]
716758

717759
Review detailed code examples and use cases in the [GitHub notebook repository for automated machine learning samples](https://github.com/Azure/azureml-examples/tree/sdk-preview/sdk/jobs/automl-standalone-jobs).
718760

0 commit comments

Comments
 (0)