matterport / Mask_RCNN

Mask R-CNN for object detection and instance segmentation on Keras and TensorFlow
Other
24.72k stars 11.71k forks source link

Training Dataset with files annotated and converted to coco format Using labelme #1973

Open MAdil45 opened 4 years ago

MAdil45 commented 4 years ago

Hi. I successfully implemented the demo versions-(coco, balloons, and shapes). Now i want to train the model on my custom dataset. I have dataset of almost 200 different meals and i have annotated them by using labelme. As i have noticed that those balloons are annotated by using VGG annotated tools and their json files are different. I have converted into coco format by using labelme tool and my json file is different. I Region tried to use balloon.py file to train but i got error of keyerror: region. I have json file in the following format.

{"info": {"description": null, "url": null, "version": null, "year": 2020, "contributor": null, "date_created": "2020-01-23 12:15:25.787447"}, "licenses": [{"url": null, "id": 0, "name": null}], "images": [{"license": 0, "url": null, "file_name": "JPEGImages/40014010215649790351.jpg", "height": 384, "width": 480, "date_captured": null, "id": 0}, {"license": 0, "url": null, "file_name": "JPEGImages/40014010215649785791.jpg", "height": 384, "width": 480, "date_captured": null, "id": 1}, "license": 0, "url": null, "file_name": "JPEGImages/40014010215649781051.jpg", "height": 384, "width": 480, "date_captured": null, "id": 100}], "type": "instances", "annotations": [{"id": 0, "image_id": 0, "category_id": 6, "segmentation": [[309.0569105691057, 143.90243902439025, 423.6910569105691, 265.0406504065041]], area": 17664.0, "bbox": [261.0, 113.0, 128.0, 138.0], "iscrowd": 0}, {"id": 410, "image_id": 100, "category_id": 2, "segmentation": [[94.42276422764229, 190.2439024390244, 236.6991869918699, 327.6422764227642]], "area": 20825.0, "bbox": [147.0, 58.0, 119.0, 175.0], "iscrowd": 0}], "categories": [{"supercategory": null, "id": 0, "name": "background"}, {"supercategory": null, "id": 1, "name": "0"}, {"supercategory": null, "id": 2, "name": "1"}, {"supercategory": null, "id": 3, "name": "3"}, {"supercategory": null, "id": 4, "name": "14"}, {"supercategory": null, "id": 5, "name": "17"}, {"supercategory": null, "id": 6, "name": "26"},

I need to train my model, so could please anyone suggest me to what should i do and how can i modify the ballooon or coco.py file so i can use it to train on my dataset. Thanks:

truongtd6285 commented 4 years ago

the format of JSON file exported from VGG looks like:

        # Load annotations
        # VGG Image Annotator saves each image in the form:
        #{ 'name_and_size':
    #  { 'filename': '28503151_5b5b7ec140_b.jpg',
    #   'size': 100202,
        #   'regions': [
        #           {
        #           
        #           'shape_attributes': {
    #               'name': 'polyline',
        #               'all_points_x': [...],
        #               'all_points_y': [...]
        #               },                  
    #           'region_attributes': {name:'a'}
    #           },
        #       ... more regions ...
        #   ],        
        # }
        #}
        # We mostly care about the x and y coordinates of each region

in that format we have a key called 'region' that stores all interested regions of your images. From your JSON file above, i cannot see a region likes that. It was the reason why you got the KeyError. I think if you want to use ballon.py, you should use VGG to create annotation files.

MAdil45 commented 4 years ago

@truongtd6285 Hi. Thanks for the response. However, in this project we are only allowed to use labelme to annotate and for conversion into coco format. I have already talked to our supervisor and he told me that you cannot use VGG. Could you please suggest me the modifications or any suggestion that could help me with this problem. Thanks.

truongtd6285 commented 4 years ago

I think you have two options:

maxpaynestory commented 4 years ago

I have modified balloon.py to parse json files created by labelme against each image.

MAdil45 commented 4 years ago

Hi @truongtd6285 Thankyou so much. Appreciate it Brother. I have to stick with the first option. Hi @maxpaynestory Could you please help me with the problem. I want to modify the way you did. I am very new to python so kindly would be great help if you can suggest me the modifications.

YashRunwal commented 4 years ago

@maxpaynestory Can you share the code for parsing json files created by labelme in balloon.py? It would be really helpful. Thanks.

kimsangseob commented 4 years ago

I have modified balloon.py to parse json files created by labelme against each image.

Can you share the code plz?? It would be really helpful!! Thank you

alexbarnadas commented 3 years ago

I have modified balloon.py to parse json files created by labelme against each image.

@maxpaynestory please tell us how you did it!

alexbarnadas commented 3 years ago

I've found this implementation which creates that function, I'm going to try, hope you find it useful, I'll tell you if it works.

iqbalchoironi commented 3 years ago

I've found this implementation which creates that function, I'm going to try, hope you find it useful, I'll tell you if it works.

sakalangkong kak, ecobaah delluh pola bisa yeh 🔢

darko262 commented 3 years ago

hello I have the same problem, could one be successful?