Mask_RCNN
Mask_RCNN copied to clipboard
Converting json format
How to convert multilple jsons got from labelme annotation tool to the one that matches with COCO/BALLOON dataset?
Do you want to combine multiple json files to one? If that is the case then you can use the VGG annotation tool, import all the json files together. It will combine the json files automatically.
@sherlocked777 you can use labelme2coco package to convert your annotations to coco format. It is really easy.
Installation:
pip install labelme2coco
Usage:
# import package
import labelme2coco
# set directory that contains labelme annotations and image files
labelme_folder = "tests/data/labelme_annot"
# set path for coco json to be saved
save_json_path = "tests/data/test_coco.json"
# conert labelme annotations to coco
labelme2coco.convert(labelme_folder, save_json_path)
Hi @fcakyon Could you help me to solve this issue please?
Converting labelme annotations to COCO format: 0%| | 0/500 [00:00<?, ?it/s]
Traceback (most recent call last):
File "convert_.py", line 11, in <module>
labelme2coco.convert(labelme_folder, save_json_path)
File "/home/user/anaconda3/envs/mlp/lib/python3.7/site-packages/labelme2coco/__init__.py", line 32, in convert
coco = get_coco_from_labelme_folder(labelme_folder)
File "/home/user/anaconda3/envs/mlp/lib/python3.7/site-packages/labelme2coco/labelme2coco.py", line 44, in get_coco_from_labelme_folder
width, height = Image.open(image_path).size
File "/home/user/anaconda3/envs/mlp/lib/python3.7/site-packages/PIL/Image.py", line 3068, in open
fp = builtins.open(filename, "rb")
FileNotFoundError: [Errno 2] No such file or directory: 'anno/..\\img\\0067.jpg'
Thank you
image file and json should be in the same folder
hi @mountains-high, in your json file's "imagePath": "some_path" contains an image path. when you use lebelme2coco converter ,it find an image path and gave an above mentioned error message. so can you remove the path and define only the image name and try the convertion. it works for me