Downloads · 30 days
5
10% of all-time downloads
vivekkopthsd/pcamvlm-medgemma-lora
pcamvlm-medgemma-lora is a image-text-to-text model from vivekkopthsd. Use it for the image-text-to-text task on the model card, and read the license before you ship it in a product. It is set up for peft. The card lists the license as gemma.
A QLoRA adapter (LoRA r=16, α=32, ~33M trainable params) fine-tuned on top of google/medgemma-1.5-4b-it for two real histopathology tasks on a single model:
Downloads · 30 days
5
10% of all-time downloads
All-time downloads
50
Public
Repo size
658 MB
Likes
0
Public
Click a slice to open those files.
.safetensors65.7 MB · 66%
From the Hugging Face model README
A QLoRA adapter (LoRA r=16, α=32, ~33M trainable params) fine-tuned on top
of google/medgemma-1.5-4b-it for two real histopathology tasks on a single
model:
Adapter only — the base model is the gated MedGemma 1.5 4B (Google, Gemma Terms of Use). It is not re-hosted here. Research/education use only — not a clinical device.
All numbers were produced by eval_scientific.py on the best-eval-loss
training checkpoint (step 1750, eval loss 0.0776), base in 4-bit NF4.
Balanced n=3000 from the held-out test split (mirror:
zacharielegault/PatchCamelyon). Method: logit-level yes/no comparison at
the final prompt position (no sampling, no free-text parsing).
| Metric | Value |
|---|---|
| Accuracy | 0.908 (95% CI 0.897–0.918) |
| Specificity (normal) | 0.943 |
| Sensitivity (tumor) | 0.872 |
| Precision (tumor) | 0.941 |
| F1 (tumor) | 0.904 |
| F1 (normal) | 0.943 |
Balanced n=900 from the official held-out CRC_VAL_HE_7K split (mirror:
1aurent/NCT-CRC-HE). Method: greedy free-text decoding + label parsing.
| Metric | Value |
|---|---|
| Accuracy | 0.876 (95% CI 0.852–0.896) |
| Macro-F1 | 0.876 |
| Unparsed answers | 0 / 900 |
Per-class F1 (support 100 each): BACK 0.985 · NORM 0.943 · ADI 0.936 · DEB 0.921 · MUC 0.930 · TUM 0.846 · LYM 0.840 · MUS 0.762 · STR 0.717.
v1 was fine-tuned with synthetic NCT-CRC distractors; real-data evaluation measured 5.8% (chance-level) on CRC_VAL_HE_7K. v2 trains the 9-way head on real, balanced NCT-CRC data instead, lifting held-out accuracy from 5.8% → 87.6% while PCam holds steady (90.4% → 90.8%).
junyeong-nero/ mini-NCTCRCHE100K), verified disjoint from the CRC_VAL_HE_7K eval set by
image-byte hashing (overlap = 0).src/model.py:patch_siglip_interpolation.import torch
from transformers import AutoModelForImageTextToText, AutoProcessor
from peft import PeftModel
base = "google/medgemma-1.5-4b-it"
processor = AutoProcessor.from_pretrained(base, trust_remote_code=True)
model = AutoModelForImageTextToText.from_pretrained(
base, torch_dtype=torch.bfloat16, device_map="auto")
model = PeftModel.from_pretrained(model, "vivekkopthsd/pcamvlm-medgemma-lora")
model.eval()
# PCam binary
image = Image.open("patch.png").convert("RGB")
messages = [{"role": "user", "content": [
{"type": "image", "image": image},
{"type": "text", "text": "Does the center region of this H&E stained "
"lymph node patch contain tumor tissue? "
"Answer yes or no."},
]}]
inputs = processor.apply_chat_template(
messages, add_generation_prompt=True, tokenize=True,
return_tensors="pt", return_dict=True)
out = model.generate(**inputs, max_new_tokens=10)
print(processor.decode(out[0], skip_special_tokens=True))
For the 9-way NCT task, ask "Which tissue type is shown? Reply with exactly one label from ADI, BACK, DEB, LYM, MUC, MUS, NORM, STR, TUM."
eval_scientific.py, models/eval_metrics.json.models/pcam-medgemma-lora-nct/training_metadata.json.@misc{pcamvlm-medgemma-2026,
title={PcamVLM v2: QLoRA fine-tuning of MedGemma-1.5-4B for PCam and real-data NCT-CRC histopathology classification},
author={Kopu, Vivek},
year={2026},
howpublished={\url{https://huggingface.co/vivekkopthsd/pcamvlm-medgemma-lora}}
}