Skip to content

Commit 7376b35

Browse files
Merge pull request #230622 from PatrickFarley/comvis-4
[cog svcs] model customization addtl docs
2 parents 4073ac9 + d1723b1 commit 7376b35

File tree

9 files changed

+354
-268
lines changed

9 files changed

+354
-268
lines changed

articles/cognitive-services/Computer-vision/concept-model-customization.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ In order to train your model effectively, use images with visual variety. Select
4444

4545
Additionally, make sure all of your training images meet the following criteria:
4646

47-
- The image must be presented in JPEG, PNG, GIF, BMP, WEBP, ICO, TIFF, or MPO format
48-
- The file size of the image must be less than 20 megabytes (MB)
49-
- The dimensions of the image must be greater than 50 x 50 pixels and less than 16,000 x 16,000 pixels
47+
- The image must be presented in JPEG, PNG, GIF, BMP, WEBP, ICO, TIFF, or MPO format.
48+
- The file size of the image must be less than 20 megabytes (MB).
49+
- The dimensions of the image must be greater than 50 x 50 pixels and less than 16,000 x 16,000 pixels.
5050

5151
### COCO file
5252

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
title: Verify a COCO annotation file
3+
titleSuffix: Azure Cognitive Services
4+
description: Use a Python script to verify your COCO file for custom model training.
5+
services: cognitive-services
6+
author: PatrickFarley
7+
manager: nitinme
8+
ms.service: cognitive-services
9+
ms.topic: how-to
10+
ms.date: 03/21/2023
11+
ms.author: pafarley
12+
---
13+
14+
# Check the format of your COCO annotation file
15+
16+
<!-- nbstart https://raw.githubusercontent.com/Azure-Samples/cognitive-service-vision-model-customization-python-samples/main/docs/check_coco_annotation.ipynb -->
17+
18+
> [!TIP]
19+
> Contents of _check_coco_annotation.ipynb_. **[Open in GitHub](https://github.com/Azure-Samples/cognitive-service-vision-model-customization-python-samples/blob/main/docs/check_coco_annotation.ipynb)**.
20+
21+
This notebook demonstrates how to check if the format of your annotation file is correct. First, install the python samples package from the command line:
22+
23+
```python
24+
pip install cognitive-service-vision-model-customization-python-samples
25+
```
26+
27+
Then, run the following python code to check the file's format. You can either enter this code in a Python script, or run the [Jupyter Notebook](https://github.com/Azure-Samples/cognitive-service-vision-model-customization-python-samples/blob/main/docs/check_coco_annotation.ipynb) on a compatible platform.
28+
29+
```python
30+
from cognitive_service_vision_model_customization_python_samples import check_coco_annotation_file, AnnotationKind, Purpose
31+
import pathlib
32+
import json
33+
34+
coco_file_path = pathlib.Path("{your_coco_file_path}")
35+
annotation_kind = AnnotationKind.MULTICLASS_CLASSIFICATION # or AnnotationKind.OBJECT_DETECTION
36+
purpose = Purpose.TRAINING # or Purpose.EVALUATION
37+
38+
check_coco_annotation_file(json.loads(coco_file_path.read_text()), annotation_kind, purpose)
39+
```
40+
41+
<!-- nbend -->
42+
43+
## Use COCO file in a new project
44+
45+
Once your COCO file is verified, you're ready to import it to your model customization project. See [Create and train a custom model](model-customization.md) and go to the section on selecting/importing a COCO file&mdash;you can follow the guide from there to the end.
46+
47+
## Next steps
48+
49+
* [Create and train a custom model](model-customization.md)

articles/cognitive-services/Computer-vision/how-to/migrate-from-custom-vision.md

Lines changed: 70 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ ms.author: pafarley
1515

1616
You can migrate an existing Azure Custom Vision project to the new Image Analysis 4.0 system. [Custom Vision](../../custom-vision-service/overview.md) is a model customization service that existed before Image Analysis 4.0.
1717

18-
This guide uses a Python script to take all of the training data from an existing Custom Vision project (images and their label data) and convert it to a COCO file. You can then import the COCO file into Vision Studio to train a custom model. See [Create and train a custom model](model-customization.md) and go to the section on importing a COCO file&mdash;you can follow the guide from there to the end.
18+
This guide uses Python code to take all of the training data from an existing Custom Vision project (images and their label data) and convert it to a COCO file. You can then import the COCO file into Vision Studio to train a custom model. See [Create and train a custom model](model-customization.md) and go to the section on importing a COCO file&mdash;you can follow the guide from there to the end.
1919

2020
## Prerequisites
2121

@@ -24,6 +24,71 @@ This guide uses a Python script to take all of the training data from an existin
2424
* A Custom Vision resource where an existing project is stored.
2525
* An Azure Storage resource - [Create one](../../../storage/common/storage-account-create.md?tabs=azure-portal)
2626

27+
#### [Jupyter Notebook](#tab/notebook)
28+
29+
This notebook exports your image data and annotations from the workspace of a Custom Vision Service project to your own COCO file in a storage blob, ready for training with Image Analysis Model Customization. You can run the code in this section using a custom Python script, or you can download and run the [Notebook](https://github.com/Azure-Samples/cognitive-service-vision-model-customization-python-samples/blob/main/docs/export_cvs_data_to_blob_storage.ipynb) on a compatible platform.
30+
31+
<!-- nbstart https://raw.githubusercontent.com/Azure-Samples/cognitive-service-vision-model-customization-python-samples/main/docs/export_cvs_data_to_blob_storage.ipynb -->
32+
33+
> [!TIP]
34+
> Contents of _export_cvs_data_to_blob_storage.ipynb_. **[Open in GitHub](https://github.com/Azure-Samples/cognitive-service-vision-model-customization-python-samples/blob/main/docs/export_cvs_data_to_blob_storage.ipynb)**.
35+
36+
37+
## Install the python samples package
38+
39+
Run the following command to install the required python samples package:
40+
41+
```python
42+
pip install cognitive-service-vision-model-customization-python-samples
43+
```
44+
45+
## Authentication
46+
47+
Next, provide the credentials of your Custom Vision project and your blob storage container.
48+
49+
You need to fill in the correct parameter values. You need the following information:
50+
51+
- The name of the Azure Storage account you want to use with your new custom model project
52+
- The key for that storage account
53+
- The name of the container you want to use in that storage account
54+
- Your Custom Vision training key
55+
- Your Custom Vision endpoint URL
56+
- The project ID of your Custom Vision project
57+
58+
The Azure Storage credentials can be found on that resource's page in the Azure portal. The Custom Vision credentials can be found in the Custom Vision project settings page on the [Custom Vision web portal](https://customvision.ai).
59+
60+
61+
```python
62+
azure_storage_account_name = ''
63+
azure_storage_account_key = ''
64+
azure_storage_container_name = ''
65+
66+
custom_vision_training_key = ''
67+
custom_vision_endpoint = ''
68+
custom_vision_project_id = ''
69+
```
70+
71+
## Run the migration
72+
73+
When you run the migration code, the Custom Vision training images will be saved to a `{project_name}_{project_id}/images` folder in your specified Azure blob storage container, and the COCO file will be saved to `{project_name}_{project_id}/train.json` in that same container. Both tagged and untagged images will be exported, including any **Negative**-tagged images.
74+
75+
> [!IMPORTANT]
76+
> Image Analysis Model Customization does not currently support **multilabel** classification training, buy you can still export data from a Custom Vision multilabel classification project.
77+
78+
```python
79+
from cognitive_service_vision_model_customization_python_samples import export_data
80+
import logging
81+
logging.getLogger().setLevel(logging.INFO)
82+
logging.getLogger('azure.core.pipeline.policies.http_logging_policy').setLevel(logging.WARNING)
83+
84+
n_process = 8
85+
export_data(azure_storage_account_name, azure_storage_account_key, azure_storage_container_name, custom_vision_endpoint, custom_vision_training_key, custom_vision_project_id, n_process)
86+
```
87+
88+
<!-- nbend -->
89+
90+
#### [Python](#tab/python)
91+
2792
## Install libraries
2893

2994
This script requires certain Python libraries. Install them in your project directory with the following command.
@@ -253,10 +318,12 @@ You need to fill in the correct parameter values. You need the following informa
253318
- The key for that storage account
254319
- The name of the container you want to use in that storage account
255320

321+
---
322+
256323
## Use COCO file in a new project
257324

258-
The script generates a COCO file and uploads it to the blob storage location you specified. You can now import it to your model customization project. See [Create and train a custom model](model-customization.md) and go to the section on selecting a COCO file&mdash;you can follow the guide from there to the end.
325+
The script generates a COCO file and uploads it to the blob storage location you specified. You can now import it to your Model Customization project. See [Create and train a custom model](model-customization.md) and go to the section on selecting/importing a COCO file&mdash;you can follow the guide from there to the end.
259326

260327
## Next steps
261328

262-
* [Create and train a custom model](model-customization.md)
329+
* [Create and train a custom model](model-customization.md)

0 commit comments

Comments
 (0)