Skip to content

Commit 9039260

Browse files
committed
add notebook option for cusvis export
1 parent 63ba5d2 commit 9039260

File tree

2 files changed

+70
-3
lines changed

2 files changed

+70
-3
lines changed

articles/cognitive-services/Computer-vision/how-to/coco-verification.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ check_coco_annotation_file(json.loads(coco_file_path.read_text()), annotation_ki
4242

4343
## Use COCO file in a new project
4444

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 a COCO file—you can follow the guide from there to the end.
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—you can follow the guide from there to the end.
4646

4747
## Next steps
4848

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

Lines changed: 69 additions & 2 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—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—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,9 +318,11 @@ 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

0 commit comments

Comments
 (0)