notebooks/ablation_promptm_unet.ipynb):[!NOTE] Parameter Accounting & Model Weights: The checkpoint files (.pth) store only the trainable visual backbone, stage projection layers, squeeze convolutions, and deep supervision heads (~5.03M to ~5.44M parameters). Frozen language encoder weights are decoupled and loaded dynamically:
- CLIP (
openai/clip-vit-base-patch32): 63.17M parameters (Default text encoder used for Ablations 1–3)- BioBERT (
emilyalsentzer/Bio_ClinicalBERT): 108.31M parameters- Sentence-BERT (SBERT) (
sentence-transformers/all-MiniLM-L6-v2): 22.71M parametersThe Total Parameters column indicates the full end-to-end model (Visual Backbone + Fusion Heads + Text Encoder).
| Operation | Trainable Params | Total Params | Peak Epoch | Peak DSC | Peak NSD |
|---|---|---|---|---|---|
| Multiplication | 5.26M | 68.43M | 24 | 0.8619 ± 0.0028 | 0.7871 ± 0.0041 |
| Concatenation | 5.44M | 68.60M | 26 | 0.8494 ± 0.0010 | 0.7528 ± 0.0021 |
| Hybrid | 5.44M | 68.60M | 28 | 0.8152 ± 0.0014 | 0.7301 ± 0.0025 |
| Fusion Strategy | Trainable Params | Text Encoder | Total Params | Peak Epoch | Peak DSC | Peak NSD | Peak Val VRAM |
|---|---|---|---|---|---|---|---|
| Early Fusion | 5.15M | CLIP (63.17M) | 68.31M | 19 | 0.8622 ± 0.0012 | 0.7928 ± 0.0019 | < 4.3 GB |
| All-Stage Fusion | 5.26M | CLIP (63.17M) | 68.43M | 24 | 0.8619 ± 0.0033 | 0.7871 ± 0.0047 | < 4.3 GB |
| Late Fusion | 5.03M | CLIP (63.17M) | 68.20M | 12 | 0.8576 ± 0.0008 | 0.7675 ± 0.0013 | < 4.3 GB |
| Text Encoder | Pretrained Model | Text Dim | Text Encoder Params | Trainable Params | Total Params | Peak Epoch | Peak DSC | Peak NSD |
|---|---|---|---|---|---|---|---|---|
| Sentence-BERT (SBERT) | all-MiniLM-L6-v2 | 384D | 22.71M | 5.11M | 27.83M | 24 | 0.8702 ± 0.0009 | 0.7896 ± 0.0019 (0.7938 ± 0.0020*) |
| CLIP | clip-vit-base-patch32 | 512D | 63.17M | 5.15M | 68.31M | 19 | 0.8622 ± 0.0012 | 0.7928 ± 0.0019 |
| BioBERT | Bio_ClinicalBERT | 768D | 108.31M | 5.21M | 113.52M | 19 | 0.8466 ± 0.0016 | 0.7584 ± 0.0024 |
| Init Type | Trainable Params | Total Params | Peak Epoch | Peak DSC | Peak NSD |
|---|---|---|---|---|---|
| Random Init | 5.11M | 27.83M | 24 | 0.8702 ± 0.0009 | 0.7896 ± 0.0019 |
| Pretrained | 5.11M | 27.83M | 25 | 0.8667 ± 0.0007 | 0.8096 ± 0.0015 |
1# Clone the repository
2git clone https://github.com/kiuyha/PromptM-UNet.git
3cd PromptM-UNet
4
5# Install dependencies and package
6pip install -e .1import torch
2import yaml
3from promptm_unet.models.PromptMUNet import PromptMUNet
4
5# Load configuration
6with open("configs/default.yml", "r") as f:
7 config = yaml.safe_load(f)
8
9# Instantiate model
10device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
11model = PromptMUNet(config).to(device)
12
13# Load checkpoint
14checkpoint = torch.load("best_model.pth", map_location=device)
15model.load_state_dict(checkpoint["model_state_dict"])
16model.eval()
17
18# Dummy 3D input: (Batch, Channels, Depth, Height, Width)
19dummy_ct = torch.randn(1, 1, 64, 128, 128).to(device)
20prompt = ["spleen segmentation in abdominal CT scan"]
21
22# Forward pass
23with torch.no_grad():
24 prediction = model(dummy_ct, prompt) # Output: (1, 1, 64, 128, 128)
25 probabilities = torch.sigmoid(prediction)
26 binary_mask = (probabilities > 0.5).cpu().numpy()
27
28print(f"Predicted spleen mask shape: {binary_mask.shape}")1accelerate launch -m promptm_unet.cli train \
2 --path.raw_data_dir "/path/to/totalsegmentator_raw" \
3 --path.prepro_data_dir "/path/to/preprocessed_data" \
4 --training.batch_size 2 \
5 --training.epochs 30
6
7# Run multi-tier evaluation
8python -m promptm_unet.cli test \
9 --checkpoint "./experiments/checkpoints/best_model.pth"3D CT Volume (1.5mm / 3.0mm)
│
▼
┌───────────────┐
│ Visual Encoder│ (Residual Vision Mamba - RVM Blocks)
└───────┬───────┘
│
▼
┌───────────────┐ ┌──────────────────┐
│ Bottleneck │ ◄────► │ Text Projection │ ◄── Frozen CLIP / BioBERT / SBERT
└───────┬───────┘ └──────────────────┘ (512D / 768D / 384D)
│ ▲
▼ │ (Multi-Stage Hadamard Product)
┌───────────────┐ │
│ Visual Decoder│ ────────────────┘
└───────┬───────┘
│
▼
Deep Supervision Heads ──► High-Resolution Spleen Binary Mask1@misc{promptm_unet2026,
2 title={PromptM-UNet: Efficient Text-Prompted 3D Medical Image Segmentation Using State-Space Model Mamba for Spleen},
3 author={Shridhara, Ketut and Setyawan, Ivan Andika and Al-Habib, Hasanuddin},
4 year={2026},
5 publisher={Universitas Negeri Surabaya},
6 howpublished={\url{https://github.com/kiuyha/PromptM-UNet}}
7}