CoolFace
Modelpublic

good2idnan/medgemma-1.5-4b-it-leukemia-lora

sourceHugging Faceapache-2.0updated 8mo agoView on Hugging Face
0likes5downloads
Model Card

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

<p align="center"> <img src="https://img.shields.io/badge/Accuracy-78.15%25-brightgreen" alt="Accuracy"/> <img src="https://img.shields.io/badge/Leukemia%20Recall-83.10%25-orange" alt="Recall"/> <img src="https://img.shields.io/badge/F1%20Score-83.24%25-blue" alt="F1"/> <img src="https://img.shields.io/badge/Training%20Images-10%2C000+-purple" alt="Training"/> </p>

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

MetricValueDescription
Accuracy78.15%Overall classification correctness
Leukemia Recall83.10%Ability to detect positive cases (sensitivity)
F1 Score83.24%Harmonic mean of precision and recall
Test Set1,872 imagesUnseen evaluation data
Training Set~10,000 imagesC-NMC Leukemia Dataset

๐Ÿงฌ Model Details

Architecture & Training

AttributeValue
Base Modelgoogle/medgemma-1.5-4b-it
Fine-tuning MethodLoRA (Parameter-Efficient Fine-Tuning)
Model TypeVision-Language Model (VLM)
TaskBinary Classification (Normal vs. Leukemia)
Parameters~4B (base) + LoRA adapters
InputBlood cell microscopy images + text prompt
OutputClassification 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

bash
pip install transformers peft torch pillow

Basic Usage

python
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 CaseDescriptionContext
Academic ResearchBenchmarking medical VLMs on hematological imagingUniversity/research lab studies
Educational DemonstrationsTeaching LoRA fine-tuning on medical dataWorkshops, courses, tutorials
Algorithm DevelopmentBaseline for developing improved blood cell classifiersComputer vision research
Transfer LearningFoundation for other blood cell classification experimentsResearch prototyping
Performance ComparisonComparing against other medical AI approachesAcademic benchmarking

Required Context: All uses must be in non-clinical, research, or educational settings with proper supervision and understanding of limitations.


๐Ÿšซ Prohibited Uses

Use CaseReasonRisk Level
Clinical DiagnosisNo regulatory approval (FDA/CE/etc.)๐Ÿ”ด CRITICAL
Patient ScreeningNot validated on clinical populations๐Ÿ”ด CRITICAL
Treatment DecisionsCould lead to incorrect therapy๐Ÿ”ด CRITICAL
Sole Decision MakerMust be combined with expert review๐Ÿ”ด CRITICAL
Emergency MedicineNot designed for time-critical decisions๐Ÿ”ด CRITICAL
Self-DiagnosisPatients should see qualified doctors๐Ÿ”ด CRITICAL
Insurance/Legal PurposesNot legally admissible evidence๐ŸŸก HIGH
Non-blood Cell ImagesTrained only on blood microscopy๐ŸŸก HIGH
Other Cancer TypesSpecialized 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. 1.Dataset Bias: Trained on a single public dataset (C-NMC); may not generalize to:
  2. 2.Different microscope types
  3. 3.Alternative staining techniques
  4. 4.Other leukemia subtypes (AML, CML, CLL)
  5. 5.Varying image resolutions
  1. 1.Population Representation: Dataset demographics may not reflect all patient populations
  1. 1.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

SetupMemoryInference 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:

bibtex
@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

ResourceLink
๐Ÿค— Modelgood2idnan/medgemma-1.5-4b-it-leukemia-lora
๐Ÿš€ DemoLeukemiaScope Space
๐Ÿ“Š DatasetC-NMC Leukemia Dataset
๐Ÿงฌ Base Modelgoogle/medgemma-1.5-4b-it
๐Ÿ’ป GitHubLeukemiaScope 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