Simple yet fully working tool
python==3.x
Simply:
1- git clone https://github.com/mohamadmansourX/Merge_COCO_FILES.git
2- cd Merge_COCO_FILES
python merge.py Json1.json Json2.json OUTPU_JSON.json
Json1 and Json2 are the two COCO files to be merged.
OUTPU_JSON is the output file for the combined results
Note:
The script will do the following checks as well:
- Duplicate filenames checks (to count if the same image has two annotations)
- 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
python INPUT_JSON.json OUTPU_JSON.json Label1 Label2...
Note: the script will do the necessary checks as well (duplicate filenames, ....)