Instructions to use erasmusmc-bigr/medgemma-4b-lirads-features-lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use erasmusmc-bigr/medgemma-4b-lirads-features-lora with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("google/medgemma-4b-it") model = PeftModel.from_pretrained(base_model, "erasmusmc-bigr/medgemma-4b-lirads-features-lora") - Notebooks
- Google Colab
- Kaggle
MedGemma 4B โ Liver Lesion LI-RADS LoRA Adapter
Fine-tuned LoRA adapter for MedGemma 4B IT (google/medgemma-4b-it) on binary classification of seven LI-RADS features in liver MRI for hepatocellular carcinoma (HCC) detection.
Developed at the Biomedical Imaging Group Rotterdam (BIGR), Erasmus MC, Rotterdam, Netherlands.
Model Details
| Base model | google/medgemma-4b-it |
| Fine-tuning method | LoRA (PEFT) |
| LoRA rank / alpha | 16 / 16 |
| LoRA dropout | 0.05 |
| LoRA target modules | all linear layers |
| Task | Binary classification (present / absent) per LI-RADS feature |
| Input | Multi-sequence MRI patch + text prompt |
| Output | present_prob / absent_prob + binary label |
Training Data
| Split | Patients | Lesions | Feature Pairs |
|---|---|---|---|
| Train | 53 | 106 | 523 |
| Validation (checkpoint selection) | 11 | 23 | 119 |
| Internal test | 12 | 23 | 114 |
| Total (internal) | 76 | 152 | 756 |
- Source: OpenSwiss โ open-access multi-centre liver MRI dataset with HCC cases
- Sequences used: T1 native, T1 hepatic arterial, T1 portal venous, T1 delayed, T2, DWI (ADC)
- Features annotated: 7 LI-RADS major features (see below)
- Annotation: Radiologist-confirmed ground truth
- Ethics & consent: OpenSwiss is a publicly released, de-identified research dataset made available under an open data license; the original data collection was covered by the institutional ethical approvals and patient consent procedures of the contributing centres. No patient-identifiable information is contained in this repository or in the released model weights.
LI-RADS Features
- Delayed phase capsule enhancement
- Delayed phase washout appearance
- Diffusion restriction
- T1 native signal enhancement
- T2 hyperintensity
- Venous phase capsule enhancement
- Venous phase washout appearance
Evaluation
This adapter was evaluated with five-fold patient-level cross-validation on the internal cohort (76 patients, 152 lesions from OpenSwissHCC and LiverHccSeg, followed by external validation on an independent institution. It was compared against prompting-only baselines , the matched fine-tuned model, and a soft-voting ensemble of the two fine-tuned 4B models.
External validation cohort: 107 cases were randomly selected (fixed seed) from the public LLD-MMRI dataset (Lou et al., 2025), sourced from Ningbo Medical Center Lihuili Hospital: hepatocellular carcinoma and hepatic cyst, liver metastases, intrahepatic cholangiocarcinoma, focal nodular hyperplasia and hepatic hemangioma, 107 cases were annotated independently by a single senior abdominal radiologist at Erasmus MC.
Results are reported in the associated manuscript, which is currently under peer review, and will be added here once it is published. For collaboration inquiries in the meantime, please contact the corresponding author.
Reference: Lou, M., Ying, H., Liu, X., Zhou, H.-Y., Zhang, Y., & Yu, Y. (2025). SDR-Former: A Siamese Dual-Resolution Transformer for Liver Lesion Classification Using 3D Multi-Phase Imaging. Neural Networks, 107228. Dataset: LLD-MMRI-Dataset
Usage
from peft import PeftModel
from transformers import AutoProcessor, AutoModelForImageTextToText
import torch
base = AutoModelForImageTextToText.from_pretrained(
"google/medgemma-4b-it",
torch_dtype=torch.bfloat16,
device_map="auto",
)
model = PeftModel.from_pretrained(
base,
"erasmusmc-bigr/medgemma-4b-liver-lesion-lora",
)
processor = AutoProcessor.from_pretrained(
"erasmusmc-bigr/medgemma-4b-liver-lesion-lora"
)
Note: This model expects multi-sequence MRI input formatted with the prompt library from the original study. Standalone inference on arbitrary MRI images is not guaranteed without the preprocessing pipeline.
Note: google/medgemma-4b-it is a gated model on Hugging Face. You must request and be granted access to the base model from Google before you can load it.
Inference
Running this model requires the full inference pipeline from the original study:
- Multi-sequence MRI patch extraction (T1 native, arterial, portal venous, delayed, T2, DWI/ADC)
- Feature-specific prompt formatting (7 LI-RADS features)
- Output probability parsing (present_prob / absent_prob)
The complete pipeline is available at: https://gitlab.com/radiology/radiomics/lai/vision_language_models/liver-lesion-vlm
For enquiries, contact: Dr. Martijn Starmans, Assistant Professor, Erasmus MC m.starmans@erasmusmc.nl
Intended Use & Limitations
- Intended use: Research on automated LI-RADS feature detection in liver MRI.
- Not for clinical use: This model has not been validated for clinical decision-making.
- Dataset size: Trained on a small single-centre dataset (53 patients); performance on out-of-distribution data may vary.
- Annotation scope: Only the 7 LI-RADS features listed above were annotated; the model does not produce overall LI-RADS scores or diagnoses.
Data Availability
- Model weights (this repository): erasmusmc-bigr/medgemma-4b-liver-lesion-lora
- Training/internal test data: OpenSwiss, open-access multi-centre liver MRI dataset (Zenodo)
- External validation data: Images, lesion masks, and diagnosis labels from LLD-MMRI are publicly available under the dataset's own terms (official repository). LI-RADS feature-level annotations for the HCC subset used in this evaluation were generated internally at Erasmus MC and are available from the corresponding author upon reasonable request.
- Inference / preprocessing code: GitLab repository
No patient-identifiable data is included in any of the above resources.
Citation
Allahchim, A. (2026). Biomedical Imaging Group Rotterdam (BIGR), Erasmus MC. (Publication forthcoming โ citation will be updated upon release.)
License
This adapter is derived from google/medgemma-4b-it, which is distributed under Google's Health AI Developer Foundations terms of use โ not the standard Gemma Terms of Use. Use of this adapter, including access to the underlying base model weights, is subject to those terms.
google/medgemma-4b-it is a gated model on Hugging Face; users must request and be granted access from Google before they can load the base model to run this adapter.
- Downloads last month
- 4