流匹配胸片去骨 / Flow-Matching Chest X-ray Bone Suppression
中文摘要 把 DeBoneDiT(浙江大学,arXiv:2610.19466)的布朗桥扩散换成流匹配后的权重。 用 1/12 的训练量(49,800 步 vs 600,000 步),在 SZCH-X-Rays 官方 75 张测试集上 取得 BSR / MSE / PSNR / LPIPS 四项第一,SSIM 排第五(共 8 个方法)。 仅供研究,不可用于临床。
⚠️ 本仓库不含 VAE。 必须另外从 diaoquesang/DeBoneDiT 下载
2025-12-26-SZCH-X-Rays-VQGAN1.pth,否则模型无法运行。
- Code (training / evaluation / figures): https://github.com/Jestions-dev/fm-cxr-bone-suppression
TL;DR
A 34 M-parameter flow-matching model that removes ribs and clavicles from chest radiographs, trained in the latent space of DeBoneDiT's VQGAN.
Trained for 49,800 steps (12× fewer than the brownian-bridge baseline's 600,000), it beats that baseline on four of five standard metrics on the authors' own benchmark and runs 4× faster at inference.
| Metric | This model | DeBoneDiT (600k steps) | Better? |
|---|---|---|---|
| BSR (%) ↑ | 95.77 | 93.17 | ✅ |
| MSE (10⁻³) ↓ | 0.519 | 1.216 | ✅ |
| PSNR (dB, uncalibrated) ↑ | 33.153 | 29.676 | ✅ |
| PSNR (dB, mean-aligned) ↑ | 33.90 | 31.95 | ✅ |
| LPIPS ↓ | 0.0495 | 0.0776 | ✅ |
| SSIM (%) ↑ | 86.97 | 88.22 | ❌ 5th of 8 |
| Training steps | 49,800 | 600,000 | 12× less |
| Inference (RTX 5070 Laptop) | 2.69 s | 10.66 s | 4× faster |
All metrics computed with DeBoneDiT's own code/metrics.py, which we verified
reproduces their published numbers (max deviation 0.056 dB).
What this is
Paired image-to-image translation: chest radiograph → dual-energy-subtraction (DES) soft-tissue image, i.e. bone suppression.
Method: source-anchored conditional flow matching in a 4×128×128 latent space.
latent x0 = CXR, x1 = bone-suppressed
source s = x0 + 2.0 * z, z ~ N(0, I)
path x_t = (1 - t) * s + t * x1
target v = x1 - s
network SiT-S/2, input = concat(x_t, x0) (8 ch), num_classes = 0
sampling Euler ODE, t: 0 -> 1, 25 steps
There is no text prompt. The conditioning is the source image itself, injected by channel concatenation. This is a paired-translation task, not text-to-image.
Why the noise term matters
With sigma = 0 and the source both as the start point and as a condition, the
velocity becomes algebraically recoverable (v = (x_t - x0) / t) and the network can
trivially satisfy the loss. Measured: 24.30 dB, visibly blurry — it collapses to
the conditional mean. sigma = 2.0 was selected by a non-monotonic sweep
(0 → 24.30, 0.5 → 29.70, 1.03 → 30.38, 2.0 → 31.29, 4.13 → 31.04).
Requirements
pip install torch timm safetensors opencv-python-headless
Pinned to what the model was trained with: timm 1.0.31, torch 2.11.0.
Older/newer timm versions change Attention/PatchEmbed forward semantics and will
silently change the output.
You must also download the VQGAN (not redistributed here):
https://huggingface.co/diaoquesang/DeBoneDiT
-> checkpoints/2025-12-26-SZCH-X-Rays-VQGAN1.pth
Usage
python infer.py \
--ckpt model.safetensors \
--vae 2025-12-26-SZCH-X-Rays-VQGAN1.pth \
--image chest.png \
--out suppressed.png \
--steps 25
Or manually:
import torch
from safetensors.torch import load_file
from model import SiT_models
# 1) this checkpoint (bf16 on disk, upcast to fp32 for exact reproduction)
net = SiT_models["SiT-S/2"](input_size=128, in_channels=8, num_classes=0).cuda()
net.load_state_dict({k: v.float() for k, v in load_file("model.safetensors").items()})
net = net.eval().requires_grad_(False)
# 2) DeBoneDiT's VQGAN
vq = torch.load("2025-12-26-SZCH-X-Rays-VQGAN1.pth", weights_only=False).cuda().eval()
# 3) latent of the CXR, normalised to [-1, 1] at 1024x1024
x0 = vq.encode_stage_2_inputs(x.to("cuda").float())
# 4) integrate
torch.manual_seed(1234)
xt = x0 + 2.0 * torch.randn_like(x0)
for k in range(25):
t = torch.full((1,), k / 25, device="cuda")
xt = xt + net(torch.cat([xt, x0], 1), t * 1000.0)[:, :4] * (1 / 25)
out = vq.decode(xt.float())
model.py is copied verbatim from DeBoneDiT's code/model.py (Apache-2.0,
Copyright 2026 Zhejiang University Team), with only the module-level instantiation removed.
Evaluation
Dataset: SZCH-X-Rays, the authors' official test split — 75 pairs, 1024×1024. Training used the remaining 666 pairs. Leakage check (128×128 pairwise PSNR near-duplicate search): 0 cross-split pairs.
| Model | Steps | BSR (%) ↑ | MSE (10⁻³) ↓ | PSNR ↑ | SSIM (%) ↑ | LPIPS ↓ |
|---|---|---|---|---|---|---|
| DeBoneDiT (official) | 600,000 | 93.17 | 1.216 | 29.676 | 88.22 | 0.0776 |
| This model | 49,800 | 95.77 | 0.519 | 33.153 | 86.97 | 0.0495 |
| Bridge, re-trained at equal budget | 49,800 | 90.54 | 2.231 | 26.977 | 87.08 | 0.0701 |
SSIM ranking (all 8 methods in the original paper's Table 1):
DeBoneDiT 88.20 > MDA-GAN 87.85 > BS-Diff 87.67 > xU-NetFullSharp 87.27 > this model 86.97 > Pix2Pix 83.88 > GL-LCM 80.72 > Yang et al. 78.11
SSIM is a genuine loss, not a rounding artifact. Window-size sweeps (3×3 / 5×5 / 7×7 / 11×11 uniform / 11×11 Gaussian σ=1.5) all leave a 0.009–0.013 deficit, so it is not a measurement artefact. We attribute it to SSIM's 7×7 windows being insensitive to fine-scale texture: this model keeps more high-frequency detail (95% of the ground truth's gradient energy vs 82% for the bridge), but fine detail decorrelates local covariance.
Limitations — read this before using
- Not for clinical use. This is a research checkpoint.
- No lesion-preservation validation. The dataset has no pathology annotations, so we cannot test whether a nodule survives bone removal. "Looks clean" ≠ clinically safe.
- No reader study. No radiologist evaluated these outputs.
- Single institution. Trained and evaluated only on SZCH-X-Rays. Cross-site, cross-vendor generalisation is untested.
- Degrades sharply out of distribution. Shifting input brightness by ±25 grey levels or contrast by ±20% drops PSNR by 11–14 dB, and under darker / lower-contrast inputs the output becomes worse than doing nothing. Test-time input standardisation does not fix it. A bridge model degrades the same way — this is a task/VAE problem, not a flow-matching one.
- Ceiling is the VAE, not the generator. Reconstructing the ground truth through the same VQGAN scores 36.65 dB (mean 0.8910 SSIM). This model reaches 33.15 dB, so ~3.5 dB of headroom sits in the VAE, not in the flow model.
- It is a conditional generator, not a bone detector. Feeding an already-suppressed image gives 22.8 dB self-consistency — it will modify a correct image. Do not apply it iteratively.
- bf16 on disk. Verified to reproduce fp32 to within 0.003 dB; upcast with
.float()for exact numbers.
Training
| Data | SZCH-X-Rays, 666 train / 75 official test |
| Backbone | SiT-S/2, 34.07 M params (same as the baseline) |
| Latent | DeBoneDiT VQGAN, 4×128×128 |
| Steps | 49,800 (300 epochs, batch 4) |
| Optimiser | AdamW, constant lr 1e-4 |
| EMA | 0.995 (the released weights are the EMA copy) |
| Precision | bf16 |
| Hardware | single RTX 5070 Laptop, 8 GB (~3 h) |
| Augmentation | horizontal flip |
Convergence: the last 50 epochs gained +0.06 dB, so the curve is at its plateau.
Licence
- Weights: CC BY-NC 4.0 — inherited from SZCH-X-Rays, which is non-commercial. No commercial use.
model.py: Apache-2.0 (Zhejiang University Team). SeeNOTICE.
Citation
@article{sun2026debonedit,
title = {DeBoneDiT: Depth-Driven Conditional Bridge Diffusion Transformers
for Bone Suppression in Chest X-Ray Images},
author = {Sun, Yifei and Fan, Fenglei and Jia, Junhao and Deng, Wenming and
Xu, Hongxia and Wang, Changmiao and Ge, Ruiquan},
journal = {arXiv preprint arXiv:2610.19466},
year = {2026}
}
If you use this checkpoint, please cite the above as well.
Related work
- RadiT — Scaling Generative Foundation Models for Chest Radiography with Rectified Flow Transformers, arXiv:2606.19460 (2026). Also applies rectified flow to chest radiographs, but for generation / controllable synthesis rather than paired bone suppression, and its weights are not released. To our knowledge this is the first public flow-matching checkpoint for CXR bone suppression.
- Diffusion Bridge or Flow Matching? Zhu et al., ICML 2026 — the unified analysis that motivated this comparison.
- Flow Matching for Generative Modeling, Lipman et al., arXiv:2210.02747.
- Downloads last month
- -