Instructions to use good2idnan/medgemma-1.5-4b-it-leukemia-lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use good2idnan/medgemma-1.5-4b-it-leukemia-lora with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("google/medgemma-1.5-4b-it") model = PeftModel.from_pretrained(base_model, "good2idnan/medgemma-1.5-4b-it-leukemia-lora") - Transformers
How to use good2idnan/medgemma-1.5-4b-it-leukemia-lora with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="good2idnan/medgemma-1.5-4b-it-leukemia-lora") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("good2idnan/medgemma-1.5-4b-it-leukemia-lora", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use good2idnan/medgemma-1.5-4b-it-leukemia-lora with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "good2idnan/medgemma-1.5-4b-it-leukemia-lora" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "good2idnan/medgemma-1.5-4b-it-leukemia-lora", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/good2idnan/medgemma-1.5-4b-it-leukemia-lora
- SGLang
How to use good2idnan/medgemma-1.5-4b-it-leukemia-lora 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 "good2idnan/medgemma-1.5-4b-it-leukemia-lora" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "good2idnan/medgemma-1.5-4b-it-leukemia-lora", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'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 "good2idnan/medgemma-1.5-4b-it-leukemia-lora" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "good2idnan/medgemma-1.5-4b-it-leukemia-lora", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use good2idnan/medgemma-1.5-4b-it-leukemia-lora with Docker Model Runner:
docker model run hf.co/good2idnan/medgemma-1.5-4b-it-leukemia-lora
- ๐ฉธ MedGemma Leukemia LoRA - Blood Cell Classification Model
๐ฉธ MedGemma Leukemia LoRA - Blood Cell Classification Model
๐ฏ Model Summary
medgemma-1.5-4b-it-leukemia-lora is a parameter-efficient fine-tuned vision-language model specialized for Acute Lymphoblastic Leukemia (ALL) detection from microscopic blood cell images.
Built on Google's MedGemma 1.5 4B IT foundation model and fine-tuned using LoRA (Low-Rank Adaptation), this model achieves high recall for leukemia detectionโcritical for medical screening applications where minimizing false negatives saves lives.
๐ก Key Impact: Early detection of leukemia improves 5-year survival rates from 20% to over 85%.
๐ค Collaborative project โ Originally published at chaudhrysuleman/medgemma-1.5-4b-it-leukemia-lora
โ ๏ธ CRITICAL DISCLAIMER - READ BEFORE USE
THIS MODEL IS FOR RESEARCH AND EDUCATIONAL PURPOSES ONLY
๐ซ What This Model Is NOT:
- โ NOT FDA-approved or cleared for medical use
- โ NOT CE-marked for clinical diagnosis in EU
- โ NOT validated for real-world patient care
- โ NOT a substitute for professional medical diagnosis
- โ NOT suitable for making clinical treatment decisions
โ What This Model IS:
- โ A research demonstration of LoRA fine-tuning techniques
- โ An educational tool for understanding medical AI
- โ A proof-of-concept for the MedGemma Impact Challenge
- โ A benchmark for comparing medical vision-language models
๐ Performance Metrics
| Metric | Value | Description |
|---|---|---|
| Accuracy | 78.15% | Overall classification correctness |
| Leukemia Recall | 83.10% | Ability to detect positive cases (sensitivity) |
| F1 Score | 83.24% | Harmonic mean of precision and recall |
| Test Set | 1,872 images | Unseen evaluation data |
| Training Set | ~10,000 images | C-NMC Leukemia Dataset |
๐งฌ Model Details
Architecture & Training
| Attribute | Value |
|---|---|
| Base Model | google/medgemma-1.5-4b-it |
| Fine-tuning Method | LoRA (Parameter-Efficient Fine-Tuning) |
| Model Type | Vision-Language Model (VLM) |
| Task | Binary Classification (Normal vs. Leukemia) |
| Parameters | ~4B (base) + LoRA adapters |
| Input | Blood cell microscopy images + text prompt |
| Output | Classification label with reasoning |
Developers
- Chaudhry Muhammad Suleman - @chaudhrysuleman
- Muhammad Idnan - @good2idnan
Training Data
The model was trained on the C-NMC Leukemia Classification Dataset, containing:
- Microscopic images of blood cells
- Binary labels: Normal (healthy) vs. ALL (Acute Lymphoblastic Leukemia)
- Single-cell centered images for consistent analysis
๐ Quick Start
โ ๏ธ Before Running This Code
WARNING: This code is for educational/research demonstration only.
- Do NOT use output for medical decisions
- Do NOT apply to real patient samples without proper validation and approval
- Ensure you have appropriate research ethics approval if using real medical data
Installation
pip install transformers peft torch pillow
Basic Usage
import os
import torch
from PIL import Image
from transformers import AutoProcessor, AutoModelForVision2Seq
from peft import PeftModel
BASE_MODEL_ID = "google/medgemma-1.5-4b-it"
LORA_ADAPTER_ID = "chaudhrysuleman/medgemma-1.5-4b-it-leukemia-lora"
hf_token = os.getenv("HF_TOKEN", "").strip() or None
processor = AutoProcessor.from_pretrained(
BASE_MODEL_ID,
trust_remote_code=True,
token=hf_token
)
base_model = AutoModelForVision2Seq.from_pretrained(
BASE_MODEL_ID,
trust_remote_code=True,
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
device_map="auto" if torch.cuda.is_available() else None,
token=hf_token
)
model = PeftModel.from_pretrained(base_model, LORA_ADAPTER_ID, token=hf_token)
model.eval()
image = Image.open("blood_cell.jpg").convert("RGB")
prompt = (
"Analyze this blood cell microscopy image and classify it.\n"
"Is the cell NORMAL or LEUKEMIA (blast)?\n"
"Answer with exactly one of: Normal, Leukemia."
)
messages = [{
"role": "user",
"content": [{"type": "image"}, {"type": "text", "text": prompt}]
}]
text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = processor(images=image, text=text, return_tensors="pt").to(model.device)
with torch.no_grad():
outputs = model.generate(**inputs, max_new_tokens=10, do_sample=False)
print(processor.decode(outputs[0], skip_special_tokens=True))
Try the Demo
๐ฎ Live Demo: LeukemiaScope on HuggingFace Spaces
๐ก Intended Uses
โ Appropriate Uses (Research & Education Only)
| Use Case | Description | Context |
|---|---|---|
| Academic Research | Benchmarking medical VLMs on hematological imaging | University/research lab studies |
| Educational Demonstrations | Teaching LoRA fine-tuning on medical data | Workshops, courses, tutorials |
| Algorithm Development | Baseline for developing improved blood cell classifiers | Computer vision research |
| Transfer Learning | Foundation for other blood cell classification experiments | Research prototyping |
| Performance Comparison | Comparing against other medical AI approaches | Academic benchmarking |
Required Context: All uses must be in non-clinical, research, or educational settings with proper supervision and understanding of limitations.
๐ซ Prohibited Uses
| Use Case | Reason | Risk Level |
|---|---|---|
| Clinical Diagnosis | No regulatory approval (FDA/CE/etc.) | ๐ด CRITICAL |
| Patient Screening | Not validated on clinical populations | ๐ด CRITICAL |
| Treatment Decisions | Could lead to incorrect therapy | ๐ด CRITICAL |
| Sole Decision Maker | Must be combined with expert review | ๐ด CRITICAL |
| Emergency Medicine | Not designed for time-critical decisions | ๐ด CRITICAL |
| Self-Diagnosis | Patients should see qualified doctors | ๐ด CRITICAL |
| Insurance/Legal Purposes | Not legally admissible evidence | ๐ก HIGH |
| Non-blood Cell Images | Trained only on blood microscopy | ๐ก HIGH |
| Other Cancer Types | Specialized for ALL only, not AML/CML/CLL | ๐ก HIGH |
Legal Requirement: Any clinical application requires separate regulatory approval in your jurisdiction (FDA 510(k), CE-IVD marking, etc.).
โ ๏ธ Limitations & Risks
Known Limitations
Dataset Bias: Trained on a single public dataset (C-NMC); may not generalize to:
- Different microscope types
- Alternative staining techniques
- Other leukemia subtypes (AML, CML, CLL)
- Varying image resolutions
Population Representation: Dataset demographics may not reflect all patient populations
False Negatives/Positives: While optimized for high recall, some cases may be misclassified
Safety Recommendations
- โ Always validate on local clinical data before any experimental use
- โ Use as screening support, not final diagnosis
- โ Combine with expert pathologist review
- โ Follow regulatory guidelines for medical AI in your jurisdiction
- โ Never deploy in clinical settings without proper approval
๐ฌ Technical Specifications
Input Requirements
- Image Format: RGB images (PNG, JPG, JPEG)
- Recommended: Single blood cell, centered, clear microscopy
- Resolution: Model handles various resolutions (224x224+ recommended)
Compute Requirements
| Setup | Memory | Inference Time |
|---|---|---|
| GPU (A100/H100) | ~8GB VRAM | ~1-2 sec/image |
| GPU (T4/V100) | ~10GB VRAM | ~3-5 sec/image |
| CPU | ~16GB RAM | ~30-60 sec/image |
๐ Citation
If you use this model in your research, please cite:
@misc{medgemma-leukemia-lora-2026,
author = {Suleman, Chaudhry Muhammad and Idnan, Muhammad},
title = {MedGemma Leukemia LoRA: Parameter-Efficient Fine-Tuning for Blood Cell Classification},
year = {2026},
publisher = {HuggingFace},
url = {https://huggingface.co/chaudhrysuleman/medgemma-1.5-4b-it-leukemia-lora}
}
๐ Resources
| Resource | Link |
|---|---|
| ๐ค Model | good2idnan/medgemma-1.5-4b-it-leukemia-lora |
| ๐ Demo | LeukemiaScope Space |
| ๐ Dataset | C-NMC Leukemia Dataset |
| ๐งฌ Base Model | google/medgemma-1.5-4b-it |
| ๐ป GitHub | LeukemiaScope Repository |
๐ License
This model is released under the Apache 2.0 License, consistent with the MedGemma base model license. See the LICENSE file for details.
๐ Responsible AI Statement
We are committed to the responsible development and use of AI in healthcare:
- Transparency: All limitations and risks are openly disclosed
- Safety: Strong disclaimers against clinical misuse
- Accountability: Contact information provided for reporting concerns
- Education: Clear guidance on appropriate vs. prohibited uses
- Compliance: Encouragement to follow all applicable regulations
Version History
- v1.0 (February 2026): Initial release for MedGemma Impact Challenge
- 83.10% recall on C-NMC test set
- Research/educational use only
Remember: This is a research tool, not a medical device. Human expertise saves lives, not AI alone. ๐ฅ
Built with โค๏ธ for the MedGemma Impact Challenge 2026
- Downloads last month
- 2
Model tree for good2idnan/medgemma-1.5-4b-it-leukemia-lora
Base model
google/medgemma-1.5-4b-it