matterport / Mask_RCNN

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

Which weight file to use for transfer learning? #1284

Open GaiaGrower opened 5 years ago

GaiaGrower commented 5 years ago

I trained the nuclei images from the Segmenting Nuclei in Microscopy Images project, both network heads and all layers, with 10 epochs for each (20 total), using the mask_rcnn_coco.h5 weight file as the starting place, and a modified version of nucleus.py.

Now I have 20 weight files, created from each of those epochs. I want to train Mask R-CNN on a different dataset, one of images of soil bacteria.

Which weight file, of the 20, should I use instead of the mask_rcnn_coco.h5 file to start this training session?

Each weight file's epoch has a different set of "losses". Should I use the very last epoch's weight file to start training on my own images? Or should I choose the weight file from my 20, that has the best set of "losses".

Should I use one from the "heads only" run, or from the "all layers" run?

Thank you for your help.

hackerghost93 commented 5 years ago

How big is your dataset? I would use coco weights for transfer learning as well and start with the heads only then maybe training all the network.

GaiaGrower commented 5 years ago

Hello, and thank you for replying! I apologize for my ignorance; just starting out.

I'm using the dataset that came with the nucleus sample, about 30k images all told.

I'm trying to get a model together that will recognize soil microorganisms: bacteria, fungi, nematodes, and protozoa. I thought that finding, thank goodness, a dataset of microscope slide images would be a better place to start with, than sets of above ground images.

I thought that the point of training the nucleus model on nuclei images, starting with the coco weights, was to get a new weight file that was the result of the model learning to identify nuclei. From there, using my nuclei-trained weight file, I could train the mask model to identify, to start, soil bacteria.

Am I totally off the mark? Why would I use the coco weights again, if I've got a nuclei-trained weight file to train the model on soil bacteria images?

Which of the 20 nuclei-trained weight files should I use? Best set of losses, the very last weight file, after training all layers?

Thank you in advance for your help.

hackerghost93 commented 5 years ago

The best set of losses you can find is the last one of the training ( look at tensorboard for val loss to be sure ). You need to use the same configurations. And I would recommend trying both using the last weights files and start at the beginning from coco. Training a model is an iterative process that takes many tries to find the best accuracy.

GaiaGrower commented 5 years ago

Thank you for responding Ahmed. Guess there's plenty left for me to learn about this. Learning via email doesn't really work. Any chance of talking with you for a few minutes? I can do phone, Skype, or WhatsApp. Baruch

On Wed, Feb 20, 2019 at 12:27 AM Ahmed Wael Said notifications@github.com wrote:

The best set of losses you can find is the last one of the training ( look at tensorboard for val loss to be sure ). You need to use the same configurations. And I would recommend trying both using the last weights files and start at the beginning from coco. Training a model is an iterative process that takes many tries to find the best accuracy.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/matterport/Mask_RCNN/issues/1284#issuecomment-465474033, or mute the thread https://github.com/notifications/unsubscribe-auth/AsA1iPOYHDCy2nOwav8zwo3jr3w4Oul5ks5vPQcBgaJpZM4a6uSv .

hackerghost93 commented 5 years ago

There is a course which helped me a lot Deep learning specialization on Coursera by Andrew Ng. you should really look into it. I am not that expert to teach someone, so you should find a better person for this job :).

ectg commented 5 years ago

The best set of losses you can find is the last one of the training ( look at tensorboard for val loss to be sure ).

Hi @hackerghost93, I am a little confused on how to use tensorboard to visualize the losses. Is sample code available in this download?

hackerghost93 commented 5 years ago

tensorboard --logdir path_to_current_dir After you run, by default this repository attaches tensorboard callback to it. The only thing to do is to run this command after you are done with training. change current directory to where the model checkout.