This project implements an end-to-end machine learning pipeline for lung cancer detection from medical images (e.g., CT scans, X-rays). It compares traditional Convolutional Neural Networks (CNNs) with Meta Learning (Few-Shot Learning) approaches like Prototypical Networks. The notebook evaluates models on metrics such as Accuracy, Precision, Recall, F1 Score, ROC-AUC, and Training Time.
- Custom CNN: Baseline model built from scratch.
- Transfer Learning: Pretrained models (ResNet50, DenseNet121, EfficientNetB0).
- Meta Learning: Prototypical Networks for few-shot classification.
- Data preprocessing with augmentations.
- Model evaluation and comparison.
- Single image prediction.
-
Clone the repository:
git clone https://github.com/RugvedVaidya/CNN-vs-meta-learning-lung-cancer-detection.git cd Comparative-Analysis -
Install dependencies:
pip install numpy pandas matplotlib seaborn tqdm pillow torch torchvision scikit-learn -
Ensure you have a GPU-enabled environment if using CUDA.
- Organize images into class folders (e.g.,
dataset/benign/anddataset/malignant/). - Update
DATASET_PATHin the notebook to your local path. - Supported formats: PNG, JPG, JPEG, BMP, TIF, TIFF.
- Open the Jupyter notebook:
Lung_Cancer_Detection_CNN_vs_MetaLearning.ipynb. - Run cells sequentially to load data, train models, and evaluate.
- For prediction, use the
predict_imagefunction with a custom image path.
- Train models with early stopping and validation.
- Compare results in the final section.
- Best model selected based on F1 Score.
Results are aggregated in a DataFrame and visualized. Transfer learning models typically outperform custom CNNs, while Meta Learning excels in low-data scenarios.
Feel free to fork and submit pull requests for improvements.
This project is for educational purposes. Ensure compliance with data privacy laws for medical images.