# 14th place insight (LB 0.578)

Here is an overview of the model that reached place #14 on stage2 with LB 0.578.
Basically, I trained a few Mask-RCNN models on different stratified folds issued from images clustering. Then I performed ensembling on masks predicted from each model.
Training
![enter image description here](assets/bfc197de5ffce574360a6d8b.png)
Additional external data (links available in
[related](https://www.kaggle.com/c/data-science-bowl-2018/discussion/47572)
thread):
Dataset from TNBC (Breast Cancer)
Dataset from nuclei segmentation benchmark
Balanced K-Folds: 
Training images split in stratified folds with balanced modalities (see
[kernel](https://www.kaggle.com/mpware/stage1-eda-microscope-image-types-clustering)
published)
Data cleaning:  "data quality issues"
[thread](https://www.kaggle.com/c/data-science-bowl-2018/discussion/47770)
was a great source.
Bad masks and images excluded.
Images available in both training and testing dataset dropped as it may hurt training.
Fix small holes in masks with morphology.
Normalization:
Contrast/luminosity enhancements with dark background.
Grayscale conversion: For generalization purpose, to avoid stain specifics in model.
Architecture:
Mask-RCNN models with regular augmentations (rotations, flips, scale ...).
ResNet101 first as backbone but finally selected ResNet50 as it was enough for 2 classes only.
SGD optimizer choosen even if convergence was slower.
120 epochs minimum before saving the best model.
Execution
![enter image description here](assets/7e076a7316d422f90b683973.png)
For each MRCNN model:
Simple TTA (flip up/down and left/right only) followed by ensembling based on IoU.
The rule applied: If all models agree then perform union of masks. If one disagree then discard the mask. This rule provided really stable results during stage#1. Also, IoU criteria was a bit better than NMS on boxes (the other
[kernel](https://www.kaggle.com/mpware/ensembling-on-instance-segmentation-lb-0-419)
attempt published).
Final ensemble and cleaning:
Keep predictions (union of masks) of each fold based on majority vote.
Fill small holes in predicted masks
Resources:
1 to 3 GPU (Tesla K80 12GB)
Google VM: n1-standard-8 (8vCPU, 50GB RAM)
Results:
I think this model can score beyond 0.578 by including BBBC images. 
BTW: I've just started a quick run with only 100 additional images from BBBC6 and limited epochs and I'm already at 0.565.
Et voila, I had a lot of fun with this competition, I was totally novice in biology domain. It might be a reason why I did not overfit too much :-).
I tried a few approaches such as UNet and LinkNet with post processing before moving to Mask-RCNN but 1st place solution used UNet so congratulations to topcoders team.
Thanks to Heng CherKeng too for all references , thoughts and code sharing that make the forum animated.