A lightweight end-to-end deep learning pipeline for classifying dermatoscopic skin lesion images using transfer learning with FastAI and PyTorch.
This project implements a Convolutional Neural Network (CNN) using FastAI and a PyTorch backend to classify skin cancer lesions from dermatoscopic images.
It uses a ResNet18 model pre-trained on ImageNet and fine-tunes it on a curated subset of the Skin Cancer ISIC dataset.
⚠️ Disclaimer: This project is for educational & research purposes only. It is not a substitute for professional medical diagnosis.
⚠️ Note: Due to resource and training time constraints, the notebook uses only a subset of classes (some classes were removed) from the original dataset.
| Feature | Description |
|---|---|
| 🧠 Transfer Learning | Pre-trained ResNet18 model fine-tuned with FastAI best practices. |
| ⚡ Simplified Workflow | FastAI abstracts away boilerplate PyTorch code for faster prototyping. |
| 🔄 Data Augmentation | Uses aug_transforms (flips, rotation, zoom, warp) for generalization. |
| 📊 Comprehensive Evaluation | Includes Confusion Matrix, Precision-Recall Curve, and ROC Curve. |
| 🎯 Prediction Demo | Load the trained model and run single-image predictions with probabilities. |
| 🧪 Test-Time Augmentation (TTA) | Achieved 80.68% accuracy by averaging predictions over augmented images. |
| 📈 Learning Rate Finder | Automatically selects the best learning rate with learn.lr_find(). |
Skin-Cancer-Detection-CNN-FastAI/
├── code.ipynb # Main Jupyter Notebook
├── README.md # Project documentation
├── literature_review.pdf # Background research
We use the publicly available Skin Cancer ISIC dataset from Kaggle: 🔗 Skin Cancer 9 Classes (ISIC) - Kaggle
Important Note: To reduce training time and manage resources, the notebook does not use all 9 classes. One or more classes were intentionally excluded during training. You can modify the notebook to include all classes if needed.
- Model Architecture: ResNet18
- Framework: PyTorch
- High-Level API: FastAI
- Training Strategy:
fine_tune+fit_one_cycle - Metrics: Accuracy, Precision-Recall, ROC-AUC
- Visualization: Confusion Matrix, Top Losses, Optimal LR plots
- Dataset Subsetting: Some classes from the original ISIC dataset were excluded for practical training duration.
- Python 3.9+
- Jupyter Notebook or JupyterLab
- Kaggle API (for downloading dataset if not manually done)
# 1. Clone the repository
git clone https://github.com/YOUR_USERNAME/Skin-Cancer-Detection-CNN-FastAI.git
cd Skin-Cancer-Detection-CNN-FastAI
# 2. Install dependencies
pip install fastai timm matplotlib scikit-learn
# 3. Download dataset (manually or via Kaggle CLI)
# Example using Kaggle CLI:
kaggle datasets download -d nodoubttome/skin-cancer9-classesisic
unzip skin-cancer9-classesisic.zip
# 4. Launch Jupyter
jupyter notebook code.ipynbThe model’s performance was assessed using multiple metrics.
This project is licensed under the MIT License. See the LICENSE file for details.

