Fast-WSI-Prediction
Fast-WSI-Prediction copied to clipboard
Unofficial implementation for ScanNet (a fast WSI prediction method) in PyTorch.
Fast WSI Prediction
Fast WSI prediction by ScanNet in PyTorch.
Aim: undergraduate course
Invasive Ductal Carcinoma (IDC) detection on Whole Slide Image (WSI) by deep learning method equipped with ScanNet fully conv. scheme for fast WSI prediction.
Data
279 slides with IDC ROI annotations.
Ratio of 6:2:2 for training, validation and testing separation.
Tiling small patch with 50*50 at 2.5x magnification for non-IDC and IDC class, binary classification task.
| patches distribution | non-IDC | IDC |
|---|---|---|
| training | 111090 | 49204 |
| validation | 45356 | 15354 |
| testing | 42292 | 14228 |
Method
- Replace the original
VGGwithVGG_fullyConvfor training - Train the
VGG_fullyConvmodel for classification, same as original training process - Check the performance on
Validationdataset and select the best model in terms of F1 score - Test and evaluate your trained
VGG_fullyConvmodel onTestingdataset in patch-level - Input the block with bigger size, Infer and predict the probability map for one WSI and show it!
HotSpot
We significantly improve the inferring time by the ScanNet scheme.
Implementation
Replaced the last GAP and fc. in VGG with AvgPooling with 2x2 kernel size followed by 2 convs with 1x1 kernel, s6_predWSI.py
self.avgpool = nn.AvgPool2d(kernel_size=2, stride=2)
self.classifier = nn.Sequential(
nn.Conv2d(out_channel, out_channel, kernel_size=1, stride=1),
nn.BatchNorm2d(out_channel),
nn.ReLU(inplace=True),
nn.Conv2d(out_channel, num_classes, kernel_size=1, stride=1))
Also, we modify the VGG network due to our small training size, and, we remove padding operation in convolutional layer to avoid the border effect arcoss testing blocks. You can refer to myModelVgg.py for more details.
The overall network structure for our architecture is shown:
| Our overall network structure |
|
Noting: The core part for Fast WSI is the step of sliding window of testing block. You can refer to s6_predWSI.py for details in function fast_wsi_pred()
Result
When training
We shows the curves of training loss and validation accuracy, see below:
| Training loss curve | Validation accuracy |
|
|
Independent testing evaluation (patch-level)
| Confusion matrics | Postive pred | Negtive pred | |
|---|---|---|---|
| Postive | 11041 | 3187 | = 14228 |
| Negtive | 3391 | 38901 | = 42292 |
- Accuracy : 0.8836
- Specificity : 0.9198
- Recall : 0.7760
- Precision : 0.7650
- F1Score : 0.7705
WSI probability map prediction (slide-level)
The valuable thing is that we achieve a fast WSI prediction method, not accuracy or performance improvement.
We show one WSI prediction probability map below, the size of the original WSI is 13440*10560, and the size of the output prediction map is 834*654.
it only takes about 4s!
| Original WSI Image | Predicted Prob. Maps |
|
|