CoolFace
Modelpublic

hugging-science/breast-cancer-detector-2

sourceHugging Faceapache-2.0updated 6mo agoView on Hugging Face
4likes249downloads
Model Card
Overview
Note: This checkpoint was donated to Huggingface-science to support open medical AI research
  • —Anyone intrested in the making of this model please read my blog
  • —Live Demo

Artificial Intelligence has revolutionized software engineering through automation, intelligent code assistance, and streamlined workflows. In the same way, AI is transforming the medical field, particularly in radiology and oncology, by helping clinicians detect diseases earlier and making diagnostic processes faster and more efficient.

The model demonstrates strong generalization and excellent accuracy even on unseen data. However, as a responsible developer, I strongly recommend using this model only as an assistive tool — never as a standalone diagnostic solution. It should always be used in conjunction with the professional judgment of a qualified radiologist or clinician.

huggingface-science/breast-cancer-detector is a three-class image classification model designed to assist healthcare professionals in analyzing breast ultrasound images. It classifies images into:

  • —0: benign — Non-cancerous findings
  • —1: malignant — Suspicious or cancerous findings
  • —2: normal — No visible abnormalities

The model acts as a supportive tool that can help reduce workload, provide a quick second opinion, and contribute to earlier detection of breast cancer — one of the most common cancers affecting women worldwide.

Intended Use
  • —Primary Use: Classification of clean breast ultrasound images to support screening and diagnosis workflows.
  • —Target Users: Radiologists, oncologists, medical researchers, and developers building healthcare AI applications.
  • —Deployment Examples: Integration into web demos (Gradio/Streamlit), hospital decision-support systems, or research pipelines (via Hugging Face Inference API).
  • —Out-of-Scope:
  • —Use with mammography, MRI, CT, or any non-ultrasound modality.
  • —Images with text overlays, annotations, calipers, or other artifacts.
  • —Real-time standalone diagnosis without radiologist review.
  • —Pediatric cases or non-breast ultrasound images.

Important: This model is not a replacement for professional medical judgment. It should always be used alongside expert review.

Training Details
  • —Dataset: gymprathap/Breast-Cancer-Ultrasound-Images-Dataset This dataset contains approximately 1,578 breast ultrasound images (PNG format) categorized into normal, benign, and malignant classes. The images were originally collected from women aged 25–75 years.
  • —Training Size: ~1,500 samples (subset used for training).
  • —Data Augmentation: 20% noise was intentionally added to the training data to improve generalization and robustness against variations in image quality and acquisition conditions.
  • —Training Duration: 12 epochs
  • —Training Metrics (on training and validation sets):
EpochTraining LossValidation LossAccuracy
10.80910.64620.8127
20.49660.47610.8311
30.49880.54650.7388
40.56620.38080.8707
50.38190.28170.9156
60.42440.27130.9288
70.38560.25700.9261
80.34280.24420.9446
90.30870.21630.9446
100.33490.21000.9393
110.35590.22610.9393
120.27070.22480.9446

The model shows strong convergence and high final validation accuracy (~94.46%), with good robustness thanks to the noise augmentation.

Evaluation & Performance
  • —Strengths: The model shows excellent detection performance on the trained distribution. The 20% noise augmentation during training helped improve robustness against real-world variations in ultrasound image quality.
  • —Internal Evaluation: Final validation accuracy of 94.46% after 12 epochs.

External Benchmarking

To further evaluate generalization on unseen data, we tested the model on the external dataset as-cle-bert/breastcanc-ultrasound-class, which contains 647 breast ultrasound images with only two classes (benign_breast_cancer and malignant_breast_cancer).

Note: Since this dataset does not include a "normal" class (while our model supports three classes), we mapped predictions as follows for evaluation:

  • —Model output "benign" → benign_breast_cancer
  • —Model output "malignant" → malignant_breast_cancer
  • —Model output "normal" → excluded from primary metrics (reported separately)
Benchmark Results
  • —Total samples: 647
  • —Samples evaluated (excluding "normal" predictions): 644
  • —"Normal" predictions on this lesion-only dataset: 3 (0.46%)

Performance on Benign vs Malignant Classification:

MetricScore
Accuracy96.12%
Precision (Malignant)94.26%
Recall / Sensitivity (Malignant)93.81%
F1-Score (Malignant)94.03%

Detailed Classification Report:

ClassPrecisionRecallF1-ScoreSupport
benign0.97010.97240.9712434
malignant0.94260.93810.9403210
accuracy--0.9612644
macro avg0.95630.95520.9558644
weighted avg0.96110.96120.9612644

The model demonstrates strong generalization, achieving 96.12% accuracy on this external dataset despite the difference in label space and limited training data. The very low rate of "normal" predictions (0.46%) on images containing only lesions further highlights the model's reliability.

Limitations
  • —Trained on a relatively small dataset (~1,500 samples) derived from ~1,578 images.
  • —Input images must be exclusively clean breast ultrasound images with no text overlays, annotations, markers, or other artifacts.
  • —Only supports the three defined labels (benign, malignant, normal). It cannot handle ambiguous, multi-lesion, or out-of-distribution cases.
  • —Performance may vary across different ultrasound machines, patient demographics (age, ethnicity, breast density), geographic regions, or lower-quality scans.
  • —Small dataset size limits full representation of global diversity.
Ethical Considerations & Risks
  • —Bias & Fairness: The limited dataset may not fully capture variations in imaging equipment, patient populations, or rare presentations. Thorough testing on diverse datasets is strongly recommended.
  • —Clinical Use: False negatives could delay diagnosis; false positives may cause unnecessary anxiety or procedures. Always combine with human expert review.
  • —Privacy: Ensure compliance with local regulations (e.g., HIPAA, GDPR, or Indian DPDP Act) when using real patient data.
  • —Recommendations: Perform external clinical validation before any deployment. Monitor for performance drift in production.

This model follows the spirit of large-scale medical AI efforts (such as Google Health and DeepMind’s breast cancer screening research), which emphasize AI as a powerful assistive tool that augments, rather than replaces, clinical expertise.

How to Use
python
from transformers import pipeline

classifier = pipeline("image-classification", model="huggingface-science/breast-cancer-detector")

result = classifier("path/to/clean_breast_ultrasound_image.png") # you can use a link also
print(result)

The model outputs labels via the mapping:

json
{
  "0": "benign",
  "1": "malignant",
  "2": "normal"
}

Input Requirements: Provide only clean breast ultrasound images (PNG/JPG) without any text or overlays.

Citation

If you use this model, please cite:

Parveshiiii (2026). breast-cancer-detector: A three-class breast ultrasound classifier trained on gymprathap/Breast-Cancer-Ultrasound-Images-Dataset.

Disclaimer: This model is provided for research and assistive purposes only. The developer bears no liability for any clinical decisions made using this tool. Always consult qualified healthcare professionals for medical diagnosis.