Skip to main content

COCO ML Toolbox

COCO ML Toolbox is a command-line interface (CLI) tool for managing COCO (Common Objects in Context) dataset files. This toolbox provides functionalities to split, merge, and crop COCO datasets, making it easier to manipulate and prepare datasets for machine learning tasks.

Features

  • Split a COCO dataset into training and testing datasets with a specified ratio.
  • Merge multiple COCO dataset files into a single file.
  • Crop images based on annotations in a COCO dataset.

Streamlit App

You can use our streamlit app here.

Installation

cocomltools requires python >= 3.9.8

Install python package

The easiest way to install the package is using pip

pip install cocomltools

You can also clone the source code and install dependencies using poetry:

git clone https://github.com/Ghallabi/coco-ml-toolbox.git
cd coco-ml-toolbox
pip install poetry
poetry install

Usage

We provide a CLI that comes with three main commands: split, merge, and crop. Below are the details on how to use each command.

Split

Splits a COCO dataset into training and testing datasets.

cocoml split --coco-path /path/to/coco.json --output-dir /path/to/output --ratio 0.2 --mode random
  • --coco-path: Path to the COCO file (JSON).
  • --output-dir: (Optional) Path to save the split COCO files. Defaults to the directory of the input COCO file.
  • --ratio: (Optional) Split ratio. Defaults to 0.2.
  • --mode: (Optional) Split mode. Options are random and strat. Defaults to random.

Merge

Merges multiple COCO dataset files into a single file.

cocoml merge --coco-paths /path/to/coco1.json,/path/to/coco2.json --output-dir /path/to/output
  • --coco-paths: Comma-separated paths to the COCO files (JSON).
  • --output-dir: (Optional) Path to save the merged COCO file. Defaults to the directory of the first input COCO file.

Crop

Crops images based on annotations in a COCO dataset.

cocoml crop --coco-path /path/to/coco.json --images-dir /path/to/images --output-dir /path/to/cropped_images --num-workers MAX_WORKERS
  • --coco-path: Path to the COCO file (JSON).
  • --images-dir: Path to the directory containing the COCO image files.
  • --output-dir: (Optional) Path to save the cropped images. Defaults to a "cropped" directory within the parent directory of the images.
  • --num-workers: to speed up the cropping process.

Metadata

Release files for cocomltools 0.1.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cocomltools 0.1.8
File Size Uploaded
cocomltools-0.1.8.tar.gz 8.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cocomltools 0.1.8
File Interpreter ABI Platform
cocomltools-0.1.8-py3-none-any.whl Python 3 none any Details

Total release size: 17.7 kB

Release files / cocomltools-0.1.8.tar.gz

Download URL cocomltools-0.1.8.tar.gz
Size 8.2 kB
Tags Source
SHA-256 checksum
How to use checksums
9ee0ebcdd5a376e59eb7a3f974c1c4e7db2dd50276ec4caa90b69a3ae57b4f88
BLAKE2b-256 checksum
How to use checksums
c961a178991623a448ac40595722dccf03a682a8c6a5de442a585c258451ccb7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.4 CPython/3.11.10 Darwin/23.4.0

Release files / cocomltools-0.1.8-py3-none-any.whl

Download URL cocomltools-0.1.8-py3-none-any.whl
Size 9.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cc57f3c80e4ac53bd3f79597956a299171a65eb2a2b518370156584f096f0404
BLAKE2b-256 checksum
How to use checksums
0a6175cb1d0f596b056c7c28052ed6b771bacc16356c27e1511683fb7d5ff815
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.4 CPython/3.11.10 Darwin/23.4.0
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page