Medical Image Segmentation Project

DermaSeg: Skin Lesion Segmentation

A medical image segmentation project for ISIC 2018 skin lesion boundary segmentation, centered on ResNet-50-backed DeepLabV3 baselines and a custom BA-DeepLabV3 with dynamic ASPP, boundary supervision, and uncertainty-aware refinement.

0.8900 best validation Dice
0.8134 best validation IoU
0.7598 best validation threshold Jaccard
0.7320 final test threshold Jaccard

Customized Boundary-Aware DeepLabV3+ResNet50

The current working model now goes beyond plain torchvision DeepLabV3. The main custom architecture is BA-DeepLabV3, a boundary-aware extension used as a research probe to test how region, contour, and uncertainty cues change lesion segmentation behavior on ISIC.

1

Dilated ResNet-50 Encoder

BA-DeepLabV3 keeps the ResNet-50 encoder family but uses a dilated backbone so high-level features retain more spatial detail than a plain classification network.

2

Dynamic ASPP

Instead of treating ASPP branches equally, the model learns image-dependent branch weights so it can emphasize the dilation scales that best fit each lesion.

3

Dual Region and Boundary Heads

The network predicts coarse lesion logits and explicit boundary logits, making contour supervision a first-class part of training rather than an afterthought.

4

Uncertainty Head

A dedicated uncertainty branch highlights ambiguous pixels, especially around lesion borders where the segmentation task is hardest.

5

Refinement Decoder

Low-level encoder features are fused with region, contour, and uncertainty cues to refine the final lesion mask at full image resolution.

6

Contour-Aware Loss

Training combines overlap loss, boundary BCE, uncertainty supervision, and contour consistency to study whether medically relevant edge information changes the baseline behavior.

Project Focus

DermaSeg is designed to show a serious medical imaging workflow rather than a single isolated notebook result. The current project uses the official ISIC 2018 Task 1 lesion-boundary split and compares supervised segmentation methods across different architectural families.

What the project demonstrates

Real mask-supervised medical segmentation on a public benchmark dataset, reproducible train/validation/test runs, and a codebase that supports classic U-Net variants, non-U-Net CNN baselines, transformer models, and promptable foundation-model extensions.

Why ISIC 2018

ISIC is a clean fit for this repository because it is a 2D RGB medical segmentation task with official lesion masks, making it appropriate for DeepLabV3, U-Net-family models, and transformer-based image segmentation.

Current Result

The strongest completed project result remains a pretrained DeepLabV3 run using a ResNet-50 backbone and ASPP head on the official ISIC train, validation, and test folders. The numbers below come from local tracked runs in this repository.

Model Best Val Dice Best Val IoU Best Val TJ Test Dice Test IoU Test TJ
DeepLabV3 0.8900 0.8134 0.7598 0.8782 0.7991 0.7320

Validation checkpoint selection uses threshold Jaccard for the ISIC task.

DeepLabV3 Architecture

DeepLabV3 is the current strongest completed run in the repository. It was chosen as a serious non-U-Net baseline for RGB medical segmentation rather than as a claim of reproducing the original ISIC challenge winners.

1

Input Image

A `320 x 320` RGB dermoscopic image enters the network as a 3-channel lesion-segmentation sample.

2

ResNet-50 Backbone

A pretrained ResNet-50 extracts increasingly abstract spatial features. In this repo, it serves as the encoder inside torchvision's `deeplabv3_resnet50` implementation, giving the model strong visual priors before any ISIC fine-tuning begins.

3

Atrous Feature Encoding

DeepLabV3 uses dilated convolutions so the receptive field expands without aggressively destroying feature-map resolution.

4

ASPP Context Module

The Atrous Spatial Pyramid Pooling block gathers lesion context at multiple scales, which helps with large, small, smooth, and irregular lesion boundaries.

5

2-Class Segmentation Head

The project predicts `background` vs `lesion` logits, then trains them with combined cross-entropy and Dice loss.

6

Mask Prediction

The best checkpoint is selected by validation threshold Jaccard, then evaluated on the held-out ISIC test set.

Why this model worked here

ISIC is a 2D RGB dataset, so DeepLabV3 matches the data shape naturally. The pretrained ResNet-50 backbone helps transfer low-level texture and boundary cues, while ASPP helps the network reason about lesion scale and contour structure.

Why it matters in the repo

The project is not limited to U-Net variants. DeepLabV3 provides a defensible non-U-Net CNN baseline, which makes the repository stronger as a segmentation portfolio project.

Qualitative Results

These panels come from the saved DeepLabV3 checkpoint on the ISIC test split. Each image shows input, ground-truth mask overlay, and predicted mask overlay for direct visual inspection.

Boundary-Aware Qualitative Results

The best custom-model checkpoint, `BA-DeepLabV3 + CE+Tversky + lr=1e-3`, also has exported panels for direct visual comparison against the baseline. These examples make the custom model visible as more than just a table row.

Model Coverage

DeepLabV3 is the first completed run, but the repository is structured for broader segmentation experiments.

Supervised models in the project

  • U-Net
  • Attention U-Net
  • SegNet
  • U-Net++
  • DeepLabV3
  • BA-DeepLabV3
  • SwinUNetLite
  • SegFormerLite

Foundation-model extensions

  • SAM
  • MedSAM
  • Promptable evaluation script support
  • Qualitative and metric summaries tracked in-repo

Ablation Workflow

The current experiment harness now tracks both architecture and optimization choices rather than a single hand-picked run. The completed sweep is being treated as a discovery study, not just a benchmark: the plain DeepLabV3 baseline stayed strongest, while the boundary-aware and Tversky-family variants exposed how sensitive lesion segmentation is to loss choice and contour supervision.

Loss ablations

  • DeepLabV3: `ce_dice`, `ce_tversky`, `ce_focal_tversky`
  • BA-DeepLabV3: `ce_dice`, `ce_tversky`, `ce_focal_tversky`

Learning-rate ablations

  • DeepLabV3 with fixed `ce_tversky`
  • BA-DeepLabV3 with fixed `ce_tversky`
  • Default sweep: `1e-4`, `3e-4`, `1e-3`

The one-command runner is scripts/run_full_isic_ablation.sh. Run artifacts are written to runs/ablations/ and saved summaries are written to results/ablations/.

Track Best Configuration Test Dice Test IoU Test TJ
Baseline DeepLabV3 + CE+Dice 0.8749 0.7946 0.7375
Boundary-aware BA-DeepLabV3 + CE+Tversky + lr=1e-3 0.8603 0.7707 0.6978

A second runner, scripts/run_ba_component_ablation.sh, isolates the boundary head and uncertainty head on top of the best `BA-DeepLabV3 + CE+Tversky + lr=1e-3` setting.