Coder Social home page Coder Social logo

annotation-factory's Introduction

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 [email protected] with any additional questions or comments.

annotation-factory's People

Contributors

jasonthedeveloper avatar microsoft-github-policy-service[bot] avatar msftgits avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

annotation-factory's Issues

Possible to update for custom vision?

The json response I receive from custom vision detection project (v3.0 api) does not seem to work with annotation-factory.

I receive this error:
Failed validating 'type' in schema:

Is this correct or my error? Possible to update annotation-factory for the current custom vision api?

The conversion to VOC is wrong

Check the example/test.py :

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

and in the result VOC file myannotation.xml:
175.127729632
250.397504
177.20223049600003
257.6607936

It's obviously wrong unless 'xmax' here means 'width', and ‘ymax' means 'height'.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.