Skip to main content

Dataset Management Framework (Datumaro)

Project description

Dataset Management Framework (Datumaro)

Build status Codacy Badge Codacy Badge

A framework and CLI tool to build, transform, and analyze datasets.

VOC dataset                                  ---> Annotation tool
     +                                     /
COCO dataset -----> Datumaro ---> dataset ------> Model training
     +                                     \
CVAT annotations                             ---> Publication, statistics etc.

Table of Contents

Examples

(Back to top)

  • Convert PASCAL VOC dataset to COCO format, keep only images with cat class presented:

    # Download VOC dataset:
    # http://host.robots.ox.ac.uk/pascal/VOC/voc2012/VOCtrainval_11-May-2012.tar
    datum convert --input-format voc --input-path <path/to/voc> \
                  --output-format coco \
                  --filter '/item[annotation/label="cat"]' \
                  -- --reindex 1 # avoid annotation id conflicts
    
  • Convert only non-occluded annotations from a CVAT project to TFrecord:

    # export Datumaro dataset in CVAT UI, extract somewhere, go to the project dir
    datum filter -e '/item/annotation[occluded="False"]' \
      --mode items+anno --output-dir not_occluded
    datum export --project not_occluded \
      --format tf_detection_api -- --save-images
    
  • Annotate MS COCO dataset, extract image subset, re-annotate it in CVAT, update old dataset:

    # Download COCO dataset http://cocodataset.org/#download
    # Put images to coco/images/ and annotations to coco/annotations/
    datum import --format coco --input-path <path/to/coco>
    datum export --filter '/image[images_I_dont_like]' --format cvat \
      --output-dir reannotation
    # import dataset and images to CVAT, re-annotate
    # export Datumaro project, extract to 'reannotation-upd'
    datum merge reannotation-upd
    datum export --format coco
    
  • Annotate instance polygons in CVAT, export as masks in COCO:

    datum convert --input-format cvat --input-path <path/to/cvat.xml> \
                  --output-format coco -- --segmentation-mode masks
    
  • Apply an OpenVINO detection model to some COCO-like dataset, then compare annotations with ground truth and visualize in TensorBoard:

    datum import --format coco --input-path <path/to/coco>
    # create model results interpretation script
    datum model add mymodel openvino \
      --weights model.bin --description model.xml \
      --interpretation-script parse_results.py
    datum model run --model mymodel --output-dir mymodel_inference/
    datum diff mymodel_inference/ --format tensorboard --output-dir diff
    
  • Change colors in PASCAL VOC-like .png masks:

    datum import --format voc --input-path <path/to/voc/dataset>
    
    # Create a color map file with desired colors:
    #
    # label : color_rgb : parts : actions
    # cat:0,0,255::
    # dog:255,0,0::
    #
    # Save as mycolormap.txt
    
    datum export --format voc_segmentation -- --label-map mycolormap.txt
    # add "--apply-colormap=0" to save grayscale (indexed) masks
    # check "--help" option for more info
    # use "datum --loglevel debug" for extra conversion info
    
  • Create a custom COCO-like dataset:

    import numpy as np
    from datumaro.components.extractor import (DatasetItem,
      Bbox, LabelCategories, AnnotationType)
    from datumaro.components.dataset import Dataset
    
    dataset = Dataset(categories={
      AnnotationType.label: LabelCategories.from_iterable(['cat', 'dog'])
    })
    dataset.put(DatasetItem(id=0, image=np.ones((5, 5, 3)), annotations=[
      Bbox(1, 2, 3, 4, label=0),
    ]))
    dataset.export('test_dataset', 'coco')
    

Features

(Back to top)

  • Dataset reading, writing, conversion in any direction. Supported formats:
  • Dataset building
    • Merging multiple datasets into one
    • Dataset filtering by a custom criteria:
      • remove polygons of a certain class
      • remove images without annotations of a specific class
      • remove occluded annotations from images
      • keep only vertically-oriented images
      • remove small area bounding boxes from annotations
    • Annotation conversions, for instance:
      • polygons to instance masks and vice-versa
      • apply a custom colormap for mask annotations
      • rename or remove dataset labels
    • Splitting a dataset into multiple subsets like train, val, and test:
      • random split
      • task-specific splits based on annotations, which keep initial label and attribute distributions
        • for classification task, based on labels
        • for detection task, based on bboxes
        • for re-identification task, based on labels, avoiding having same IDs in training and test splits
    • Sampling a dataset
      • analyzes inference result from the given dataset and selects the ‘best’ and the ‘least amount of’ samples for annotation.
      • Select the sample that best suits model training.
        • sampling with Entropy based algorithm
  • Dataset quality checking
    • Simple checking for errors
    • Comparison with model inference
    • Merging and comparison of multiple datasets
    • Annotation validation based on the task type(classification, etc)
  • Dataset comparison
  • Dataset statistics (image mean and std, annotation statistics)
  • Model integration
    • Inference (OpenVINO, Caffe, PyTorch, TensorFlow, MxNet, etc.)
    • Explainable AI (RISE algorithm)
      • RISE for classification
      • RISE for object detection

Check the design document for a full list of features. Check the user manual for usage instructions.

Installation

(Back to top)

Dependencies

  • Python (3.6+)
  • Optional: OpenVINO, TensforFlow, PyTorch, MxNet, Caffe, Accuracy Checker

Optionally, create a virtual environment:

python -m pip install virtualenv
python -m virtualenv venv
. venv/bin/activate

Install Datumaro package:

pip install datumaro

Usage

(Back to top)

There are several options available:

Standalone tool

Datuaro as a standalone tool allows to do various dataset operations from the command line interface:

datum --help
python -m datumaro --help

Python module

Datumaro can be used in custom scripts as a Python module. Used this way, it allows to use its features from an existing codebase, enabling dataset reading, exporting and iteration capabilities, simplifying integration of custom formats and providing high performance operations:

from datumaro.components.project import Project

# load a Datumaro project
project = Project.load('directory')

# create a dataset
dataset = project.make_dataset()

# keep only annotated images
dataset.select(lambda item: len(item.annotations) != 0)

# change dataset labels
dataset.transform('remap_labels',
  {'cat': 'dog', # rename cat to dog
    'truck': 'car', # rename truck to car
    'person': '', # remove this label
  }, default='delete') # remove everything else

# iterate over dataset elements
for item in dataset:
  print(item.id, item.annotations)

# export the resulting dataset in COCO format
dataset.export('dst/dir', 'coco')

Check our developer guide for additional information.

Contributing

(Back to top)

Feel free to open an Issue, if you think something needs to be changed. You are welcome to participate in development, instructions are available in our contribution guide.

Project details


Release history Release notifications | RSS feed

This version

0.1.9

Download files

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

Source Distribution

datumaro-0.1.9.tar.gz (162.5 kB view details)

Uploaded Source

Built Distribution

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

datumaro-0.1.9-py3-none-any.whl (213.4 kB view details)

Uploaded Python 3

File details

Details for the file datumaro-0.1.9.tar.gz.

File metadata

  • Download URL: datumaro-0.1.9.tar.gz
  • Upload date:
  • Size: 162.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.6.5

File hashes

Hashes for datumaro-0.1.9.tar.gz
Algorithm Hash digest
SHA256 f5735e1dc83994115659c99090abbd7487bbc372437d4f7aa18d9b915405e807
MD5 2b245eb4f2ff663475e736d69657e418
BLAKE2b-256 8fee06d7a8a5ee6bbf3fa81fb61542b45891d54da712325936c6e3ab5fe9c000

See more details on using hashes here.

File details

Details for the file datumaro-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: datumaro-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 213.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.6.5

File hashes

Hashes for datumaro-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 d71da855339646bef21dd75ddf2e89f21463832d25492e06734b5247ff83193e
MD5 26a81a7d3e7e82f380e860850902d3d1
BLAKE2b-256 62c25da5ff40c63992f4dcf47ed90b4b0cc36ad0d7983406e278d333a0cd3453

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