Downloads · 30 days
6
4% of all-time downloads
karadi97/medgemma-histolab-5k
medgemma-histolab-5k is a image-text-to-text model from karadi97. 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 apache-2.0.
A QLoRA fine-tuned adapter on top of google/medgemma-4b-it, trained to classify histopathology patches across three benchmark datasets.
Downloads · 30 days
6
4% of all-time downloads
All-time downloads
140
Public
Repo size
69.1 MB
Likes
0
Public
Click a slice to open those files.
.safetensors35.7 MB · 51%
From the Hugging Face model README
A QLoRA fine-tuned adapter on top of google/medgemma-4b-it, trained to classify histopathology patches across three benchmark datasets.
| Dataset | Baseline (zero-shot) | Fine-tuned | Δ |
|---|---|---|---|
| NCT-CRC-HE-100K (9-class) | 53.4% | 89.6% | +36.2 pp |
| PatchCamelyon (2-class) | ~60% | 85.2% | +25.2 pp |
| BACH ICIAR 2018 (4-class) | ~40% | 68.3% | +28.3 pp |
| Overall | 53.4% | 81.0% | +27.6 pp |
google/medgemma-4b-it (4B parameter multimodal LLM)| Dataset | Task | Classes | Samples used |
|---|---|---|---|
| NCT-CRC-HE-100K | 9-class tissue classification | Adipose, Background, Debris, Lymphocyte, Mucus, Muscle, Normal, Stroma, Tumor | 5 000 |
| PatchCamelyon | Binary metastasis detection | Normal, Tumor | 5 000 |
| BACH ICIAR 2018 | 4-class breast cancer grading | Normal, Benign, InSitu, Invasive | ~400 (full dataset) |
This repo contains only the LoRA adapter weights (~35 MB). The base model
(google/medgemma-4b-it) is downloaded separately and requires a HuggingFace
token with access to the gated MedGemma model.
The notebook handles everything: GPU setup, model download, adapter loading, and launches a public Gradio UI.
git clone https://github.com/karaditya/medgemma-histolab
cd medgemma-histolab
pip install -e .
export HF_TOKEN=hf_...
export ADAPTER_REPO_ID=karadi97/medgemma-histolab-5k
python app.py
from transformers import AutoProcessor, AutoModelForImageTextToText
from peft import PeftModel
import torch
BASE = "google/medgemma-4b-it"
ADAPTER = "karadi97/medgemma-histolab-5k"
TOKEN = "hf_..." # needs MedGemma access
processor = AutoProcessor.from_pretrained(BASE, token=TOKEN)
base = AutoModelForImageTextToText.from_pretrained(
BASE, torch_dtype=torch.bfloat16, device_map="auto", token=TOKEN
)
model = PeftModel.from_pretrained(base, ADAPTER, token=TOKEN)
model = model.merge_and_unload() # optional: bake adapter in for faster inference
The adapter weights are released under Apache 2.0.
The base model (google/medgemma-4b-it) is subject to
Google's MedGemma Terms of Use.