Segmentation, Four Ways
UNet, autoencoder transfer, CLIP fusion & SAM2
05
Year — 2025
Categories
Role
- MSc project — University of Edinburgh
- End-to-end design & evaluation (team of 2)
Do modern shortcuts — self-supervised pre-training, foundation-model features, promptable segmentation — actually beat a classic architecture engineered with care? Four approaches, one dataset, identical evaluation: a custom 20.1M-parameter UNet, an autoencoder-pretrained variant, a CLIP-fused hybrid, and SAM2 trained from scratch. The carefully built UNet more than doubled the baseline. The study’s sharpest insight came from the one that failed.
Problem
Pixel-level segmentation is unforgiving: every ear, tail, and fuzzy outline classified against cluttered backgrounds, 37 breeds, and a dataset riddled with real-world flaws — a 2:1 class imbalance, inconsistent masks, corrupt files, ambiguous boundaries. Everything started with the data: a preprocessing pipeline standardized 7,400 raw images and corrected the imbalance through asymmetric augmentation, producing 11,661 clean, balanced image–mask pairs.
Approach
The UNet used instance normalization for small-batch stability, a spatial dropout schedule graded by depth, bilinear upsampling to eliminate checkerboard artifacts, and a composite weighted cross-entropy + Dice loss. The autoencoder variant pre-trained to excellent reconstruction, then froze its encoder — and let the results expose whether reconstruction features transfer. The CLIP hybrid fused a frozen ViT-B/16’s global semantics into the UNet bottleneck. SAM2 was trained from scratch, under CPU-only memory constraints, for interactive point- and box-prompt segmentation — then shipped as a working Gradio app.
The autoencoder paradox: near-perfect reconstruction, and not a single cat pixel found. What a network learns depends entirely on what you ask it to do.
Results
- Custom UNet mIoU
- 0.69 vs 0.33 baseline
- SAM2 Dice — one click
- 0.889
- SAM2 pixel accuracy
- 91.7%
- Curated training pairs
- 11,661
- Perturbation families tested
- 8
- Architectures compared
- 4
Findings
Simplicity, engineered well, beat sophistication: the plain UNet outperformed both foundation-model fusion and self-supervised pre-training. CLIP fusion underperformed for identifiable reasons, yet uniquely succeeded on breed edge cases the UNet misread. And a systematic robustness study across eight corruption families mapped the exact boundary between graceful degradation and collapse.
- University of Edinburgh
Next case study
06 / 11