Skip to main content

Generate xml annotations for TensorFlow object detection models.

Project description

auto-annotate-logo

Auto Annotation Tool for TensorFlow Object Detection

Are you tired to label your images by hand when working with object detection? Have hundreds or thousands of images to label? Then this project will make your life easier, just create some annotations and let the machine do the rest for you!

Contents

🤔 How it works

This auto annotation tool is based on the idea of a semi-supervised architecture, where a model trained with a small amount of labeled data is used to produce the new labels for the rest of the dataset.

As simple as that, the library uses an initial and simplified object detection model to generate the XML files with the image annotations (considering the PASCAL VOC format). Besides that, it's possible to define a confidence threshold for the detector, acting as a trade-off for the generated predictions.

If you want to know more technical details about the project, please, refer to my Medium article.

📝 Prerequisites

To use this library you will need a pre-trained object detection model with a subsample of your dataset. As a semi-supervised solution, it's impossible to avoid manual annotation, but you'll need to label just a small amount of your data.

It's hard to determine the number of images to label manually, once it depends on the complexity of your problem. If you want to detect dogs and cats and have 2000 images in your dataset, for example, probably 200 images are enough (100 per class). On the other hand, if you have dozens of classes or objects that are hard to detect, you should need more manual annotations to see the benefits of the semi-supervised approach.

After training this initial model, export your best checkpoint to the SavedModel format and you'll be ready to use the auto annotation tool!

💾 Installation

It's recommended to use a Python virtual environment to avoid any compatibility issue with your TensorFlow version.

In your environment, you can install the project using pip:

$ pip install auto-annotate

👨‍🔬 Usage

You can use this tool either from the command line or directly in your Python code. For both, you'll have the same set of parameters:

  • saved_model_path: The path of the saved_model folder with the initial model.
  • label_map_path: The path of the label_map.pbtxt file.
  • imgs_path: The path of the folder with your dataset images to label.
  • xml_path (optional): Path to save the resulting XML files. The default behavior is to save in the same folder of the dataset images.
  • threshold: Confidence threshold to accept the detections made by the model. the defaults is 0.5.

Command line

To use this tool from the command line, you just need to run:

python -m auto_annotate --label_map_path /example/label_map.pbtxt \
--saved_model_path /example/saved_model \
--imgs_path /example/dataset_images \
--xml_path /example/dataset_labels \
--threshold 0.65

Code

To use this tool from your Python code, check the following code snippet:

from auto_annotate import AutoAnnotate

ann_tool = AutoAnnotate(
              saved_model_path = '/example/saved_model',
              label_map_path = '/example/label_map.pbtxt',
              images_path = '/example/dataset_images',
              xml_path = '/example/dataset_labels',
              detection_threshold = 0.65)

ann_tool.generate_annotations()

🤝 Contribute

Contributions are welcome! Feel free to open a new issue if you have any problem to use the library of find a bug!

You can also use the discussions section to suggest improvements and ask questions!

Project details


Download files

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

Source Distribution

auto_annotate-1.0.5.tar.gz (46.7 kB view details)

Uploaded Source

Built Distribution

auto_annotate-1.0.5-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file auto_annotate-1.0.5.tar.gz.

File metadata

  • Download URL: auto_annotate-1.0.5.tar.gz
  • Upload date:
  • Size: 46.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.10

File hashes

Hashes for auto_annotate-1.0.5.tar.gz
Algorithm Hash digest
SHA256 a04f88eb2603cc149f22341f43cb388cf2ef736af8a33ebd102abdfcc0749e3d
MD5 02357c6ff1f51070b4e85b6280d82a71
BLAKE2b-256 a4235203b9000514082477c146da3f3296313cb12d4fc8504866eb5eb9ccdb05

See more details on using hashes here.

File details

Details for the file auto_annotate-1.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for auto_annotate-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 df9292f342eec8bff7386c78eaec4b9375cfc7062be6635a503f45f98fc6ad9d
MD5 f9129128173f1e218adea44bb47deef8
BLAKE2b-256 9d1082be79cf3c55800e94605ff5a2bf3799ffe0004014424424796a0f28f73d

See more details on using hashes here.

Supported by

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