Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/tommyngx/MammoMix/llms.txt

Use this file to discover all available pages before exploring further.

MammoMix is a deep learning framework for detecting breast cancer in mammography images. It wraps HuggingFace Transformers-based object detection models — YOLOS and Deformable DETR — in a reproducible training pipeline built on PyTorch, and adds a multi-model ensemble strategy called MoCaE that combines specialist models trained on different mammography datasets to improve detection robustness across imaging conditions.

What MammoMix does

MammoMix treats breast cancer detection as a single-class object detection problem. Each mammography image is processed to predict bounding boxes around cancerous regions, labeled as cancer (class ID 0). The training loop is driven by HuggingFace Trainer with YAML-based configuration, automatic mixed-precision, cosine learning rate scheduling, and optional Weights & Biases experiment tracking built in. After training, test evaluation runs automatically and prints detection metrics including mAP@50.

Supported datasets

MammoMix is designed around three publicly available mammography datasets, each with its own imaging characteristics and annotation format:
DatasetDescription
CSAWKarolinska mammography dataset with radiologist-annotated cancer bounding boxes
DMIDDigital mammography images with bounding box annotations
DDSMDigital Database for Screening Mammography, a large-scale benchmark dataset
All three datasets share the same directory structure after preprocessing with splitting.py, which produces train.txt, val.txt, and test.txt split manifests alongside images/ and labels/ folders containing VOC-format XML annotations.

Supported models

MammoMix supports two transformer-based detection architectures, configured via YAML files in the configs/ directory:
ModelHuggingFace IDConfig fileInput size
YOLOShustvl/yolos-baseconfig_yolos.yaml640×640
Deformable DETRSenseTime/deformable-detrconfig_d_detr.yaml800×800
Both are loaded through AutoModelForObjectDetection.from_pretrained and fine-tuned from ImageNet-pretrained weights with ignore_mismatched_sizes=True to adapt the classification head to the single cancer class.

The MoCaE ensemble

MoCaE (Mixture of Calibrated Experts) is MammoMix’s inference-time ensemble strategy, implemented in mocae.py. It trains one YOLOS model per dataset (CSAW, DDSM, DMID), then at inference:
  1. Calibrates each model’s confidence scores using a RandomForestRegressor fitted on IoU values from validation data, with ResNet-18 image embeddings as additional features.
  2. Combines predictions from all three experts using Soft-NMS with Gaussian score decay.
  3. Refines surviving boxes and scores through Score Voting, a weighted averaging step that pulls nearby boxes toward each other proportional to IoU overlap and calibrated confidence.
This allows MammoMix to leverage domain-specific knowledge from each dataset while producing a single unified set of detections.

Explore MammoMix

Quickstart

Train your first model in five steps, from cloning the repo to reading mAP results.

Architecture

Understand how YOLOS, Deformable DETR, and the MoCaE ensemble fit together.

Training with YOLOS

Full reference for YOLOS training configuration, hyperparameters, and callbacks.

MoCaE ensemble inference

Run calibrated multi-model inference across all three datasets.

Citation

If you use MammoMix in your research, please cite:
@misc{mammomix2025,
  title={MammoMix: Breast Cancer Object Detection},
  author={UTS},
  year={2025},
  url={https://github.com/tommyngx/MammoMix}
}

Build docs developers (and LLMs) love