Skip to main content

Utilities for building and working with computer vision datasets

Project description

xt-cvdata

Description

This repo contains utilities for building and working with computer vision datasets, developed by Xtract AI.

So far, APIs for the following open-source datasets are included:

  1. COCO 2017 (detection and segmentation): xt_cvdata.apis.COCO
  2. Open Images V5 (detection and segmentation): xt_cvdata.apis.OpenImages
  3. Visual Object Tagging Tool (VoTT) CSV output (detection): xt_cvdata.apis.VoTTCSV

More to come.

Installation

From PyPI:

pip install xt-cvdata

From source:

git clone https://github.com/XtractTech/xt-cvdata.git
pip install ./xt-cvdata

Usage

See specific help on a dataset class using help. E.g., help(xt_cvdata.apis.COCO).

Building a dataset

from xt_cvdata.apis import COCO, OpenImages

# Build an object populated with the COCO image list, categories, and annotations
coco = COCO('/nasty/data/common/COCO_2017')
print(coco)
print(coco.class_distribution)

# Same for Open Images
oi = OpenImages('/nasty/data/common/open_images_v5')
print(oi)
print(coco.class_distribution)

# Get just the person classes
coco.subset(['person'])
oi.subset(['Person']).rename({'Person': 'person'})

# Merge and build
merged = coco.merge(oi)
merged.build('./data/new_dataset_dir')

This package follows pytorch chaining rules, meaning that methods operating on an object modify it in-place, but also return the modified object. The exception is the merge() method which does not modify in-place and returns a new merged object. Hence, the above operations can also be completed using:

from xt_cvdata.apis import COCO, OpenImages

merged = (
    COCO('/nasty/data/common/COCO_2017')
        .subset(['person'])
        .merge(
            OpenImages('/nasty/data/common/COCO_2017')
                .subset(['Person'])
                .rename({'Person': 'person'})
        )
)
merged.build('./data/new_dataset_dir')

In practice, somewhere between the two approaches will probably be most readable.

The current set of dataset operations are:

  • analyze: recalculate dataset statistics (e.g., class distributions, train/val split)
  • verify_schema: check if class attributes follow required schema
  • subset: remove all but a subset of classes from the dataset
  • rename: rename/combine dataset classes
  • sample: sample a specified number of images from the train and validation sets
  • split: define the proportion of data in the validation set
  • merge: merge two datasets together, returning merged dataset
  • build: create the currently defined dataset using either symlinks or by copying images

Implementing a new dataset type

New dataset types should inherit from the base xt_cvdata.Builder class. See the Builder, COCO and OpenImages classes as a guide. Specifically, the class initializer should define info, licenses, categories, annotations, and images attributes such that self.verify_schema() runs without error. This ensures that all of the methods defined in the Builder class will operate correctly on the inheriting class.

Data Sources

[descriptions and links to data]

Dependencies/Licensing

[list of dependencies and their licenses, including data]

References

[list of references]

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

xt-cvdata-0.6.1.tar.gz (14.7 kB view details)

Uploaded Source

Built Distribution

xt_cvdata-0.6.1-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

File details

Details for the file xt-cvdata-0.6.1.tar.gz.

File metadata

  • Download URL: xt-cvdata-0.6.1.tar.gz
  • Upload date:
  • Size: 14.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3.post20200330 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.3

File hashes

Hashes for xt-cvdata-0.6.1.tar.gz
Algorithm Hash digest
SHA256 4dd1b37d5f9c6ef98982cde407f70ab42dea6cacf90797a457ea5406fdf7fda3
MD5 552418f479a182a740510778dda0b371
BLAKE2b-256 db588305a1d79f4b3322e2fe251fd6a6eeb38253d794419a56ee48960eb13baf

See more details on using hashes here.

File details

Details for the file xt_cvdata-0.6.1-py3-none-any.whl.

File metadata

  • Download URL: xt_cvdata-0.6.1-py3-none-any.whl
  • Upload date:
  • Size: 17.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3.post20200330 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.3

File hashes

Hashes for xt_cvdata-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 46eace4cd666d98aa2324342e08da708b66f7f5692a7693d2e72ad11e6a9bc50
MD5 48bea3b15ffd70dcbd7462f1bf1fd782
BLAKE2b-256 a597f0218e357ee8d3d93901340742997f9d67800cf2d792ee552a2007392ba2

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