MoCaE (Mixture of Calibrated Experts) is MammoMix’s ensemble strategy. Instead of relying on a single model, it trains one YOLOS expert per mammography dataset, calibrates each expert’s raw confidence scores against true IoU, then merges all predictions with Soft-NMS and Score Voting.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.
Pipeline overview
Train one expert per dataset
Each expert is a YOLOS model fine-tuned on a specific mammography dataset. MoCaE ships with three experts configured in At startup,
CONFIGS:mocae.py
mocae.py loads each expert with AutoModelForObjectDetection.from_pretrained pointing at saved_dir, sets the model to .eval(), and moves it to the available device.Build calibration datasets and train calibrators
A raw confidence score from a detector does not reliably predict IoU with the ground truth. MoCaE fits a RandomForest calibrator per expert to map The 512-dimensional image embedding comes from a ResNet-18 with its classification head replaced by Calibrator trainingThe calibrator is fitted on validation-split IoU values and serialised as
(image_embedding, confidence) → predicted IoU.Feature constructionFor every predicted box that passes the 0.5 confidence threshold, MoCaE constructs a 513-dimensional input vector:mocae.py
torch.nn.Identity():mocae.py
mocae.py
calibrator.pkl inside the expert’s saved_dir. At inference time it replaces the expert’s raw pred_scores with predicted IoU values, making scores from different experts directly comparable.Combine predictions with Soft-NMS and Score Voting
At inference time
Score VotingAfter Soft-NMS, Score Voting refines each surviving box’s coordinates by taking a weighted average of all nearby boxes, weighted by IoU similarity and calibrated score:The
combine_predictions merges all expert outputs for each image.Soft-NMSStandard NMS hard-removes any box whose IoU with the top-scoring box exceeds a threshold. Soft-NMS decays scores instead, preserving potentially valid detections:mocae.py
| Parameter | Value | Effect |
|---|---|---|
sigma_nms | 0.08 | Gaussian decay width — smaller value means faster score suppression for overlapping boxes |
iou_nms | 0.65 | IoU threshold used only in linear mode; ignored in default gaussian mode |
method | 'gaussian' | Score decay formula: score × exp(−iou² / sigma_nms) |
mocae.py
sigma_sv parameter controls the width of the IoU-based Gaussian weight:mocae.py
Running the full ensemble
After all three steps above complete,mocae.py evaluates the combined pipeline on each dataset’s test split:
mocae.py
combine_predictions returns the output of MeanAveragePrecision.compute() from torchmetrics, which includes map, map_50, map_75, and size-based variants.
Component summary
Expert models
Three YOLOS models fine-tuned on CSAW, DDSM, and DMID mammography datasets, each stored in
./Weights/.ResNet-18 embeddings
512-dimensional image features extracted from a pretrained ResNet-18 with its classification head removed, used as calibrator input.
Calibrators
Per-expert
RandomForestRegressor (300 trees) that maps (embedding, confidence) to predicted IoU. Saved as calibrator.pkl.Soft-NMS + Score Voting
Gaussian Soft-NMS (
sigma_nms=0.08, iou_nms=0.65) suppresses duplicates softly; Score Voting (sigma_sv=0.08) refines surviving box coordinates.