π« U-Net Lung Segmentation β GAN Fine-Tuning (Model 3B)
This model performs lung segmentation on grayscale chest X-ray images using a U-Net architecture enhanced with:
- Dilated Residual Blocks
- Squeeze-and-Excitation (SE) modules
- Atrous Spatial Pyramid Pooling (ASPP)
- Adversarial Fine-Tuning via PatchGAN (SegGAN)
It was specifically fine-tuned on structurally challenging cases (Hard Examples) using a GAN-based training strategy.
π§ Model Overview
- Base Model: U-Net with ASPP, SE Blocks, Dilated Convolutions
- Framework: Keras / TensorFlow
- Use Case: Semantic segmentation of lungs in chest X-rays
- Focus: Robustness in difficult or degraded image regions
βοΈ Architecture Summary
Component | Description |
---|---|
Encoder | 6 stages with Dilated Residual Blocks + SE modules |
Bottleneck | ASPP module with dilation rates 6, 12, 18 + GAP |
Decoder | Skip connections, UpSampling, Progressive channel reduction |
Output Layer | 1Γ1 Conv2D + Sigmoid for binary mask |
GAN Discriminator | PatchGAN (BΓHΓWΓ1) for local realism checks |
π― Training Strategy: SegGAN
Adversarial Setup:
- Generator: U-Net (frozen encoder + ASPP)
- Discriminator: PatchGAN
- Loss Functions:
combined_loss
: Dice + Binary Crossentropygan_loss
: Binary Crossentropy with label smoothing
- Optimizers:
- Generator: Adam (lr = 1e-4)
- Discriminator: Adam (lr = 1e-5, Ξ²1 = 0.5, Ξ²2 = 0.9)
- EarlyStopping: Based on validation Dice stagnation
π§ͺ Fine-Tuning on Hard Examples (Model 3B)
To further increase robustness, the GAN-finetuned model was retrained on a curated subset of 300 low-performing masks (lowest Dice scores) out of 21,165 total samples.
These cases included:
- Heavily rotated or flipped chest X-rays
- Fragmented masks
- Very low-contrast or noisy images
CLAHE preprocessing was applied to enhance contrast.
π Evaluation Results
β Final Test Set Performance (CLAHE Preprocessed)
Metric | Value |
---|---|
Average Dice Score | 0.9768 |
Average IoU Score | 0.9551 |
Combined Loss | 0.0649 |
π Training Metrics (Epoch 50)
Epoch | Train Dice | Train IoU | Val Dice | Val IoU | Val Loss | LR |
---|---|---|---|---|---|---|
50 | 0.9843 | 0.9690 | 0.9603 | 0.9245 | 0.0644 | 5e-6 |
𧬠Usage
from huggingface_hub import hf_hub_download
import tensorflow as tf
# Download model
model_path = hf_hub_download(repo_id="maja011235/lung-segmentation-gan", filename="entwickeltes_masken_model.h5")
# Load with Keras
model = tf.keras.models.load_model(model_path, compile=False)
# Compile (optional)
model.compile(loss=..., metrics=...)
- Downloads last month
- 32
Inference Providers
NEW
This model isn't deployed by any Inference Provider.
π
Ask for provider support