No project description provided
Project description
Annotstein
annotstein
provides lightweight and modular endpoints to common annotation operations, like rebasing file paths, converting coordinates from absolute to relative, etc.
NOTE: this library is unstable and under active development.
Library
Currently, the lib allows to manipulate COCO, PASCAL-VOC and ultralytics YOLO datasets through object-oriented and functional APIs. The COCO format is used as the exchange format to manipulate annotations, i.e. most operations on VOC and YOLO datasets transform the dataset to COCO as an intermediate, in-memory step.
These APIs allow to perform multiple operations on a dataset, like converting from one format to another, merge multiple datasets, extract crops based on bboxes, etc.
Classes under annotstein.{coco,voc,yolo}.schemas
provide validation using pydantic models. These classes can be sub-classed to add extra-validation (e.g. specific categories are expected) and still work with the functional APIs, see examples/subclassing.py.
CLI
Convert
The convert
command allows to convert between annotation formats.
# Convert VOC to COCO
convert -s voc -t coco -i voc/ -o coco.json
# Convert COCO to VOC
convert -s coco -t voc -i coco.json -o voc/
# Convert YOLO-segment (https://docs.ultralytics.com/datasets/segment/) to COCO
convert -s yolo-segment-task -t coco -i dataset.yaml -o coco.json
# Convert COCO to YOLO-segment
convert -s coco -t yolo-segment-task -i coco.json -t dataset.yaml
# Convert YOLO-detect (https://docs.ultralytics.com/datasets/detect/) to COCO
convert -s yolo-detect-task -t coco -i dataset.yaml -o coco.json
# Convert COCO to YOLO-detect
convert -s coco -t yolo-detect-task -i coco.json -o dataset.yaml
Since VOC and YOLO require annotations to exist as individual text files along with the images they describe, the flags --symlink|--copy|--move
in the convert
command allow to select how images will be processed.
COCO operations
The following operations can be performed on COCO datasets, using the coco
subcommand:
- Transform coordinates from absolute to relative, and vice verse (
coordinates
) - Merge multiple COCO datasets into a single one (
merge
) - Extract image patches into a
category_id
-based file tree (crop
) - Rebase a given dataset images'
file_name
s (rebase
) - Compute some stats (e.g. category instance count) (
stats
) - Split a COCO dataset into train and test datasets (
split
)
Uses
The aim of this project is to allow simple manipulation of CV datasets through the API or the CLI. Moreover, it can also be used in CI/CD or applications steps to validate that annotations are coherent (e.g. validate COCO dataset's bboxes and segmentations, validate annotations refer to existing images, etc).
You can obviously use it for whatever you want!
Roadmap
- Integration with CVOps tooling (e.g. CVAT, FiftyOne)
- Add missing operations for YOLO datasets
- Add more utility functions for COCO datasets
References
- COCO challenge and dataset
- Pascal-VOC challenge and dataset
- Ultralytics YOLO-detect and YOLO-segment
hiddendocs
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file annotstein-0.1.1.tar.gz
.
File metadata
- Download URL: annotstein-0.1.1.tar.gz
- Upload date:
- Size: 15.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.10.10 Linux/6.5.0-25-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2fe17acc601e97a10ac13634ead92010be090d42584b2d47ff620f488202cd4 |
|
MD5 | 7db1ccb78c9541235d21e9c64950861b |
|
BLAKE2b-256 | c27000156afeb1e68a2239f35ad300d1c5cda19beb85c08b1dacdecb06a307ba |
File details
Details for the file annotstein-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: annotstein-0.1.1-py3-none-any.whl
- Upload date:
- Size: 20.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.10.10 Linux/6.5.0-25-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c4b52f68f31a83ce973efd76b245787a30d2de78f78c684fcc1bc87eed3186e |
|
MD5 | cf5dab566fc62c11aeba65f01b449860 |
|
BLAKE2b-256 | 18fef0b2d5e33858077da9639bf5b66836dd45fb4eb0d6175f4490e39eee4ae3 |