๐Ÿฉธ MedGemma Leukemia LoRA - Blood Cell Classification Model

Accuracy Recall F1 Training

๐ŸŽฏ 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

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

  1. 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
  2. Population Representation: Dataset demographics may not reflect all patient populations

  3. 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
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for good2idnan/medgemma-1.5-4b-it-leukemia-lora

Adapter
(63)
this model