README.md

January 7, 2025 ยท View on GitHub

CheXagent

๐Ÿ“ Paper โ€ข ๐Ÿค— Hugging Face โ€ข ๐Ÿงฉ Github โ€ข ๐Ÿช„ Project

Note that the repository and models are only for research purposes and not for clinical use.

๐Ÿค– Model

CheXagent and its "byproducts" are available on Hugging Face:

ModelLinkNote
CheXagentHuggingfaceThe CheXagent model
Vision EncoderHuggingfaceEight SigLIP/CLIP models of various sizes adapted for CXR
Language DecoderHuggingfaceA language model adapted for clinical use cases (especially for radiology)

Check out model_chexagent/chexagent.py for the following usages:

Expand to check the model overview.
class CheXagent:
    def generate(self, paths, prompt): ...
    def view_classification(self, path): ...
    def view_matching(self, paths): ...
    def binary_disease_classification(self, paths, disease_name): ...
    def disease_identification(self, paths, disease_names): ...
    def findings_generation(self, paths, indication): ...
    def findings_generation_section_by_section(self, paths): ...
    def image_text_matching(self, paths, text): ...
    def plot_image(self, path, response, save_path): ...
    def phrase_grounding(self, path, phrase, save_path): ...
    def abnormality_detection(self, path, disease_name, save_path): ...
    def chest_tube_detection(self, path, save_path): ...
    def rib_fracture_detection(self, path, save_path): ...
    def foreign_objects_detection(self, path, save_path): ...
    def temporal_image_classification(self, paths, disease_name): ...
    def findings_summarization(self, findings): ...
    def named_entity_recognition(self, text): ...

๐ŸŽฌ Get started

Get Started (CheXagent)

Run the script to play with CheXagent:

python demos/demos/run_examples.py

or run the following command to interact with CheXagent through a web demo hosted by Gradio:

python demos/app_demos.py

โœจ Evaluation

Download the CheXbench data from HuggingFace and put it to evaluation_chexbench/data.json. The scripts for evaluating FMs on CheXbench are in

+--evaluation_chexbench
|+--axis_1_image_perception
|+--axis_2_image_text_reasoning
|+--axis_3_text_generation

To check whether your environment is set up in the same way as ours, run the following command:

Expand to check the command

Run

python evaluation_chexbench/axis_3_text_generation/run_findings_generation.py

and the result should be close to the following numbers:

Macro F1 (14)Micro F1 (14)Macro F1 (5)Micro F1 (5)Avg
44.958.055.362.555.2

A note: From our experiments in replicating the baselines, the BLEU (or F1RadGraph) scores are affected by the report styles (e.g., sentence orders or even the de-id symbols ("___" in MIMIC-CXR)). F1CheXbert is relatively robust to these variations, which is important since nowadays different models are trained on different preprocessed reports (with various styles).

Comparisons with existing studies
ModelSizeF1CheXbert
Macro F1 (14)Micro F1 (14)Macro F1 (5)Micro F1 (5)Avg
GPT-4V-20.435.519.625.825.3
MARIA-17B38.655.747.756.049.5
MARIA-27B41.658.150.459.152.3
Med-PaLM-M12B37.351.450.656.549.0
Med-PaLM-M84B39.853.651.657.950.7
Med-PaLM-M562B37.351.450.656.549.0
LLaVA-Rad7B39.557.347.757.450.5
CheXagent3B44.958.055.362.555.2

๐Ÿ“š Data

Run the following command to compile the CheXinstruct dataset:

python data_chexinstruct/compile_chexinstruct.py

Run the following command to visualize the CheXinstruct dataset:

python data_chexinstruct/dataset_visualizer.py

๐Ÿฉบ Clinical Reader Study

We provide the reader study interface implementation for future research in this area:

python reader_study/app.py

โœ๏ธ Citation

@article{chexagent-2024,
  title={CheXagent: Towards a Foundation Model for Chest X-Ray Interpretation},
  author={Chen, Zhihong and Varma, Maya and Delbrouck, Jean-Benoit and Paschali, Magdalini and Blankemeier, Louis and Veen, Dave Van and Valanarasu, Jeya Maria Jose and Youssef, Alaa and Cohen, Joseph Paul and Reis, Eduardo Pontes and Tsai, Emily B. and Johnston, Andrew and Olsen, Cameron and Abraham, Tanishq Mathew and Gatidis, Sergios and Chaudhari, Akshay S and Langlotz, Curtis},
  journal={arXiv preprint arXiv:2401.12208},
  url={https://arxiv.org/abs/2401.12208},
  year={2024}
}