Path: blob/master/samples/nucleus/inspect_nucleus_model.ipynb
240 views
Mask R-CNN - Inspect Nucleus Trained Model
Code and visualizations to test, debug, and evaluate the Mask R-CNN model.
Configurations
Notebook Preferences
Load Validation Dataset
Load Model
Run Detection
Compute AP on Batch of Images
Step by Step Prediction
Stage 1: Region Proposal Network
The Region Proposal Network (RPN) runs a lightweight binary classifier on a lot of boxes (anchors) over the image and returns object/no-object scores. Anchors with high objectness score (positive anchors) are passed to the stage two to be classified.
Often, even positive anchors don't cover objects fully. So the RPN also regresses a refinement (a delta in location and size) to be applied to the anchors to shift it and resize it a bit to the correct boundaries of the object.
1.a RPN Targets
The RPN targets are the training values for the RPN. To generate the targets, we start with a grid of anchors that cover the full image at different scales, and then we compute the IoU of the anchors with ground truth object. Positive anchors are those that have an IoU >= 0.7 with any ground truth object, and negative anchors are those that don't cover any object by more than 0.3 IoU. Anchors in between (i.e. cover an object by IoU >= 0.3 but < 0.7) are considered neutral and excluded from training.
To train the RPN regressor, we also compute the shift and resizing needed to make the anchor cover the ground truth object completely.
1.b RPN Predictions
Here we run the RPN graph and display its predictions.
Stage 2: Proposal Classification
This stage takes the region proposals from the RPN and classifies them.
2.a Proposal Classification
Run the classifier heads on proposals to generate class propbabilities and bounding box regressions.
2.c Step by Step Detection
Here we dive deeper into the process of processing the detections.
Apply Bounding Box Refinement
Filter Low Confidence Detections
Per-Class Non-Max Suppression
Stage 3: Generating Masks
This stage takes the detections (refined bounding boxes and class IDs) from the previous layer and runs the mask head to generate segmentation masks for every instance.
3.a Mask Targets
These are the training targets for the mask branch
3.b Predicted Masks
Visualize Activations
In some cases it helps to look at the output from different layers and visualize them to catch issues and odd patterns.