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.4.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

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

coco_lib-0.1.4-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file coco_lib-0.1.4.tar.gz.

File metadata

  • Download URL: coco_lib-0.1.4.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.8.0-48-generic

File hashes

Hashes for coco_lib-0.1.4.tar.gz
Algorithm Hash digest
SHA256 710bf5e88ac3889a71327f94cb13900514cf26329f5a3ef63e35f2f80d2ecb1d
MD5 5b9a4f7993f58383c10210cd834d398a
BLAKE2b-256 0b981e3991564d219168883f799e476e2f7df348f103ea4f261ac0207e5a942a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: coco_lib-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.8.0-48-generic

File hashes

Hashes for coco_lib-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 03e1cc892b809ab0af6dfb959b8a9852a67853cb29dde6550b068ca311e78642
MD5 7e7d672c72ea4a84ef4d9a9fad19cceb
BLAKE2b-256 943dde6013aacdf5daa27553bc8ced5d9580dc6204440248e02a44886ce14bfe

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