Skip to main content

annotation factory python sdk

Project description

Introduction

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.

Build Status

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

annotationfactory-0.0.1.dev127-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file annotationfactory-0.0.1.dev127-py3-none-any.whl.

File metadata

  • Download URL: annotationfactory-0.0.1.dev127-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.0

File hashes

Hashes for annotationfactory-0.0.1.dev127-py3-none-any.whl
Algorithm Hash digest
SHA256 dabe1aeb3ad48b4d2e3431c87720dc0659de915c4936f5edcecb35afc158cf5a
MD5 1c00683f49f040cbe5e4d06fe27387d1
BLAKE2b-256 d37b0a17ca93e355acee23665d0700a615f600123defb9600997810d26d14b2b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page