Skip to main content

Python package which aims to merge 2 COCO .json files

Project description

Merge .json COCO files

This package is intended for data scientist who wants to merge several COCO datasets before training a new model.

Requirements

python==3.x

Installation

Simply set up a Python environment and type :

pip install COCO_merger

COCO Files Merge Usage

python -m COCO_merger.merge --src Json1.json Json2.json --out OUTPUT_JSON.json

Argument parser

usage: merge.py [-h] --src SRC SRC --out OUT

Merge two annotation files to one file

optional arguments:
  -h, --help     show this help message and exit
  --src SRC SRC  Path of two annotation files to merge
  --out OUT      Path of the output annotation file

Note:

The script will do the following checks as well:

  1. Duplicate filenames checks (to count if the same image has two annotations)
  2. Categories checks (Both files should have same categegories (name, id))

The reason I didn't mix categories, incase they are different, is to help annotators identifying any change in there categories. I believe this will be helpful incase of annotating a dataset as batches or splitting the annotation on members. Any change in ids caused by software being used or human mistake will be directly identified.

Example of Dog category existing in file 2 but not file 1

AssertionError: Category name: Dog in file 2 does not exist in file 1

Example of Cat category existing in both files but with different ids:

AssertionError: Category name: Cat, id: 1 in file 1 and 2 in file 2


Note: the script will do the necessary checks as well (duplicate filenames, ....)

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_merger-0.0.2.tar.gz (5.5 kB view hashes)

Uploaded Source

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