Attention Residual UNet for Liver & Hepatic Vessel Segmentation
A deep learning architecture combining UNet, residual connections, and attention mechanisms for automated segmentation of liver, hepatic vessels, and tumors from CT images.
Problem Statement
Medical image segmentation is essential for diagnosis and treatment planning. Traditional approaches like thresholding and region-growing require significant manual intervention and struggle with the varying intensity values in CT scans. The liver and surrounding tissues often have similar intensities, making automated segmentation challenging.
This project addresses two segmentation tasks:
1. Liver + Tumor segmentation from contrast-enhanced CT images
2. Hepatic Vessel + Tumor segmentation for vascular analysis
Architecture
The Attention Residual UNet combines three key components:
UNet Foundation
- Encoder path: Progressive downsampling with convolutional blocks to capture multi-scale features
- Decoder path: Upsampling with transposed convolutions to reconstruct spatial details
- Skip connections: Link encoder to decoder, preserving high-resolution spatial information
Residual Connections
Residual blocks replace standard convolutions, allowing gradients to flow through shortcuts. This enables deeper networks without vanishing gradients—critical for capturing fine anatomical details.
Attention Mechanisms
Spatial attention gates are applied at skip connections to focus on relevant regions while suppressing irrelevant background. The attention map highlights important anatomical structures like liver boundaries and vessels.
Dataset
Medical Segmentation Decathlon dataset:
| Task | Total Images | Training | Validation | Slice Threshold |
|---|---|---|---|---|
| Liver | 54 CT scans | 43 | 11 | <300 slices |
| Hepatic Vessels | 303 CT scans | 172 | 44 | <80 slices |
Images exceeding the slice threshold were excluded to manage computational resources while maintaining segmentation quality.
Training Configuration
| Parameter | Value |
|---|---|
| Optimizer | Adam |
| Learning Rate | 1×10⁻⁴ with scheduler |
| Batch Size | 32 |
| LR Scheduler | Factor 0.5, patience 3 |
| Early Stopping | Patience 5 epochs |
| Loss Function | Dice-Cross Entropy (DiceCE) |
Model Features:
- Liver model: 8 base features (doubling per level)
- Vessel model: 16 base features (larger dataset allowed more capacity)
Results
| Task | Structure | Dice Score |
|---|---|---|
| Liver Segmentation | Liver | 0.88 |
| Liver Segmentation | Tumor | 0.73 |
| Vessel Segmentation | Hepatic Vessels | 0.73 |
| Vessel Segmentation | Tumor | 0.66 |
The model achieved strong performance on larger structures (liver) but faced challenges with smaller, irregular tumor regions due to class imbalance.
Live Demo
Try the interactive segmentation demo at /demos/ct-segmentation — upload NIfTI files and visualize the model's predictions in real-time.
Technologies
- PyTorch + MONAI for model implementation
- Medical Segmentation Decathlon dataset
- Docker for containerized deployment
- FastAPI backend for inference API