Check the format of your COCO annotation file
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
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for