This is ongoing project
Implemented Mask R-CNN model to automatically segment the boundary of potential cancerous regions (specifically Melanoma) from dermoscopic images.
- Python 3.6
- OpenCV 4.1.0
- keras 2.2.4
- Tensorflow 1.13.0
- Mask-RCNN
- imgaug 0.2.9
- cuda toolkit 10.0
- cuDNN 7.4.2
- Imutils
- NumPy 1.16.2
The skin lesion boundary segmentation dataset is from International Skin Imaging Collaboration (ISIC) 2018 Lesions dataset, which consists of 2594 images in JPEG format and 2594 corresponding ground-truth masks in PNG format.
The lesions.py
contains several subclasses of the Mask R-CNN classes. We define a subclass of the Config
class inside mrcnn
to override and/or define any configurations we might need, which is called LesionBoundaryConfig
(check here). The LesionBoundaryConfig
class stores all relevant configurations when training Mask R-CNN model on the skin lesion dataset.
Just as we have a training configuration, we also have an prediction/inference configuration as well, which is called LesionBoundaryInferenceConfig
(check here). The LesionBoundaryInferenceConfig
class is not subclass of the Mask R-CNN Config
class but is rather a subclass of LesionBoundaryConfig
class used for training.
The LesionBoundaryDataset
class (check here) is responsible for managing the lesion dataset, including loading both images and their corresponding masks from disk.
The lesions.py
has three modes, including training (check here), predicting (check), and investigating (check here). The investigating mode is used to check the training set to make sure the data is properly stored. It is a wise choice to start with a pre-trained model and then fine-tune it. Thus, Mask R-CNN model with ResNet backbone pre-trained on the COCO is used, which is named mask_rcnn_coco.h5
(download site). We first freeze all the layers before head, and train the head for 25 epochs. After the head have start to learn patterns, we could pause the training and unfreeze all the layers before, and continue the training but with smaller learning rate.
The following command can start to train the Mask R-CNN model.
python lesions.py --mode train
However, it is recommended to investigate and debug dataset, images and masks, before starting training, in order to ensure the training process can work properly.
The following command can provide some insight into dataset before training the Mask R-CNN model.
python lesions.py --investigate
Since I just finished first-time training to get a sense of training Mask R-CNN model, there are many modifications to be done in the future, including increase the accuracy while reducing the possible overfitting situation.