Skip to main content
QUICK REVIEW

[Paper Review] A Parallel Implementation of Computing Mean Average Precision

Beinan Wang|arXiv (Cornell University)|Jun 19, 2022
Machine Learning and Data ClassificationComputer Science14 citations
TL;DR

This paper proposes a parallel, hardware-accelerated implementation of Mean Average Precision (mAP) computation for object detection, replacing sequential loops with vectorized operations using broadcasting, masking, and indexing in PyTorch and TensorFlow. The method enables real-time mAP evaluation during training with minimal performance overhead and achieves mAP values within 0.62% of the standard sequential implementation, demonstrating near-identical accuracy with vastly improved efficiency.

ABSTRACT

Mean Average Precision (mAP) has been widely used for evaluating the quality of object detectors, but an efficient implementation is still absent. Current implementations can only count true positives (TP's) and false positives (FP's) for one class at a time by looping through every detection of that class sequentially. Not only are these approaches inefficient, but they are also inconvenient for reporting validation mAP during training. We propose a parallelized alternative that can process mini-batches of detected bounding boxes (DTBB's) and ground truth bounding boxes (GTBB's) as inference goes such that mAP can be instantly calculated after inference is finished. Loops and control statements in sequential implementations are replaced with extensive uses of broadcasting, masking, and indexing. All operators involved are supported by popular machine learning frameworks such as PyTorch and TensorFlow. As a result, our implementation is much faster and can easily fit into typical training routines. A PyTorch version of our implementation is available at https://github.com/bwangca/fast-map.

Motivation & Objective

  • To address the inefficiency and incompatibility of existing mAP computation methods with deep learning training pipelines.
  • To enable real-time mAP evaluation during training by processing mini-batches of detections and ground truth boxes in parallel.
  • To eliminate I/O bottlenecks from sequential implementations that require dumping detection results to disk.
  • To provide a hardware-accelerated, framework-native solution compatible with PyTorch and TensorFlow.
  • To allow training routines to select model weights based on validation mAP, improving model selection fidelity.

Proposed method

  • Replace sequential loops over class-specific detections with vectorized operations using broadcasting, masking, and indexing across mini-batches.
  • Represent precision and recall as vectors P and Q, where each element corresponds to a detection sorted by confidence score.
  • Compute AP using trapezoidal integration over the PR curve via the formula: (P[i] + P[i-1]) * (Q[i] - Q[i-1]) / 2, summed and averaged across classes.
  • Support both full PR curve evaluation and specific recall levels using tiling and broadcasting to align with recall thresholds.
  • Leverage optimized operators from PyTorch and TensorFlow to enable GPU acceleration and seamless integration into training loops.
  • Use a unified tensor-based representation to handle TP, FP, and ignored detections via logical masking and indexing.

Experimental results

Research questions

  • RQ1Can mAP be computed efficiently and in real time during deep learning training for object detection?
  • RQ2How can the mAP computation pipeline be restructured to support batched, parallel inference without I/O overhead?
  • RQ3What is the numerical difference between a parallel vectorized mAP implementation and the standard sequential method?
  • RQ4To what extent can hardware acceleration improve mAP evaluation performance in training workflows?
  • RQ5Can a framework-native, differentiable mAP implementation be integrated into standard training routines for better model selection?

Key findings

  • The proposed parallel mAP implementation achieves an mAP of 0.6658 on the Pascal VOC 2007 test set, compared to 0.6617 from the sequential baseline, showing a 0.62% relative difference.
  • The discrepancy in mAP values is primarily due to low-level operator differences in computational frameworks, not algorithmic flaws, and is negligible for model evaluation.
  • The method processes entire mini-batches of detections and ground truth boxes simultaneously, eliminating the need for per-class, sequential processing.
  • The implementation is fully compatible with PyTorch and TensorFlow, leveraging their optimized operators for hardware acceleration.
  • The vectorized approach eliminates disk I/O overhead, enabling real-time mAP evaluation during training without performance degradation.
  • The method supports both full PR curve integration and evaluation at specific recall levels using tiling and broadcasting techniques.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.