Skip to content

About

Classifying 7 types of skin lesions from dermoscopic images using the HAM10000 dataset. The project compares CNN-based and Transformer-based architectures, and combines the two best-performing models in an ensemble.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

Skin Lesion Classification with Deep Learning

Classifying 7 types of skin lesions from dermoscopic images using the HAM10000 dataset. The project compares CNN-based and Transformer-based architectures, and combines the two best-performing models in an ensemble.

HAM10000 — 10,015 dermoscopic images across 7 classes:

  • Melanocytic Nevi
  • Melanoma
  • Benign Keratosis
  • Basal Cell Carcinoma
  • Actinic Keratoses
  • Vascular Lesions
  • Dermatofibroma

The dataset is split at the patient level using GroupShuffleSplit on lesion_id to prevent data leakage between splits (72% train / 13% val / 15% test).

Models

Model Test Acc Balanced Acc Macro F1 AUC-ROC
ResNet-50 (Baseline) 0.7590 0.7500 0.6681 0.9548
EfficientNet-B4 0.8507 0.7083 0.7380 0.9712
ConvNeXt-Base 0.8474 0.7634 0.7510 0.9428
Swin Transformer-Base 0.8507 0.7966 0.7719 0.9717
ViT-B/16 0.8566 0.7720 0.7741 0.9629
Ensemble (EfficientNet-B4 + Swin) 0.8657 0.7998 0.7856 0.9811

Training Setup

All models were trained with the following configuration:

  • Optimizer: AdamW with weight decay 1e-2
  • Loss: CrossEntropyLoss with label smoothing 0.1
  • Mixed precision training (fp16)
  • Gradient clipping (max norm 1.0)
  • WeightedRandomSampler to handle class imbalance
  • Early stopping (patience 7-8 epochs)

CNN models (ResNet-50, EfficientNet-B4, ConvNeXt-Base) used CosineAnnealingWarmRestarts. Transformer models (Swin, ViT) used Linear Warmup followed by Cosine Decay, which proved essential for stable training.

Notebooks

EDA/
    Skin_Cancer_EDA.ipynb

Models/
    Fine_Tuning_ResNet50.ipynb
    Fine_Tuning_EfficientNet_B4.ipynb
    Fine_Tuning_ConvNeXt_Base.ipynb
    Fine_Tuning_Swin_Transformer.ipynb
    Fine_Tuning_ViT_B16.ipynb
    Ensemble_EfficientNet_Swin.ipynb

Ensemble

The ensemble combines EfficientNet-B4 and Swin Transformer-Base using weighted average of softmax probabilities. The optimal weights (EfficientNet 0.4, Swin 0.6) were found via grid search on the validation set. The diversity between a CNN and a Transformer architecture is the main reason the ensemble outperforms each model individually.

Requirements

torch
timm
albumentations
torchmetrics
scikit-learn
pandas
numpy
matplotlib
seaborn

References

  • Tschandl et al., The HAM10000 dataset (2018)
  • Liu et al., Swin Transformer (2021)
  • Dosovitskiy et al., An Image is Worth 16x16 Words (2020)
  • Tan & Le, EfficientNet (2019)
  • Liu et al., A ConvNet for the 2020s (2022)

About

Classifying 7 types of skin lesions from dermoscopic images using the HAM10000 dataset. The project compares CNN-based and Transformer-based architectures, and combines the two best-performing models in an ensemble.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages