Skip to content

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Repository files navigation

VLM: 3D Radiology Report Generation

nnFoundation paper nnFoundationViT models nnFoundationCNN models nnFoundationViT-ReportGen-CT-RATE model nnFoundationViT-ReportGen-Merlin model

RMR paper PrimusM-MAE model ModernBERT-Merlin model

A framework for radiology report generation from 3D medical images, supporting training, inference, and evaluation of vision-language models.

Project Paper Training configurations
nnFoundation nnFoundation: 3D Foundation Models for Radiology paper_configs/nnFoundation
RMR Resolution Meets Reduction: Efficient Visual Context for 3D Radiology Report Generation paper_configs/RMR

nnFoundation: This repository provides the downstream report-generation experiments for nnFoundation. Frozen features from nnFoundationViT or nnFoundationCNN are connected to Qwen2.5-VL-3B through a trainable vision-to-language adapter, with LoRA adaptation of the language model. To generate reports for your own CT volumes, use the released report-generation models instead, which were trained with an updated recipe.

RMR (Resolution Meets Reduction): RMR investigates how to preserve useful visual detail while reducing the token cost of 3D report generation. Its experiments compare input field of view and resolution, visual token compression methods, and language-model choice on CT-RATE and Merlin.

Installation

Use Python 3.12, uv, and a CUDA-capable GPU. Evaluation, including the automatic evaluation after training, requires Java for METEOR. From the repository root:

uv sync --locked --python 3.12

Generating reports with the released models (Inference)

The two released models connect frozen nnFoundationViT features to Qwen3-VL-2B and were trained with an updated recipe. For new data, we recommend them over models trained with the configurations in the nnFoundation paper.

Model Trained on Use for
nnFoundationViT-ReportGen-CT-RATE CT-RATE Chest CT
nnFoundationViT-ReportGen-Merlin Merlin Abdominal CT

inference_nifti.py generates one report per NIfTI volume in a folder. It crops each volume to its TotalSegmentator mask and preprocesses and encodes it as in training, so no preprocessing settings have to be passed. Install the TotalSegmentator extra, download a model, and run it (--nproc_per_node sets the number of GPUs):

uv sync --locked --python 3.12 --extra totalsegmentator
uv run hf download MIC-DKFZ/nnFoundationViT-ReportGen-CT-RATE --local-dir models/ctrate

uv run torchrun --standalone --nproc_per_node=1 inference_nifti.py \
  --checkpoint_dir models/ctrate \
  --input_dir /path/to/chest_ct_volumes \
  --mask_dir /path/to/masks \
  --output_dir /path/to/reports

The reports are saved in inference_results.json in the output folder. See report generation for NIfTI volumes for masks, offline use, batching, and the output files.

Training quick start

The example below trains nnFoundationViT on CT-RATE. Before running it, prepare the dataset JSONs and vision embeddings and export the config's data-path variables, CTRATE_DATASET_JSONS and VLM_EMBEDS, as described there.

Training reads two environment variables:

Variable Purpose
VLM_CONFIG_DIR Root for resolving configuration files
VLM_OUTPUT_DIR Root for saving runs and finding existing runs by folder name

The experiments use an effective batch size of 24. Set the per-GPU batch size and gradient accumulation for your available GPU memory and GPU count:

effective batch size = number of GPUs × per-GPU batch size × gradient accumulation steps

For example, train nnFoundationViT on CT-RATE with one GPU (1 × 3 × 8 = 24):

export VLM_CONFIG_DIR="$PWD/paper_configs/nnFoundation"
export VLM_OUTPUT_DIR="$PWD/output"

uv run python train.py \
  --train_config nnFoundationViT.yml \
  --add_base_configs bases/datasets/ctrate/nnFoundationViT.yml \
  --trainer.per_device_train_batch_size 3 \
  --trainer.gradient_accumulation_steps 8

The example uses $PWD/output. You can set VLM_OUTPUT_DIR to any writable location, including outside the repository, with enough space for checkpoints.

Multi-GPU training uses Distributed Data Parallel (DDP) through torchrun. For four GPUs (4 × 3 × 2 = 24):

uv run torchrun --standalone --nproc_per_node=4 train.py \
  --train_config nnFoundationViT.yml \
  --add_base_configs bases/datasets/ctrate/nnFoundationViT.yml \
  --trainer.per_device_train_batch_size 3 \
  --trainer.gradient_accumulation_steps 2

Set --eval.per_device_batch_size separately to fit report generation in GPU memory. See evaluation settings for the callback and Trainer batch-size distinction.

This nnFoundation recipe saves its configuration and checkpoints under VLM_OUTPUT_DIR, then automatically generates reports and evaluates the final checkpoint on the test set. See inference and evaluation for the output files and directory structure.

Reproducing nnFoundation and RMR experiments

The nnFoundation and RMR experiments initialized the adapter's linear layers with self.model.post_init() (zero-mean normal weights with Qwen's initializer_range, zero biases). The default PyTorch initialization performs better, so the call is disabled by default.

To reproduce the paper results, add --model.post_init to the training command. It affects the Qwen2.5-VL and Qwen3-VL models only.

Documentation

Citation

Please cite the paper corresponding to the configurations or methods you use.

@misc{harsy2026nnfoundation3dfoundationmodels,
  title         = {nnFoundation: 3D Foundation Models for Radiology},
  author        = {Ulrich Harsy, Constantin and Wald, Tassilo and Gotkowski, Karol and others},
  year          = {2026},
  eprint        = {2609.26924},
  archivePrefix = {arXiv},
  primaryClass  = {cs.CV},
  url           = {https://arxiv.org/abs/2609.26924}
}

@misc{suprijadi2026resolutionmeetsreduction,
  title         = {Resolution Meets Reduction: Efficient Visual Context for 3D Radiology Report Generation},
  author        = {Suprijadi, Jonathan and Stock, Raphael and Langenberg, Moritz
                   and Zimmerer, David and Kahl, Kim-Celine and Denner, Stefan
                   and Kirchhoff, Yannick and Gotkowski, Karol and Rokuss, Maximilian
                   and Traub, Jeremias and Wald, Tassilo and Ulrich, Constantin
                   and Maier-Hein, Klaus},
  year          = {2026},
  eprint        = {2608.08713},
  archivePrefix = {arXiv},
  primaryClass  = {cs.CV},
  url           = {https://arxiv.org/abs/2608.08713}
}

The nnFoundation model cards provide the full citation and additional references for the vision encoders and pretraining framework.

License

Project code, documentation, and configurations are licensed under Apache 2.0. See NOTICE.md for upstream attribution. External publications, datasets, pretrained models, and dependencies retain their respective licenses.

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages