Muokkaa

Jaa


Check the format of your COCO annotation file

Important

This feature is now deprecated. On January 10, 2025, Azure AI Image Analysis 4.0 Custom Image Classification, Custom Object Detection, and Product Recognition preview API will be retired. After this date, API calls to these services will fail.

To maintain a smooth operation of your models, transition to Azure AI Custom Vision, which is now generally available. Custom Vision offers similar functionality to these retiring features.

Tip

This article is based on the Jupyter notebook check_coco_annotation.ipynb. Open in GitHub.

This guide demonstrates how to check if the format of your annotation file is correct. First, install the python samples package from the command line:

pip install cognitive-service-vision-model-customization-python-samples

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 on a compatible platform.

from cognitive_service_vision_model_customization_python_samples import check_coco_annotation_file, AnnotationKind, Purpose
import pathlib
import json

coco_file_path = pathlib.Path("{your_coco_file_path}")
annotation_kind = AnnotationKind.MULTICLASS_CLASSIFICATION # or AnnotationKind.OBJECT_DETECTION
purpose = Purpose.TRAINING # or Purpose.EVALUATION

check_coco_annotation_file(json.loads(coco_file_path.read_text()), annotation_kind, purpose)

Use COCO file in a new project

Once your COCO file is verified, you're ready to import it to your model customization project. See Create and train a custom model and go to the section on selecting/importing a COCO file—you can follow the guide from there to the end.

Next steps