MammoMix uses torchmetrics to compute mean average precision (mAP) for breast cancer detection. All metrics are computed in Pascal VOC coordinate space after converting model outputs from YOLO format.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.
Metric definitions
map — COCO-style mAP (primary metric)
map — COCO-style mAP (primary metric)
The primary summary metric. This is the standard COCO detection metric. It penalises imprecise localisation more than
map averages precision over 10 IoU thresholds from 0.50 to 0.95 in steps of 0.05, then averages over all object sizes.map_50 does, so improvements here indicate genuine advances in both detection and box quality.map_50 — mAP at IoU 0.50 (best-model criterion)
map_50 — mAP at IoU 0.50 (best-model criterion)
Average precision computed at a single IoU threshold of 0.50. A predicted box counts as a true positive when its intersection-over-union with the matched ground-truth box is at least 50%.It is more lenient than
map_50 is used as metric_for_best_model in TrainingArguments, meaning the Trainer saves the checkpoint that maximises this value:map and correlates well with clinical recall in mammography screening, where detecting the lesion at all matters more than tight localisation.map_75 — mAP at IoU 0.75 (strict threshold)
map_75 — mAP at IoU 0.75 (strict threshold)
Average precision at an IoU threshold of 0.75. Only tightly localised predictions count as true positives. A substantially lower
map_75 relative to map_50 indicates the model detects lesions but localises them loosely.map_small — mAP for small objects
map_small — mAP for small objects
Average precision for ground-truth boxes with an area smaller than 32 × 32 pixels (1,024 px²). Small lesions are the hardest to detect and most clinically significant in early-stage mammography.
map_medium — mAP for medium objects
map_medium — mAP for medium objects
Average precision for ground-truth boxes with area between 32² and 96² pixels (1,024–9,216 px²).
map_large — mAP for large objects
map_large — mAP for large objects
Average precision for ground-truth boxes with area greater than 96 × 96 pixels (9,216 px²).
Why map_per_class is removed
torchmetrics.functional.detection.map.mean_average_precision returns a map_per_class tensor by default. MammoMix removes it before returning metrics:
evaluation.py
cancer (id2label={0: 'cancer'}). With a single class, map_per_class duplicates the top-level map value and adds noise to logging dashboards and Trainer checkpointing logic. Removing it keeps the returned dictionary clean and avoids confusing the metric_for_best_model selector.
ModelOutput dataclass
During evaluation MammoMix wraps raw model tensors in a minimal dataclass so that image_processor.post_process_object_detection can process them without importing the full YOLOS output class:
evaluation.py
logits to extract class probabilities and pred_boxes to obtain box coordinates. It applies softmax over logits, filters by the threshold argument (0.5 by default), and converts pred_boxes to Pascal VOC format using the provided target_sizes.
Metric computation flow
evaluation.py
Metric summary table
| Key | IoU threshold | Size filter | Notes |
|---|---|---|---|
map | 0.50–0.95 (10 steps) | All | Primary COCO metric |
map_50 | 0.50 | All | Used as metric_for_best_model |
map_75 | 0.75 | All | Strict localisation quality |
map_small | 0.50–0.95 | area < 1,024 px² | Early-stage lesions |
map_medium | 0.50–0.95 | 1,024–9,216 px² | Mid-size lesions |
map_large | 0.50–0.95 | area > 9,216 px² | Large lesions |
map_per_class | — | — | Removed (single-class detector) |