New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

rpycocotools

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rpycocotools

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

  • 0.0.7
  • PyPI
  • Socket score

Maintainers
1

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 NameMean time in s
rpycocotools on COCO instances_train2017.json4.4
pycocotools on COCO instances_train2017.json16.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 NameMean time in ms
rpycocotools on COCO instances_train2017.json880.6
pycocotools on COCO instances_train2017.json19,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 NameMean time in s
rpycocotools on COCO instances_train2017.json371
pycocotools on COCO instances_train2017.json141

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

Test NameMean time in s
rpycocotools on COCO instances_train2017.json300
pycocotools on COCO instances_train2017.json120

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc