Instructions to use OussamaEL/medgemma-ECG-C with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OussamaEL/medgemma-ECG-C with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="OussamaEL/medgemma-ECG-C")# Load model directly from transformers import AutoProcessor, AutoModelForImageTextToText processor = AutoProcessor.from_pretrained("OussamaEL/medgemma-ECG-C") model = AutoModelForImageTextToText.from_pretrained("OussamaEL/medgemma-ECG-C") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use OussamaEL/medgemma-ECG-C with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "OussamaEL/medgemma-ECG-C" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OussamaEL/medgemma-ECG-C", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/OussamaEL/medgemma-ECG-C
- SGLang
How to use OussamaEL/medgemma-ECG-C with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "OussamaEL/medgemma-ECG-C" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OussamaEL/medgemma-ECG-C", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "OussamaEL/medgemma-ECG-C" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OussamaEL/medgemma-ECG-C", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Unsloth Studio new
How to use OussamaEL/medgemma-ECG-C with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for OussamaEL/medgemma-ECG-C to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for OussamaEL/medgemma-ECG-C to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for OussamaEL/medgemma-ECG-C to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="OussamaEL/medgemma-ECG-C", max_seq_length=2048, ) - Docker Model Runner
How to use OussamaEL/medgemma-ECG-C with Docker Model Runner:
docker model run hf.co/OussamaEL/medgemma-ECG-C
# Load model directly
from transformers import AutoProcessor, AutoModelForImageTextToText
processor = AutoProcessor.from_pretrained("OussamaEL/medgemma-ECG-C")
model = AutoModelForImageTextToText.from_pretrained("OussamaEL/medgemma-ECG-C")MedGemma-4B ECG Report Generator
This is a fully merged, standalone model fine-tuned from unsloth/medgemma-4b-pt for ECG interpretation and clinical report generation. It was trained using the Unsloth library for high-efficiency, memory-optimized fine-tuning.
This model is designed to take structured output from a primary ML classifier (which provides findings like "Atrial Fibrillation: 82% confidence, Present") and synthesize it into a coherent, human-readable clinical report, complete with an impression, detailed analysis, and clinical recommendations.
Model Details
- Base Model:
unsloth/medgemma-4b-pt - Fine-tuning Method: Unsloth + LoRA (merged into base model)
- Training Data: 500 curated ECG interpretation examples.
- Evaluation Score: The model achieved an average structural correctness score of Not available / 1.0 on a hold-out set.
Usage
This model follows a standard instruction format. Provide the instruction and the structured input to get a clinical report.
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
model_name = "OussamaEL/medgemma-ECG-C"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype=torch.bfloat16,
device_map="auto",
)
# Alpaca prompt format is required
alpaca_prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
### Instruction:
{}
### Input:
{}
### Response:
{}"""
instruction = "You are a medical AI assistant specializing in ECG interpretation. Analyze the ECG findings and patient context to generate a clinical report."
input_text = """ECG FINDINGS:
- Atrial Fibrillation (AFIB): 95% confidence, Present
- Sinus Tachycardia (STACH): 88% confidence, Present
PATIENT CONTEXT:
68-year-old male with diabetes and hypertension presents with 2 days of worsening shortness of breath and leg swelling."""
inputs = tokenizer(
alpaca_prompt.format(instruction, input_text, ""),
return_tensors="pt"
).to("cuda")
outputs = model.generate(**inputs, max_new_tokens=256)
print(tokenizer.decode(outputs[0], skip_special_tokens=True).split("### Response:")[1].strip())
This model is intended for research and development purposes and is not a substitute for professional medical advice.
- Downloads last month
- 9
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="OussamaEL/medgemma-ECG-C")