The project is a complete COVID-19 detection package comprising of 3 tasks:
β€ Task 1: COVID-19 Infection Segmentation
β€ Task 2: COVID-19 Classification
β€ Task 3: Lung Segmentation
Sample data |
-----------------------------------------------------------------------------------------------------------------------------------------
- All scripts are exactly the same with the notebooks having same titles.
- Any necessary package to be installed is placed on top of each of the six scripts/notebooks.
- Scripts/Notebooks are using kaggle and Colab collectively, so will contain some exclusive operations as per the platform like importing data from kaggle to colab needs a unique API key, mounting drive and authentication, etc
-----------------------------------------------------------------------------------------------------------------------------------------
β task1_preprocessing_plus_unet_with_comments.py ---> Contains the maximum number of comments and explanation. Any doubt, if persists probably could be rectified here. It contains the UNet training for infection mask prediction (Task- 1)
β task1_crossval_3folds_unet.py --> Contains the cross-validation (3-folds) for TASK-1.
β task1_crossval_4folds_unet.py --> Contains the cross-validation (4-folds) for TASK-1.
β task1_unet_plus_plus.py --> Contains the unet++ training for TASK-1.
β task2_covid19_classifcation.py --> Contains the covid-19 classification (TASK-2).
β task3_lung_segmentation_unet.py --> Contains Unet training for lung segmentation (TASK-3).
β app.py --> Contains a runner code for running any file listed above.
# app.py
from task1_crossval_3folds_unet import *
from task1_crossval_4folds_unet import *
from task1_preprocessing_plus_unet_with_comments import *
from task1_unet_plus_plus import *
from task2_covid19_classifcation import *
from task3_lung_segmentation_unet import *
print("\n\n\n\n")
print("--------------------------------------------------------------------------------------")
print(" 'one' --> Task1: 3-fold cross-validation UNet (Infection Segmentation)")
print(" 'two' --> Task1: 4-fold cross-validation UNet (Infection Segmentation)")
print(" 'three' --> Task1: UNet original holdout method (Infection Segmentation)")
print(" 'four' --> Task1: UNet++ holdout method (Infection Segmentation)")
print(" 'five' --> Task2: COVID-19 Classification")
print(" 'six' --> Task3: Lung Segmentation")
print("--------------------------------------------------------------------------------------")
print("\n\n\n\n\n")
print("Enter from one of the {'one', 'two', 'three', 'four', 'five', 'six', 'seven'}")
num = input()
if num == 'one':
three_fold_runner_unet_infection_segmentation()
if num == 'two':
four_fold_runner_unet_infection_segmentation()
if num == 'three':
holdout_runner_unet_infection_segmentation()
if num == 'four':
holdout_runner_unetplusplus_infection_segmentation()
if num == 'five':
runner_classification()
if num == 'six':
runner_lung_segmentation()
-----------------------------------------------------------------------------------------------------------------------------------------
Note: Not all are displayed here, rest could be fetched after running notebooks
RESULT TABLE
+----------------------------------------+----------------------------+-----------------------+---------------------------+------------------------+--------+--------------+----------+
| | Dice (Mean of folds) | IOU (Mean of folds) | Precision (Mean of folds) | Recall (Mean of folds) | AUCROC | F1 Score | Accuracy |
+----------------------------------------+----------------------------+-----------------------+---------------------------+------------------------+--------+--------------+----------+
| Task1: Infection Segmentation (3-fold) | 0.948 | 0.903 | 0.947 | 0.950 | - | same as dice | - |
+----------------------------------------+----------------------------+-----------------------+---------------------------+------------------------+--------+--------------+----------+
| Task1: Infection Segmentation (4-fold) | 0.956 | 0.917 | 0.955 | 0.958 | - | same as dice | - |
+----------------------------------------+----------------------------+-----------------------+---------------------------+------------------------+--------+--------------+----------+
| Task2: Classification | - | - | 0.987 | 0.989 | 0.998 | 0.988 | 0.982 |
+----------------------------------------+----------------------------+-----------------------+---------------------------+------------------------+--------+--------------+----------+
| Task3: Lung Segmentation | 0.984 | 0.969 | - | - | - | same as dice | - |
+----------------------------------------+----------------------------+-----------------------+---------------------------+------------------------+--------+--------------+----------+
| | Note: precision and recall | values are as per the | best threshold for dice | | | | |
+----------------------------------------+----------------------------+-----------------------+---------------------------+------------------------+--------+--------------+----------+
-----------------------------------------------------------------------------------------------------------------------------------------
1.) Removing incomplete and fauty images
2.) Separate model for empty mask prediction
3.) Use of Contrast Limited Adaptive Histogram Equalization (
) for image enhancement
4.) Cropping the Region of Interst (ROI) using Otsu's binarization and other approaches
5.) Data Augmentation
Cropping out contour with the largest area |
CLAHE only Output | Before-After Image (after all preprocessing steps) |
Augmentated CT Scans (Task: 1) |
Augmented Infections Masks (Task: 1) |
Augmentated CT Scans (Task: 3) |
Augmented Lung Masks (Task: 3) |
(Remains same for all tasks)
Exponential decaying LR (Step and continuous) | Exponential decaying LR (Step and continuous) with Variation |
Cosine Annealing Cyclical LR | Blend of Cosine Annealing and Exponential Decay |
Trianing curve for Dice Coefficient | Training curve for BCE + Dice Loss |
Optimizing threshold with small step size |
Precision and recall curves v/s thresholds |
Some Actual Vs Predicted Masks | Some Actual Vs Predicted Masks |
4-fold threshold vs split number dataframe for DICE | Brief report acquired from dataframe |
4-fold threshold vs split number dataframe for IOU | Brief report acquired from dataframe |
4-fold threshold vs split number dataframe for PRECISION | Brief report acquired from dataframe |
4-fold threshold vs split number dataframe for RECALL | Brief report acquired from dataframe |
Some Actual v/s Predicted Masks by 4 Unet models of 4-fold Cross-Validation |
Training curve for Dice Coefficient | Training curve for BCE + Dice Loss |
Optimizing threshold with small step size |
Classification loss curve |
Distribution of TN, TP, FN, FP with Threshold 0.50 | Distribution of TN, TP, FN, FP with Best Threshold 0.81 |
ROC Curve with Threshold 0.50 | ROC Curve with Threshold 0.81 |
Confusion matrix with Threshold 0.50 | Confusion matrix with Best Threshold 0.81 |
Training curve for Dice Coefficient | Training curve for BCE + Dice Loss |
Optimizing threshold with small step size |
Actual v/s Predicted Lung Masks | Actual v/s Predicted Lung Masks |
MIT License
Copyright (c) 2020 Rohit Verma
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.