RoentGen-v2: Improving Performance, Robustness, and Fairness of Radiographic AI Models with Finely-Controllable Synthetic Data
import torch
from diffusers import DiffusionPipeline
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
pipe = DiffusionPipeline.from_pretrained("stanfordmimi/RoentGen-v2")
pipe = pipe.to(device)
prompt = "50 year old female. Normal chest radiograph."
image = pipe(prompt).images[0]565k synthetic chest radiographs generated with RoentGen-v2 available on HuggingFace here.
Strongly recommended to create a dedicated virtual environment for this project.
A requirements.txt is provided.
After you install the requirements via your package manager, it is important to run pip install --upgrade torch==2.6.0 torchvision==0.21.0 torchaudio==2.6.0 xformers --index-url https://download.pytorch.org/whl/cu126. This downgrades torch in order to ensure version compatibility with monai and torchxrayvision packages. Tested and confirmed to work with wheels for cu126, cu121 and cu118.
To run large-scale multi-gpu distributed inference, use the following commands.
Only inference, no quality check:
accelerate launch --num_processes=1 --mixed_precision bf16 \
roentgenv2/inference_code/run_inference.py \
--config_file="./configs/infer_config_demo.yaml"Only inference, no quality check (multi-gpu):
accelerate launch --num_processes=4 --multi-gpu --mixed_precision bf16 \
roentgenv2/inference_code/run_inference.py \
--config_file="./configs/infer_config_demo.yaml"Inference plus demographics quality check:
accelerate launch --num_processes=1 --mixed_precision bf16 \
roentgenv2/inference_code/run_inference_w_quality_check.py \
--config_file="./configs/infer_config_demo.yaml"Inference plus demographics quality check (multi-gpu):
accelerate launch --num_processes=4 --multi-gpu --mixed_precision bf16 \
roentgenv2/inference_code/run_inference_w_quality_check.py \
--config_file="./configs/infer_config_demo.yaml"In order to finetune RoentGen-v2 on your own dataset, follow the instructions below.
accelerate launch --num_processes=1 --mixed_precision bf16 \
roentgenv2/train_code/train.py \
--config_file="./configs/train_config_demo.yaml"Finetuning (multi-gpu):
accelerate launch --num_processes 4 --multi_gpu --mixed_precision bf16 \
roentgenv2/train_code/train.py \
--config_file="./configs/train_config_demo.yaml"If you find this repository useful for your work, please cite the following paper:
@misc{moroianu2025improvingperformancerobustnessfairness,
title={Improving Performance, Robustness, and Fairness of Radiographic AI Models with Finely-Controllable Synthetic Data},
author={Stefania L. Moroianu and Christian Bluethgen and Pierre Chambon and Mehdi Cherti and Jean-Benoit Delbrouck and Magdalini Paschali and Brandon Price and Judy Gichoya and Jenia Jitsev and Curtis P. Langlotz and Akshay S. Chaudhari},
year={2025},
eprint={2508.16783},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2508.16783},
}