Downloads · 30 days
0
shayanyan/gemma3-alzheimer-lora
gemma3-alzheimer-lora is a machine learning model from shayanyan. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for transformers.
This repository contains LoRA-adapter weights for google/gemma-3-4b-it, fine-tuned on the Falah/AlzheimerMRI dataset for single-image Alzheimer’s stage classification from MRI scans.
Downloads · 30 days
0
Access
Public
Updated Aug 26, 2025
Repo size
173 MB
Likes
0
Public
Click a slice to open those files.
.safetensors135 MB · 78%
From the Hugging Face model README
This repository contains LoRA-adapter weights for google/gemma-3-4b-it, fine-tuned on the Falah/Alzheimer_MRI dataset for single-image Alzheimer’s stage classification from MRI scans.
⚠️ Research/educational use only — not for clinical or diagnostic purposes.
Mild_DementedModerate_DementedNon_DementedVery_Mild_Demented{"type":"image"} in the user turn).seq_len=512.Trainer)[q_proj, k_proj, v_proj, o_proj, up_proj, down_proj, gate_proj]Non_Demented (majority class)Moderate_Demented, Very_Mild_Demented)Improvement expected with class balancing, more epochs, or weighted loss.
from transformers import AutoProcessor, AutoModelForImageTextToText
from peft import PeftModel
from PIL import Image
BASE = "google/gemma-3-4b-it"
REPO = "shayanyan/gemma3-alzheimer-lora"
processor = AutoProcessor.from_pretrained(REPO, trust_remote_code=True)
base = AutoModelForImageTextToText.from_pretrained(BASE, device_map="auto", torch_dtype="bfloat16")
model = PeftModel.from_pretrained(base, REPO)
img = Image.open("example_mri.jpg").convert("RGB")
messages = [
{"role":"system","content":[{"type":"text","text":"You are a careful neuroradiology assistant."}]},
{"role":"user","content":[{"type":"text","text":"Classify the Alzheimer stage for this MRI."},{"type":"image"}]},
]
inputs = processor.apply_chat_template(messages, tokenize=True, return_tensors="pt")
inputs = {**inputs, "images": [[img]]}
outputs = model.generate(**{k:v.to(model.device) for k,v in inputs.items()}, max_new_tokens=32)
print(processor.tokenizer.decode(outputs[0], skip_special_tokens=True))