CompDiff: Hierarchical Compositional Diffusion for Fair and Zero-Shot Intersectional Medical Image Generation

Under review at MICCAI 2026

Mahmoud Ibrahim1,2,3⋆, Bart Elen3, Chang Sun1,2, Gökhan Ertaylan3, Michel Dumontier1,2

1 Institute of Data Science, Maastricht University  ·  2 Dept. of Advanced Computing Sciences, Maastricht University  ·  3 VITO, Belgium

mahmoud.ibrahim@vito.be

Summary

Generators trained on demographically imbalanced medical datasets inherit those imbalances, producing lower-quality images for rare subgroups and failing on demographic intersections that never appeared in training. CompDiff addresses this imbalanced generator problem at the representation level: a Hierarchical Conditioner Network (HCN) factorizes demographic conditioning into shared components, enabling parameter sharing across subgroups and zero-shot generation for unseen demographic combinations. On chest X-rays and fundus images, CompDiff beats both standard fine-tuning and FairDiffusion on overall FID (64.3 vs. 75.1 on chest), subgroup equity (ES-FID), and generalization to held-out intersections (up to 21% FID improvement).

Abstract

Generative models are increasingly used to augment medical imaging datasets for fairer AI. Yet a key assumption often goes unexamined: that generators themselves produce equally high-quality images across demographic groups. Models trained on imbalanced data can inherit these imbalances, yielding degraded synthesis quality for rare subgroups and struggling with demographic intersections absent from training. We refer to this as the imbalanced generator problem. Existing remedies such as loss reweighting operate at the optimization level and provide limited benefit when training signal is scarce or absent for certain combinations. We propose CompDiff, a hierarchical compositional diffusion framework that addresses this problem at the representation level. A dedicated Hierarchical Conditioner Network (HCN) decomposes demographic conditioning, producing a demographic token concatenated with CLIP embeddings as cross-attention context. This structured factorization encourages parameter sharing across subgroups and supports compositional generalization to rare or unseen demographic intersections. Experiments on chest X-rays (MIMIC-CXR) and fundus images (FairGenMed) show that CompDiff compares favorably against both standard fine-tuning and FairDiffusion across image quality (FID: 64.3 vs. 75.1), subgroup equity (ES-FID), and zero-shot intersectional generalization (up to 21% FID improvement on held-out intersections). Downstream classifiers trained on CompDiff-generated data also show improved AUROC and reduced demographic bias, suggesting that architectural design of demographic conditioning is an important and underexplored factor in fair medical image generation.

Method

Standard diffusion models learn demographics from text prompts. That works when a subgroup is well represented in training — but it struggles for rare intersections and completely fails when a combination is missing entirely (for example, no Age 80+ Asian patients in the training set). CompDiff fixes this at the representation level instead of the loss.

  1. Decompose. Age, sex, and race each get their own learned embedding — the building blocks of every demographic intersection.
  2. Compose. A small network (the Hierarchical Conditioner Network, HCN) combines those embeddings into a single demographic token that captures the full intersection.
  3. Condition. The demographic token is concatenated with the CLIP text embeddings and handed to Stable Diffusion as cross-attention context, alongside the clinical description.

Because the parts are learned separately and then composed, the model can produce combinations it never saw during training — enabling zero-shot generation for rare or unseen demographic intersections, while keeping image quality high for the common ones.

Inputs · demographic
Age Sex Race
Input · clinical prompt
“Subtle opacity at the right lung base. No overt pulmonary edema.”
OURS
Hierarchical Conditioner Network (HCN)
  1. Embed each attribute in its own table
  2. Compose via small MLP into one token
  3. Auxiliary classifiers regularise the token
c · demographic token
FROZEN
CLIP text encoder
inherited from Stable Diffusion 2.1
t · text embeddings
concat
Cross-attention context
[ c  ‖  t ]
LoRA-TUNED
Stable Diffusion 2.1 UNet
latent-space denoising; context enters through cross-attention layers
Generated medical image
matched to the requested demographic × clinical description
Original paper figure: CompDiff Hierarchical Conditioner Network architecture. Demographic attributes feed into HCN which produces a token that is concatenated with CLIP text embeddings and used as cross-attention context in Stable Diffusion.
Original paper schematic (full version with all auxiliary heads and HCN internals). The blueprint above is a simplified data-flow view.

Results

Top row: cross-modality metrics (chest & fundus). Bottom row: demographic-control metrics on chest X-ray only. Hover a bar for details.

Table 1 — Overall generation quality and fairness

Mean (std) across three runs. Hover a value for details; the bar under each value shows how close it is to the best in its column (longer = better). best in column · CompDiff row highlighted in teal

Modality Method Image Quality Disease
AUROC ↑
Equity-Scaled FID (ES-FID) ↓
FID ↓ FID-RAD ↓ Sex Race Age
Chest
X-ray
Baseline 82.8(2.2) 8.7(0.1) 0.80(0.00) 98.3(1.3) 122.9(1.2) 111.8(0.7)
FairDiffusion 75.1(0.1) 6.2(0.0) 0.74(0.03) 88.6(0.3) 115.7(0.5) 102.5(0.8)
CompDiff 64.3(0.3) 6.8(0.1) 0.82(0.01) 78.4(0.1) 106.2(0.4) 98.3(0.6)
Fundus Baseline 72.2(0.2) 6.4(0.0) 0.94 82.4(1.4) 105.7(0.1) 97.3(0.8)
FairDiffusion 64.3(0.5) 5.0(0.1) 0.93 76.7(0.9) 106.6(2.2) 98.1(1.3)
CompDiff 54.6(0.4) 4.9(0.1) 0.96 65.2(0.6) 97.7(1.4) 85.1(1.0)

Takeaway. CompDiff achieves the best FID on both modalities and the lowest ES-FID across sex, race, and age — fairer generation with higher overall quality.

Table 2 — FID on selected intersectional subgroups

Subgroups ordered from common to rare; the percentage under each subgroup is its share of the training set. Lower FID is better. The last row shows CompDiff's % improvement over Baseline — every subgroup improves, including the rarest.

Subgroup 60–80Male · White16% of training 40–60Male · White14% of training 18–40Male · White4% of training 40–60Female · Hispanic2% of training 40–60Male · Hispanic1.5% of training 40–60Male · Asian0.5% of training 40–60Female · Asian0.5% of training
Baseline 115.2(1.2) 114.1(1.6) 130.9(1.0) 168.5(1.9) 170.4(9.4) 192.6(4.9) 204.0(5.4)
FairDiffusion 102.9(2.4) 104.6(0.8) 125.4(3.2) 162.0(2.4) 165.6(3.6) 201.7(15.4) 209.4(5.2)
CompDiff 97.6(2.0) 89.3(1.6) 116.9(1.6) 149.0(2.7) 135.0(7.0) 184.5(3.0) 167.9(1.7)
CompDiff
vs Baseline

Takeaway. CompDiff improves FID on every selected subgroup, from the most common (16% of training data) down to the rarest (0.5%). FairDiffusion can even regress on the rarest groups — on fundus, Age 80+ / Male / Black jumps from 229.4 to 300.2 — confirming that loss reweighting alone cannot compensate when training signal is scarce.

Table 3 — Zero-shot generalization to held-out subgroups

These five chest-X-ray demographic intersections were removed entirely from training — the generator never saw a single example from any of them. At inference, each model was asked to generate X-rays for these unseen combinations; lower FID means the generated images look more like the real held-out test set.

Held-out subgroup 18–40Female · Asianunseen 18–40Male · Asianunseen 80+Female · Asianunseen 80+Male · Asianunseen 80+Male · Hispanicunseen
Baseline 183.3 161.3 210.7 208.1 231.7
FairDiffusion 181.7 152.1 247.2 265.5 229.9
CompDiff 159.8 127.6 195.4 206.6 212.2
CompDiff
vs Baseline

Takeaway. CompDiff beats both Baseline and FairDiffusion on every held-out intersection. FairDiffusion is actually worse than Baseline on the two Age 80+ / Asian groups — loss reweighting cannot help when a subgroup has literally no training samples. Hierarchical composition lets CompDiff synthesize unseen intersections from the single-attribute and pairwise embeddings it did see.

See the paper for the downstream classifier evaluation (Table 4) and full ablation study (Table 5).

Pretrained weights are released on Hugging Face: chest X-ray and fundus.

BibTeX

@misc{ibrahim2026compdiff,
      title={CompDiff: Hierarchical Compositional Diffusion for Fair and Zero-Shot Intersectional Medical Image Generation},
      author={Mahmoud Ibrahim and Bart Elen and Chang Sun and G\"okhan Ertaylan and Michel Dumontier},
      year={2026},
      eprint={2603.16551},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2603.16551}
}