Downloads · 30 days
0
ImNotTam/medgemma-spider-finetuned
medgemma-spider-finetuned is a machine learning model from ImNotTam. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as apache-2.0.
Fine-tuned MedGemma model for Spider dataset - Medical image analysis with multiple images per patient.
Downloads · 30 days
0
Access
Public
Updated Dec 12, 2025
Repo size
9.3 GB
Likes
0
Public
Click a slice to open those files.
.safetensors9.5 GB · 96%
From the Hugging Face model README
Fine-tuned MedGemma model for Spider dataset - Medical image analysis with multiple images per patient.
google/medgemma-4b-itoutput_medgemma_spider/
├── final_model/ # Full merged model (large)
├── lora_adapters/ # LoRA adapters only (recommended, lightweight)
├── checkpoint-*/ # Training checkpoints
├── trainer_state.json # Training state
└── eval_metrics.json # Evaluation metrics
from unsloth import FastVisionModel
model, processor = FastVisionModel.from_pretrained(
model_name="ImNotTam/medgemma-spider-finetuned",
subfolder="lora_adapters",
load_in_4bit=True,
)
# Enable inference mode
FastVisionModel.for_inference(model)
# Prepare input with multiple images
image_paths = ["path/to/image1.png", "path/to/image2.png", ...]
question = "What do you see in these images?"
messages = [
{
"role": "user",
"content": [
{"type": "image", "image": img_path} for img_path in image_paths
] + [{"type": "text", "text": question}]
}
]
# Generate response
inputs = processor.apply_chat_template(
messages,
add_generation_prompt=True,
tokenize=True,
return_tensors="pt",
).to("cuda")
outputs = model.generate(**inputs, max_new_tokens=512)
response = processor.decode(outputs[0], skip_special_tokens=True)
print(response)
from transformers import AutoModelForVision2Seq, AutoProcessor
model = AutoModelForVision2Seq.from_pretrained(
"ImNotTam/medgemma-spider-finetuned",
subfolder="final_model",
device_map="auto",
torch_dtype="auto"
)
processor = AutoProcessor.from_pretrained(
"ImNotTam/medgemma-spider-finetuned",
subfolder="final_model"
)
# Use same inference code as above
from unsloth import FastVisionModel
from trl import SFTTrainer
# Load LoRA adapter
model, processor = FastVisionModel.from_pretrained(
model_name="ImNotTam/medgemma-spider-finetuned",
subfolder="lora_adapters",
load_in_4bit=True,
)
# Add new LoRA config để train tiếp
model = FastVisionModel.get_peft_model(
model,
r=24,
lora_alpha=48,
lora_dropout=0.1,
finetune_vision_layers=True,
finetune_language_layers=True,
)
# Train với data mới
trainer = SFTTrainer(
model=model,
tokenizer=processor,
train_dataset=your_new_dataset,
# ... training args
)
trainer.train()
lora_adapters/ (lightweight, fast)final_model/ (full model)lora_adapters/ + add new LoRA configpip install unsloth transformers torch trl pillow
Apache 2.0