matterport / Mask_RCNN

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

How to train with multiple classes more than 300 #1697

Open saravanakumarjsk opened 5 years ago

saravanakumarjsk commented 5 years ago

I've been working with this repo for a while and I need to know how to train the images with 300 or more number of classes, FYI I have the image dataset and the number of classes needed.. Can anyone please help me out on this.

karthik9319 commented 5 years ago

Go here take a look at surgery.py file. In that

class SurgeryDataset(utils.Dataset):
    def load_VIA(self, dataset_dir, subset, hc=False):
         self.add_class("surgery", 1, "arm")
         self.add_class("surgery", 2, "ring")
         ...
         ...

add your classes accordningly

HosAkh commented 5 years ago

@karthik9319 I'm trying to do something similar but what I'm confused on is how many annotations should to do for each class? Say for example label human body parts. Due to the color of the skin I would need to give it more samples annotations samples or not for better accuracy? Hopefully that made sense.

karthik9319 commented 5 years ago

@BeyoncesHomeboy as far as I understood this is what you wanted to do correct me if I'm wrong- when you apply this Mask R-CNN to an image of the human. It should mask all parts with relevant colors?

if that's what you want. Your annotation should be of the left hand as one class, right hand as one class, head as one class, left leg as one class, right leg as one class. Irrespective of the color of the skin the more training data annotations you provide, the better the model performance will be. Use image augmentation if you have fewer data.

HosAkh commented 5 years ago

@karthik9319 So what you are saying the more annotations I make the better the training class will be. Just like with tensorflow for poets where you provide a pictures for each class but this time those pictures have annotations where they are outlined on what I'm looking for, correct?

karthik9319 commented 5 years ago

@BeyoncesHomeboy Exactly!!! Use VGA annotation tool and annotate all body parts in that image and label them accordingly. Just make sure if these annotated points are not out of the image dimension.

HosAkh commented 5 years ago

@BeyoncesHomeboy Exactly!!! Use VGA annotation tool and annotate all body parts in that image and label them accordingly. Just make sure if these annotated points are not out of the image dimension.

I'm a little confused on the folder structuring. I have to do a before and after now for fat or muscle gain/loss so as I'm stitching 2 images to make one and labeling each body part as an object and classify them if they have gained or lost fat or muscle (each object will have it's own color and class). What I'm wondering is how to structor the folders? Would stomach fat loss have it's own folder with all of the images and then the annotation. Then Stomach muscle gain have it own, then pecs, arms, so on and so forth. Or do I just create one folder inside the data folder for fat loss and have all of the images with the json file in it and then another folder for muscle gain with all of the images in it? Or can I just have one folder that will include all of the images and then one massive json file?

karthik9319 commented 5 years ago

@BeyoncesHomeboy see this post regarding annotating your data training data. The last option one folder consists of all images and one json file.