Fine-tuned LoRA adapter for Google's MedGemma-4B-it model on the ECGInstruct dataset for automated ECG interpretation.
This is a LoRA (Low-Rank Adaptation) fine-tuned version of google/medgemma-4b-it trained on the PULSE-ECG/ECGInstruct dataset containing 1.15M ECG instruction-following examples.
Developed by: convaiinnovations
Base Model: google/medgemma-4b-it
Training Infrastructure: AIRAWAT (C-DAC) - 8x NVIDIA A100 40GB GPUs
Training Duration: ~40 hours (1 epoch)
Final Token Accuracy: 88.23%
Hardware:
Hyperparameters:
Training Metrics:
pip install transformers peft pillow torch
from transformers import AutoModelForImageTextToText, AutoProcessor
from peft import PeftModel
from PIL import Image
# Load base model
base_model_id = "google/medgemma-4b-it"
model = AutoModelForImageTextToText.from_pretrained(
base_model_id,
torch_dtype="auto",
device_map="auto"
)
# Load LoRA adapter
model = PeftModel.from_pretrained(
model,
"convaiinnovations/medgemma-4b-ecginstruct-lora"
)
# Load processor
processor = AutoProcessor.from_pretrained(base_model_id)
# Load ECG image
image = Image.open("ecg_image.png").convert("RGB")
# Prepare prompt
messages = [
{
"role": "user",
"content": [
{"type": "image"},
{"type": "text", "text": "Analyze this ECG and provide a detailed interpretation."}
]
}
]
# Process input
text = processor.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
inputs = processor(text=[text], images=[[image]], return_tensors="pt", padding=True)
inputs = {k: v.to(model.device) for k, v in inputs.items()}
# Generate
outputs = model.generate(
**inputs,
max_new_tokens=512,
do_sample=False,
temperature=None,
top_p=None
)
# Decode
response = processor.decode(outputs[0], skip_special_tokens=True)
print(response)
This model can:
⚠️ Medical Disclaimer: This model is intended for research and educational purposes only. It should not be used as a substitute for professional medical advice, diagnosis, or treatment. Always consult qualified healthcare professionals for medical decisions.
If you use this model, please cite:
@misc{medgemma-ecginstruct-lora,
author = {convaiinnovations},
title = {MedGemma-4B ECGInstruct LoRA},
year = {2025},
publisher = {HuggingFace},
howpublished = {\url{https://huggingface.co/convaiinnovations/medgemma-4b-ecginstruct-lora}}
}
Apache 2.0 (following base model license)
checkpoint-9017/optimizer.pt 617 MBadapter_model.safetensors 308 MBcheckpoint-9017/adapter_model.safetensors 308 MBcheckpoint-9017/rng_state_0.pth 16.4 kBcheckpoint-9017/rng_state_1.pth 16.4 kBcheckpoint-9017/rng_state_2.pth 16.4 kBcheckpoint-9017/rng_state_3.pth 16.4 kBcheckpoint-9017/rng_state_4.pth 16.4 kBcheckpoint-9017/rng_state_5.pth 16.4 kBcheckpoint-9017/rng_state_6.pth 16.4 kBcheckpoint-9017/rng_state_7.pth 16.4 kBcheckpoint-9017/training_args.bin 6.4 kBtraining_args.bin 6.4 kBcheckpoint-9017/scheduler.pt 1.5 kB有文件?提交种子。
提交种子google/medgemma-4b-it