Identifies 14 thoracic pathologies plus "No Finding" from frontal chest radiographs using multi-label classification.
NIH ChestX-ray14 — 112K frontal chest X-rays with 14 disease labels.
Reference: Wang et al. 2017, CVPR - "ChestX-ray8: Hospital-scale Chest X-ray Database and Benchmarks"
1from transformers import AutoProcessor, AutoModelForImageTextToText
2from peft import PeftModel
3from PIL import Image
4
5base_model_id = "google/medgemma-4b-it"
6adapter_id = "efecelik/medgemma-chest-xray-lora"
7
8processor = AutoProcessor.from_pretrained(base_model_id)
9model = AutoModelForImageTextToText.from_pretrained(
10 base_model_id, torch_dtype="bfloat16", device_map="auto"
11)
12model = PeftModel.from_pretrained(model, adapter_id)
13
14image = Image.open("chest_xray.jpg").convert("RGB")
15messages = [
16 {"role": "user", "content": [
17 {"type": "image"},
18 {"type": "text", "text": "Analyze this chest X-ray and identify any findings."}
19 ]}
20]
21
22inputs = processor.apply_chat_template(
23 messages, add_generation_prompt=True, tokenize=True,
24 return_dict=True, return_tensors="pt", images=[image]
25).to(model.device)
26
27output = model.generate(**inputs, max_new_tokens=256)
28print(processor.decode(output[0], skip_special_tokens=True))
This adapter is part of the
MedVision AI platform built for the
MedGemma Impact Challenge. It is designed for:
1@inproceedings{wang2017chestx,
2 title={Chestx-ray8: Hospital-scale chest x-ray database and benchmarks},
3 author={Wang, Xiaosong and Peng, Yifan and Lu, Le and Lu, Zhiyong and Bagheri, Mohammadhadi and Summers, Ronald M},
4 booktitle={Proceedings of the IEEE conference on computer vision and pattern recognition},
5 pages={2097--2106},
6 year={2017}
7}