Skip to main content

Package providing utilities to load, manipulate, convert and visualize COCO format datasets.

Project description

rpycocotools

PyPI PyPI - Python Version PyPI - Downloads PyPI - License CI Python CI Rust

The rpycocotools package provides tools to load, manipulate, convert and visualize COCO format datasets. The documentation is available here.

Installation

The package is available on PyPI here, and can installed with pip:

pip install rpycocotools

You can also git clone this repo and build it yourself with:

pip install -r requirements/requirements-build.txt
pip install .

Usage example

Visualize image with a given id:

import rpycocotools
coco_dataset = rpycocotools.COCO("../data_samples/coco_25k/annotations.json", "../data_samples/coco_25k/images")
coco_dataset.visualize_img(174482)

rpycocotools_visu_example

import rpycocotools
coco_dataset = rpycocotools.COCO("../data_samples/coco_25k/annotations.json", "../data_samples/coco_25k/images")
anns = coco_dataset.get_img_anns(174482)
mask = rpycocotools.mask.decode(anns[0].segmentation)

The mask is a numpy array and can be visualized (for example with opencv):

bike_segmentation

Benchmarks

Details

There are a few benchmarking scripts to compare to pycocotools.
The results reported here are done on my own PC and presented only to get a general idea. I might run the benchmark on a more reproducible environment in the future.

Setup

Some of the benchmarks use the instances_train2017.json files from the 2017 COCO dataset.
Either place this file in the data_samples folder or only run the commands below with the -m "not coco2017" option.

pip install -r requirements/requirements-benchmarks.txt
pip install .

Load

Benchmark how much time it takes load a COCO dataset.

python -m pytest benchmarks/load.py -vv

Results:

Test Name Mean time in s
rpycocotools on COCO instances_train2017.json 4.4
pycocotools on COCO instances_train2017.json 16.5

Area

Benchmark how much time it takes to compute the total number of mask pixels in a COCO dataset.

python -m pytest benchmarks/area.py -vv -m coco2017

Results:

Test Name Mean time in ms
rpycocotools on COCO instances_train2017.json 880.6
pycocotools on COCO instances_train2017.json 19,302.9

Decode masks

Benchmark how much time it takes to decode all the masks in a COCO dataset.

python -m pytest benchmarks/decode.py -vv -m coco2017

Results:

Test Name Mean time in s
rpycocotools on COCO instances_train2017.json 371
pycocotools on COCO instances_train2017.json 141

Results after converting all the segmentations to RLE before decoding (conversion time not included):

Test Name Mean time in s
rpycocotools on COCO instances_train2017.json 300
pycocotools on COCO instances_train2017.json 120

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

rpycocotools-0.0.7.tar.gz (139.9 kB view hashes)

Uploaded Source

Built Distributions

rpycocotools-0.0.7-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.6 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

rpycocotools-0.0.7-pp39-pypy39_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl (2.9 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ s390x

rpycocotools-0.0.7-pp39-pypy39_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (3.8 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ppc64le

rpycocotools-0.0.7-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.6 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

rpycocotools-0.0.7-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.6 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

rpycocotools-0.0.7-pp38-pypy38_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl (2.9 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ s390x

rpycocotools-0.0.7-pp38-pypy38_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (3.8 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ppc64le

rpycocotools-0.0.7-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.6 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

rpycocotools-0.0.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.6 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

rpycocotools-0.0.7-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl (2.9 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ s390x

rpycocotools-0.0.7-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (3.8 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ppc64le

rpycocotools-0.0.7-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.6 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

rpycocotools-0.0.7-cp311-none-win_amd64.whl (1.1 MB view hashes)

Uploaded CPython 3.11 Windows x86-64

rpycocotools-0.0.7-cp311-none-win32.whl (1.0 MB view hashes)

Uploaded CPython 3.11 Windows x86

rpycocotools-0.0.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.6 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

rpycocotools-0.0.7-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl (2.9 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ s390x

rpycocotools-0.0.7-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (3.8 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ppc64le

rpycocotools-0.0.7-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.6 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

rpycocotools-0.0.7-cp311-cp311-macosx_11_0_arm64.whl (1.3 MB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

rpycocotools-0.0.7-cp311-cp311-macosx_10_7_x86_64.whl (1.4 MB view hashes)

Uploaded CPython 3.11 macOS 10.7+ x86-64

rpycocotools-0.0.7-cp310-none-win_amd64.whl (1.1 MB view hashes)

Uploaded CPython 3.10 Windows x86-64

rpycocotools-0.0.7-cp310-none-win32.whl (1.0 MB view hashes)

Uploaded CPython 3.10 Windows x86

rpycocotools-0.0.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.6 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

rpycocotools-0.0.7-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl (2.9 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ s390x

rpycocotools-0.0.7-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (3.8 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ppc64le

rpycocotools-0.0.7-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.6 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

rpycocotools-0.0.7-cp310-cp310-macosx_11_0_arm64.whl (1.3 MB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

rpycocotools-0.0.7-cp310-cp310-macosx_10_7_x86_64.whl (1.4 MB view hashes)

Uploaded CPython 3.10 macOS 10.7+ x86-64

rpycocotools-0.0.7-cp39-none-win_amd64.whl (1.1 MB view hashes)

Uploaded CPython 3.9 Windows x86-64

rpycocotools-0.0.7-cp39-none-win32.whl (1.0 MB view hashes)

Uploaded CPython 3.9 Windows x86

rpycocotools-0.0.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.6 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

rpycocotools-0.0.7-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl (2.9 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ s390x

rpycocotools-0.0.7-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (3.8 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ppc64le

rpycocotools-0.0.7-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.6 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

rpycocotools-0.0.7-cp38-none-win_amd64.whl (1.1 MB view hashes)

Uploaded CPython 3.8 Windows x86-64

rpycocotools-0.0.7-cp38-none-win32.whl (1.0 MB view hashes)

Uploaded CPython 3.8 Windows x86

rpycocotools-0.0.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.6 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

rpycocotools-0.0.7-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl (2.9 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ s390x

rpycocotools-0.0.7-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (3.8 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ppc64le

rpycocotools-0.0.7-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.6 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

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