matterport / Mask_RCNN

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

Transfer learning with Mask_RCNN #1470

Open manojmsrit opened 5 years ago

manojmsrit commented 5 years ago

I am trying to use Mask_RCNN for transfer learning for my custom dataset. I want mask_rcnn to detect all the 80 classes from the coco dataset and also i want to add new class for my custom dataset. How to achieve this, can anybody give me a pointer for the same.

as in the samples/balloon it shows that they only trying to detect balloon, in my case if i want to detect all the 80 classes of coco images and then also balloon , how to achieve this ?

Thanks and Regards

apelli4 commented 5 years ago

Also interested in this. I believe it has something to do with setting the number of classes in the config at the beginning of balloon.py `

class BalloonConfig(Config): """Configuration for training on the toy dataset. Derives from the base Config class and overrides some values. """

Give the configuration a recognizable name

NAME = "balloon"

# We use a GPU with 12GB memory, which can fit two images.
# Adjust down if you use a smaller GPU.
IMAGES_PER_GPU = 2

**# Number of classes (including background)
NUM_CLASSES = 1 + 1  # Background + balloon**

# Number of training steps per epoch
STEPS_PER_EPOCH = 100

# Skip detections with < 90% confidence
DETECTION_MIN_CONFIDENCE = 0.9

` I believe bolded is what determines the number of classes used

roryw10 commented 5 years ago

+1 for a better overview of transfer learning here. I took a look at some of the descriptions / guides and it isnt clear to me at what point the layers are frozen for transfer learning here?

nyck33 commented 5 years ago

@roryw10

https://github.com/matterport/Mask_RCNN/blob/master/samples/shapes/train_shapes.ipynb Under heading Training it says:

Train in two stages:

Only the heads. Here we're freezing all the backbone layers and training only the randomly initialized layers (i.e. the ones that we didn't use pre-trained weights from MS COCO). To train only the head layers, pass layers='heads' to the train() function.

Fine-tune all layers. For this simple example it's not necessary, but we're including it to show the process. Simply pass layers="all to train all layers.

So basically in two stages, train the heads first then finetune entire model.

Does anyone know how to set the config file so it detects only tennis balls?

lloydrayner commented 5 years ago

+1 on multi class training and transfer learning

May-forever commented 4 years ago

Dear manojmsrit,

I want to use Mask-RCNN to train on my custom dataset (just one class).

First of all, I use Labelme to create groundtruth for each image. Each image has a .json file as its ground-truth.

After that, I don't know what should I do...

I want to know how to convert my groundtruth file to a format that Mask-rcnn can use. Do you have any tools ?

Looking forward to hearing from you, thanks in advance.

With best regards, Ming

YashRunwal commented 3 years ago

@May-forever Did you find a solution? I am facing the same problem.

mountains-high commented 2 years ago

@May-forever, did you find the solution?

goldeneave commented 1 year ago

@May-forever, did you find the solution?

it seems the train process do not take coco format annotation file, so if you want train on sample code in the repo, you may convert into VIA format