Skip to content

Commit eb8ee73

Browse files
committed
add coco verification how-to
1 parent f0d79a6 commit eb8ee73

File tree

4 files changed

+57
-2
lines changed

4 files changed

+57
-2
lines changed
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+
<!-- nbstart https://raw.githubusercontent.com/Azure-Samples/cognitive-service-vision-model-customization-python-samples/main/docs/check_coco_annotation.ipynb -->
15+
16+
> [!TIP]
17+
> 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)**.
18+
19+
# Check the format of your COCO annotation file
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 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/model-customization.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Note that
8888

8989
- Image Analysis model customization for classification is different from other kinds of vision training, as we utilize your class names, as well as image data, in training. So, be sure provide meaningful category names in the annotations.
9090
- Note that in the example dataset, there are few images for the sake of simplicity. Although [Florence models](https://www.microsoft.com/en-us/research/publication/florence-a-new-foundation-model-for-computer-vision/) achieve great few-shot performance (high model quality even with little data available), it's good to have more data for the model to learn. Our recommendation is to have at least five images per class, and the more the better.
91-
- Once your COCO annotation file is prepared, you can use the [COCO file verification script](tbd) to check the format.
91+
- Once your COCO annotation file is prepared, you can use the [COCO file verification script](coco-verification.md) to check the format.
9292

9393
#### Multiclass classification example
9494

articles/cognitive-services/Computer-vision/includes/coco-files.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,8 @@ The value for `absolute_url` can be found in your blob container's properties:
118118
| Key | Type | Description | Required? |
119119
|-|-|-|-|
120120
| `id` | integer | Unique ID for each category (label class). These should be present in the `annotations` section. | Yes |
121-
| `name`| string | Name of the category (label class) | Yes |
121+
| `name`| string | Name of the category (label class) | Yes |
122+
123+
### COCO file verification
124+
125+
You can use our [Python sample code](/azure/cognitive-services/computer-vision/how-to/coco-verification) to check the format of a COCO file.

articles/cognitive-services/Computer-vision/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ items:
146146
href: how-to/model-customization.md
147147
- name: Migrate a Custom Vision project to Image Analysis
148148
href: how-to/migrate-from-custom-vision.md
149+
- name: Verify a custom model COCO file
150+
href: how-to/coco-verification.md
149151
- name: Call the Image retrieval APIs
150152
href: how-to/image-retrieval.md
151153
- name: Call the Background removal API

0 commit comments

Comments
 (0)