Architecture Overview
The DenseNet U-Net model combines DenseNet121 as the encoder with a U-Net decoder, leveraging dense connectivity for efficient feature reuse and gradient flow.Key Features
- Encoder: DenseNet121 with dense blocks
- Dense blocks:
[6, 12, 24, 16]layers per block - Growth rate: 32 filters per dense layer
- Decoder: U-Net-style upsampling with skip connections
- Output: 2-class softmax segmentation
Dense Block Architecture
Dense blocks implement dense connectivity where each layer receives feature maps from all preceding layers:models/densenet.py (50-88)
Dense Connectivity Pattern
Each dense layer:- 1×1 Conv: Reduces channels (bottleneck layer)
- 3×3 Conv: Extracts features with
growth_rate=32filters - Concatenation: Concatenates output with input features
Transition Blocks
Transition blocks reduce spatial dimensions and compress feature maps:models/densenet.py (91-108)
- Compression:
reduction=0.5reduces channels by 50% - Downsampling: 2×2 average pooling with stride 2
Complete Model Architecture
models/densenet.py (110-159)
Network Structure
- Encoder
- Decoder
| Block | Layers | Output Channels | Resolution |
|---|---|---|---|
| conv1 | 1 | 64 | H/2 × W/2 |
| pool1 | - | 64 | H/4 × W/4 |
| conv2 | 6 | ~256 | H/4 × W/4 |
| pool2 | - | ~128 | H/8 × W/8 |
| conv3 | 12 | ~512 | H/8 × W/8 |
| pool3 | - | ~256 | H/16 × W/16 |
| conv4 | 24 | ~1024 | H/16 × W/16 |
| pool4 | - | ~512 | H/32 × W/32 |
| conv5 | 16 | ~1024 | H/32 × W/32 |
Advantages of DenseNet U-Net
Dense Connectivity
- Feature Reuse: All layers access features from preceding layers
- Gradient Flow: Improved backpropagation through dense connections
- Parameter Efficiency: Fewer parameters than ResNet for similar performance
U-Net Decoder
- Skip Connections: Preserves spatial information from encoder
- Progressive Upsampling: Gradual resolution recovery
- Multi-scale Features: Combines low and high-level features
Model Weights
Pretrained Weights
The model can optionally load ImageNet-pretrained weights for the DenseNet121 encoder:DigiPathAI Weights
Task-specific weights are available for different datasets:- digestpath_densenet.h5: Trained on DigestPath dataset
- paip_densenet.h5: Trained on PAIP dataset
- camelyon_densenet.h5: Trained on Camelyon dataset
Input/Output Specifications
Input
- Shape:
(batch, height, width, 3) - Flexible dimensions:
(None, None, 3)for variable sizes - Preprocessing: Standard ImageNet normalization
Output
- Shape:
(batch, height, width, 2) - Classes: [background, tissue]
- Activation: Softmax probabilities
The DenseNet U-Net model is particularly effective for tissue segmentation due to its ability to capture fine-grained details through dense connections while maintaining global context through skip connections.
Usage Example
Related Models
Inception-ResNet
Multi-scale feature extraction
DeepLabv3+
Atrous spatial pyramid pooling