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.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.
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 ascancer (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:| Dataset | Description |
|---|---|
| CSAW | Karolinska mammography dataset with radiologist-annotated cancer bounding boxes |
| DMID | Digital mammography images with bounding box annotations |
| DDSM | Digital Database for Screening Mammography, a large-scale benchmark dataset |
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 theconfigs/ directory:
| Model | HuggingFace ID | Config file | Input size |
|---|---|---|---|
| YOLOS | hustvl/yolos-base | config_yolos.yaml | 640×640 |
| Deformable DETR | SenseTime/deformable-detr | config_d_detr.yaml | 800×800 |
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 inmocae.py. It trains one YOLOS model per dataset (CSAW, DDSM, DMID), then at inference:
- Calibrates each model’s confidence scores using a
RandomForestRegressorfitted on IoU values from validation data, with ResNet-18 image embeddings as additional features. - Combines predictions from all three experts using Soft-NMS with Gaussian score decay.
- 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.
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.