Skip to content

About

Fine-tuned models for lung cancer versus non-cancer pneumonia-only classification using chest CT scans, with GradCAM

Resources

Stars

1 star

Watchers

1 watching

Forks

Repository files navigation

The application of deep learning in lung cancerous lesion detection

This repository contains scripts used to fine-tune deep learning models for the classification of lung cancer and non-cancer pneumonia-only using chest CT scans. Gradient-weighted Class Activation Mapping (GradCAM) was also employed to interpret the models' decision in classifying cancerous CT scans.

Our manuscript is now available at medRxiv and is under submission.

Model architectures

Nine model architectures were optimized, trained and evaluated in our study:

  • DenseNet121
  • MobileNetV2
  • InceptionV3
  • InceptionResNetV2
  • ResNet50
  • ResNet101
  • VGG16
  • VGG19
  • Xception

All models were built using TensorFlow's Keras API 2.13 with python 3.8.

Datasets

  • For the lung cancer dataset, chest CT scans of 101 lung cancer patients was randomly obtained from the Lung-PET-CT-Dx database in the Cancer Image Archive. The original database contains approximately 251,135 scans of 355 lung cancer patients.

  • A collection of pneumonia-only CT scans was employed as the non-cancer dataset. This is a newly established library extracted from peer-reviewed scientific publications and is available at ReiCHU31/CT-pneumonia-dataset.

Here, we provided some sample data for training, validation and testing. The ./sample_data directory is organized as follows:

sample_data
├── Training
│   ├── Cancer       
│   └── Non-cancer    
├── Validation
│   ├── Cancer       
│   └── Non-cancer             
├── Testing
│   ├── Cancer       
│   └── Non-cancer       

Usage

  • Install packages:
pip install -r requirements.txt
  • Training and testing:

Choose one of the following for the --base argument: dense mob incepres res50 res101 incepv3 vgg16 vgg19 xcep

Example command:

python main.py --data ./sample_data --base incepv3 --input_size 299 --epochs 5 --batch 5

An example notebook to train InceptionV3 was also provided: example_notebook.ipynb

  • Implementing GradCAM on a chosen input image (remember to specify the path to your saved weights and input image):
python gradcam.py --base incepv3 --input_size 299 --model_path "incepv3.h5" \
        --layer mixed10 --img "./gradcam_cancer_input.png"

Example GradCAM output:

About

Fine-tuned models for lung cancer versus non-cancer pneumonia-only classification using chest CT scans, with GradCAM

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages