Skip to main content

COCO dataset library.

Project description

coco-lib

COCO dataset library. Provides serializable native Python bindings for several COCO dataset formats.

Supported bindings and their corresponding modules:

  • Object Detection: objectdetection
  • Keypoint Detection: keypointdetection
  • Panoptic Segmentation: panopticsegmentation
  • Image Captioning: imagecaptioning

Installation

coco-lib is available on PyPI:

pip install coco-lib

Usage

Creating a dataset (Object Detection)

>>> from coco_lib.common import Info, Image, License
>>> from coco_lib.objectdetection import ObjectDetectionAnnotation, \
...                                      ObjectDetectionCategory, \
...                                      ObjectDetectionDataset
>>> from datetime import datetime
>>> info = Info(  # Describe the dataset
...    year=datetime.now().year, 
...    version='1.0', 
...    description='This is a test dataset', 
...    contributor='Test', 
...    url='https://test', 
...    date_created=datetime.now()
... )
>>> mit_license = License(  # Set the license
...     id=0, 
...     name='MIT', 
...     url='https://opensource.org/licenses/MIT'
... )
>>> images = [  # Describe the images
...     Image(
...         id=0, 
...         width=640, height=480, 
...         file_name='test.jpg', 
...         license=mit_license.id,
...         flickr_url='',
...         coco_url='',
...         date_captured=datetime.now()
...     ),
...     ...
... ]
>>> categories = [  # Describe the categories
...     ObjectDetectionCategory(
...         id=0,
...         name='pedestrian',
...         supercategory=''
...     ),
...     ...
... ]
>>> annotations = [  # Describe the annotations
...     ObjectDetectionAnnotation(
...         id=0,
...         image_id=0,
...         category_id=0,
...         segmentation=[],
...         area=800.0,
...         bbox=[300.0, 100.0, 20.0, 40.0],
...         is_crowd=0
...     ),
...     ...
... ]
>>> dataset = ObjectDetectionDataset(  # Create the dataset
...     info=info,
...     images=images,
...     licenses=[mit_license],
...     categories=categories,
...     annotations=annotations
... )
>>> dataset.save('test_dataset.json', indent=2)  # Save the dataset

Loading a dataset

>>> from coco_lib.objectdetection import ObjectDetectionDataset
>>> dataset = ObjectDetectionDataset.load('test_dataset.json')  # Load the dataset

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

coco-lib-0.1.3.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

coco_lib-0.1.3-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file coco-lib-0.1.3.tar.gz.

File metadata

  • Download URL: coco-lib-0.1.3.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.9.5 Linux/5.13.0-48-generic

File hashes

Hashes for coco-lib-0.1.3.tar.gz
Algorithm Hash digest
SHA256 23f50cdd4f8d93bd55e7fb6cbbe7559930b6fa27cfeedf81160db6a7e3c47286
MD5 863a25f29d209fc4f12a2863d4cd0c8d
BLAKE2b-256 74fecbc0bc19e7f853ebf49560ddbb37855bc409df28bf92ba86b38ac26d83b2

See more details on using hashes here.

File details

Details for the file coco_lib-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: coco_lib-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.9.5 Linux/5.13.0-48-generic

File hashes

Hashes for coco_lib-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 68c2c45a8e84dfb9000bf6ee20922b92d3c7f32c8295bcdb04824161167a1446
MD5 0e184818362d9f0b4082be41b828fed6
BLAKE2b-256 7b5c8f14e0839b49a262cd0fda202287b02600e54c56b4aaf1ec09b5938c99b3

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