Simple Python package for converting between CustomVision <-> Pascal VOC <-> YOLO annotations
Перейти к файлу
microsoft-github-policy-service[bot] f561f0db87
Auto merge mandatory file pr
This pr is auto merged as it contains a mandatory file and is opened for more than 10 days.
2022-11-28 19:10:27 +00:00
annotationfactory Transferring project. 2019-03-04 10:27:44 +11:00
example Transferring project. 2019-03-04 10:27:44 +11:00
.gitignore Initial commit 2019-02-27 19:30:03 -08:00
LICENSE Transferring project. 2019-03-04 10:27:44 +11:00
README.md Updated status badge. 2019-05-26 15:43:30 +10:00
SECURITY.md Microsoft mandatory file 2022-08-12 16:22:34 +00:00
azure-pipelines.yml Transferring project. 2019-03-04 10:27:44 +11:00
requirements.txt Transferring project. 2019-03-04 10:27:44 +11:00
setup.py Transferring project. 2019-03-04 10:27:44 +11:00

README.md

Introduction

Build Status GitHub PyPI Python Version

Annotation-Factory Python SDK. This package works specifically with Microsoft Cognitive Services detection results. AnnotationWriter takes a JSON object received from Cognitive Services and produces annotation files in both VOC and YOLO formats for use in training machine learning models.

Getting Started

  1. Install annotationfactory package via pip:

    pip install annotationfactory
    

Sample to use

from annotationfactory.annotationwriter import AnnotationWriter
import annotationfactory.annotationconverter as converter

example = {
    'tagId': 0,
    'tagName': 'Apples',
    'region': {
        'left': 0.288039029,
        'top': 0.411838,
        'width': 0.291451037,
        'height': 0.4237842
    }
}

# Initialise AnnotationWriter.
writer = AnnotationWriter()

# Initialise annotation handlers.
writer.initVoc("test.jpg", 608, 608)
writer.initYolo()

# Add VOC object to writer.
writer.addVocObject(example)
writer.addVocObject(example)

# Add YOLO object to writer.
writer.addYoloObject(example)
writer.addYoloObject(example)

# Output VOC annotations to file.
writer.saveVoc("myannotation.xml")

# Output YOLO annotations to file.
writer.saveYolo("myannotation.txt")

# Converts VOC annotations back to CustomVision annotation format.
voc2cv = converter.convertVocFromPath("myannotation.xml")

# Converts YOLO annotations back to CustomVision annotation format.
# Requires a txt file with list of label names as an input.
yolo2cv = converter.convertYoloFromPath("myannotation.txt", "class.names")

Run locally

pip install -r requirements.txt 
python example/test.py

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.