Mask_RCNN icon indicating copy to clipboard operation
Mask_RCNN copied to clipboard

Transfer learning with Mask_RCNN

Open manojmsrit opened this issue 5 years ago • 7 comments

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

manojmsrit avatar Apr 25 '19 17:04 manojmsrit

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

apelli4 avatar May 01 '19 21:05 apelli4

+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?

roryw10 avatar May 04 '19 13:05 roryw10

@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?

nyck33 avatar May 30 '19 13:05 nyck33

+1 on multi class training and transfer learning

lloydrayner avatar Jun 05 '19 10:06 lloydrayner

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

May-forever avatar Oct 08 '19 12:10 May-forever

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

YashRunwal avatar Aug 21 '20 06:08 YashRunwal

@May-forever, did you find the solution?

mountains-high avatar Jun 06 '22 13:06 mountains-high

@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

goldeneave avatar Mar 09 '23 06:03 goldeneave