Small library to do transformations of Coco Datasets. A couple of transformations are already implemented, see below.
- Only works with Run Length Encoded (RLE) annotations at the moment!
- If an annotation is cut in the process, even very tiny annotations are kept.
- The specified versions of numpy, pycocotools and Pillow seem to work nicely together. But newer versions might work as well.
Create a python environment and install dependencies:
python -m venv venv
source venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
then set environment variables ANNOTATION_PATH, IMAGES_PATH, OUTPUT_PATH and choose
the correct transformation by uncommenting it in main.py.
then run python main.py.
The following transformations are implemented, more can easily be implemented by writing respecting Transform classes.
Tiling is done in a non-overlapping way. All annotations are kept, even if they are tiny after cutting.
The image and annotations are resized according to a scaling factor.
The exemplary dataset has exactly one frame per image that represents a frame in which all annotations are. This transformation fits a maximum size square into the image and cuts all annotations accordingly.
This transform could remove annotations that are smaller than a given size.
Author: Tim Wessels, Bundesamt für Verbraucherschutz und Lebensmittelsicherheit, im Auftrag von KIDA
Example dataset provided by Christoph Kämpfer, Julius Kühn-Institut