License
This release contains CheXanatomy adapter weights for a PaliGemma-based model.
Use of these weights is subject to:
- the license and usage terms of the underlying PaliGemma/Gemma base model
- the license and terms governing the training data and derived data pipeline
- the license terms in the CheXanatomy code repository for accompanying code
This release is provided for research use.
CheXanatomy: Anatomy-Aware Vision-Language Modeling for Chest Radiographs
This repository contains the released CheXanatomy model for anatomy-aware vision-language modeling on chest radiographs.
CheXanatomy is described in:
CheXanatomy: Anatomy-Aware Vision-Language Modeling for Chest Radiographs
Sergios Gatidis, Curtis Langlotz, Christian Bluethgen
Model Description
CheXanatomy augments a pretrained vision-language model with explicit anatomical supervision in token space. Instead of introducing task-specific decoder heads, the model is trained autoregressively to generate anatomical localization and segmentation outputs as structured tokens.
The model supports anatomy-aware tasks such as:
- anatomical detection
- bounding-box generation
- anatomical segmentation
- anatomy token identification
- transfer to related localization tasks
The training approach uses synthetic chest radiographs generated from CT volumes, with forward-projected anatomical labels providing anatomically consistent 2D supervision.
Intended Use
This model is intended for research use in:
- anatomy-aware medical vision-language modeling
- chest radiograph localization
- chest radiograph anatomical segmentation
- representation learning for radiology imaging
This release is not intended for:
- direct clinical deployment
- autonomous diagnosis
- unsupervised medical decision-making
Training Data
CheXanatomy uses synthetic chest radiograph training data derived from CT volumes. Synthetic chest radiographs can be generated from the CT-RATE dataset together with the CheXsynth pipeline:
The CheXanatomy code repository is available at:
Model Inputs and Outputs
The model takes:
- a chest radiograph image
- a textual prompt
Example prompts:
detect heart
segment left lung
segment aorta
caption <loc0400><loc0312><loc0703><loc0625>
The model generates autoregressive token outputs that may include:
- location tokens such as
<loc0123>
- segmentation tokens such as
<seg045>
- anatomical labels
Segmentation masks may require postprocessing and token decoding using the utilities released in the CheXanatomy code repository.
Usage
Example
1from pathlib import Path
2import torch
3from peft import PeftConfig, PeftModel
4from PIL import Image
5from transformers import PaliGemmaForConditionalGeneration, PaliGemmaProcessor
6
7model_id = "StanfordAIMI/chexanatomy-paligemma-10b-224"
8
9peft_config = PeftConfig.from_pretrained(model_id)
10base_model_id = peft_config.base_model_name_or_path
11
12base_model = PaliGemmaForConditionalGeneration.from_pretrained(base_model_id)
13model = PeftModel.from_pretrained(base_model, model_id)
14processor = PaliGemmaProcessor.from_pretrained(base_model_id)
15
16image = Image.open("ct.png").convert("RGB")
17prompt = "segment left lung"
18
19inputs = processor(image, prompt, return_tensors="pt")
20
21device = "cuda" if torch.cuda.is_available() else "cpu"
22model = model.to(device)
23inputs = {k: v.to(device) for k, v in inputs.items()}
24
25with torch.no_grad():
26 outputs = model.generate(
27 **inputs,
28 max_new_tokens=256,
29 do_sample=False,
30 )
31
32decoded = processor.decode(outputs[0], skip_special_tokens=True)
33print(decoded)