Skip to content

MelaNet

Two-stage skin lesion analysis. A U-Net segments the lesion, an EfficientNet-B0 classifies it, and Grad-CAM shows which region drove the prediction.

Dice, U-Net on ISIC 2018
0.85
ROC-AUC, EfficientNet-B0 on ISIC 2020
0.879
recall, full-image classifier
0.80
  • Python
  • PyTorch
  • torchvision
  • OpenCV
  • Albumentations
  • Streamlit
A dermoscopic image of a skin lesion beside its Grad-CAM heatmap, which highlights two regions inside the lesion.

The problem

Skin lesion classifiers are usually reported as one accuracy number. For a screening tool that hides the two things that matter most: whether the model is looking at the lesion at all, and how it behaves when about 98% of the examples are benign.

Pipeline

  1. Dermoscopic image
  2. U-Net segmentation
  3. Lesion crop
  4. EfficientNet-B0
  5. Prediction
  6. Grad-CAM heatmap
Segment first, then classify, then explain the prediction. The highlighted stage is where the key decision sits.

How it works

The pipeline runs in two stages. A U-Net trained on the ISIC 2018 segmentation masks finds the lesion. An EfficientNet-B0 trained on ISIC 2020 then classifies either the cropped lesion region or the full image.

Every prediction comes with a Grad-CAM heatmap, so the person reading the result can see which region drove the call.

Training used mixed precision (AMP, fp16) and Albumentations augmentation on a single RTX 3050. The Streamlit app offers region, full-image and side-by-side modes, and a command-line script covers batch inference.

Two dermoscopic lesion images from ISIC 2020, each beside its Grad-CAM heatmap.
Inputs from ISIC 2020 beside their Grad-CAM heatmaps.
ROC curve for the full-image classifier, with an area under the curve of about 0.88.
ROC curve for the full-image classifier.

The decision

I chose
Keep two classifiers, one on the segmented region and one on the full image, and report both.
Instead of
Shipping only the model with the higher score.
Because
The full-image model wins on ROC-AUC by a hair (0.8793 against 0.8746), but the region model's Grad-CAM stays concentrated inside the lesion. For a tool someone is meant to trust, where the model looks matters as much as the score.

Results

ISIC 2018 for segmentation, ISIC 2020 for classification, threshold 0.5.
ModelDiceROC-AUCAccuracyRecall
U-Net segmentation0.85–––
Region classifier–0.87460.82120.7521
Full-image classifier–0.87930.80150.8034

What broke, and the fix

  1. Precision is low on both classifiers, around 0.07.

    That is what a 98 to 2 class split does at a fixed 0.5 threshold. I report it instead of hiding it, and lead with ROC-AUC because it does not depend on the threshold.

What I would do next

  • Calibrate the decision threshold to a target sensitivity instead of using 0.5.
  • Replace the single train and test split with k-fold cross-validation.
  • Validate on an external dataset. This is an educational project, not a diagnostic tool, and it should not be read as one.