Object detectors are scored by COCO Average Precision (AP), a metric that pools every predicted box of a given class across the whole test set, sorts them by confidence, and asks how many of the top-ranked boxes are correct. The ranking losses proposed for detectors do something narrower. They sort candidates only inside one image. A confident false alarm on a cluttered street photo can therefore outrank a correct but modestly scored car in another photo, and lower the reported AP, without any training loss ever comparing the two. We propose a training loss that estimates each box's rank among all same-class predictions in the dataset, using a small cache carried across mini-batches. That estimated rank then decides two things: how hard to push each confidence score, and how much each box's localization error matters for AP.
The setting is a detector with a decoupled head, meaning separate branches for "what is it" and "where is it." Decoupling stops the two tasks from fighting over shared features. It also leaves the confidence score blind to box quality, and existing methods patch that gap with hand-set multipliers. The proposal is meant to show that one dataset-level ranking estimate can supply both missing signals while each gradient still reaches only its own branch.
Core Claim
A meaningful part of the gap between a detector's training objective and its COCO AP comes from misrankings between images, which per-image ranking losses cannot see. A cross-batch rank estimator built for detection can close part of that gap. It needs two corrections that single-vector retrieval methods never required. First, a candidate's correctness depends on its overlap with the ground-truth box (IoU), so a box counts as a true positive at some IoU thresholds and not at others. Second, stale cached entries must be rescored with the current classifier. Decoupled heads make the second correction cheap: the classification branch's final layer is a small linear map, so cached pre-logit features from that branch can be passed through the current weights at almost no cost. The same rank estimate also gives a principled per-box weight for the localization loss, namely how much AP would rise if that box's IoU crossed the next COCO threshold. This weight replaces the fixed exponents in TOOD's alignment score $t=s^{\alpha}u^{\beta}$, which TOOD sets to $\alpha=1$ and $\beta=6$.
Where This Sits
Three detection papers motivate the claim, and all three rank within an image.
- DR Loss ranks the expected foreground score above the expected background score per image. It leaves box regression to a separate loss.
- Revisiting AP Loss: Adaptive Ranking Pair Selection introduces "adaptive false positives": a poorly localized positive is treated as a negative relative to better-localized ones. It selects which pairs to rank with a Gaussian mixture fitted inside each image. We reuse its idea that box quality should decide which positives count as correct. We change where the comparisons come from. - Searching Parameterized AP Loss combines score and IoU into one AP-shaped loss. Its shape parameters are found by reinforcement-learning search over many training runs. The ranking is still computed locally, and the search is expensive.
The method comes from the retrieval and ranking literature, which addresses batch dependence but only for a single score per example.
- Smooth-AP supplies the sigmoid relaxation of the rank indicator. It is confined to the mini-batch, and its performance depends on batch size.
- SOPRC supplies the sampling-rate-invariant estimator and the idea of an auxiliary vector that tracks ranks across iterations. Its ablation reports +1.3% mean AUPRC on iNaturalist from the unbiased estimator alone.
- CBA-MR and global hard-sample mining for re-identification supply cross-batch caches. CBA-MR also names the constraint we must handle: cached entries go stale if features drift quickly.
None of these methods handles candidates whose label depends on a continuous IoU, and none feeds the rank back into a separate localization branch.
TOOD and Decoupled DETR constrain the design. They show that separating the branches helps and that the separated branches then need an explicit alignment signal. Both provide that signal through a fixed product of score and IoU inside pointwise losses. We keep their architectures and replace the alignment heuristic. GIoU remains our localization loss. We change only its per-box weighting.
Research Program
The rank estimate. For each class $c$, the loss estimates the global rank of every candidate box $i$ with score $s_i$. The estimate adds three sources of competitors: the current mini-batch, a cache of recent hard negatives, and a running histogram of all other negative scores:
$$ \hat r_i = 1 + \sum_{j \in B_c} \sigma\!\left(\tfrac{s_j - s_i}{\tau}\right) + \sum_{k \in M_c} \sigma\!\left(\tfrac{\tilde s_k - s_i}{\tau}\right) + \rho_c\, \hat H_c(s_i). $$
The symbols are defined as follows:
- $B_c$ is the set of same-class candidates in the current mini-batch, across all of its images.
- $M_c$ is a cache of the $m$ highest-scoring recent negatives.
- $\tilde s_k$ is the score of cached entry $k$, recomputed by applying the current classifier layer to that entry's stored pre-logit feature.
- $\hat H_c(s_i)$ is the number of remaining negatives with scores above $s_i$, read from a running histogram of negative scores kept over the last few hundred iterations.
- $\rho_c$ is a SOPRC-style correction factor. It rescales counts so that the ratio of positives to negatives matches the training-set ratio rather than the sampled one.
- $\sigma$ is the sigmoid and $\tau$ is the Smooth-AP temperature.
The three tiers are chosen on purpose. Hard negatives near the top of the ranking set AP and must be scored accurately, so they are rescored. The large mass of easy negatives only needs to be counted, so a histogram is enough.
What counts as correct. Following COCO, a positive counts as a true positive at IoU threshold $t$, for $t \in \{0.5, 0.55, \dots, 0.95\}$, only if its IoU $u_i \ge t$. Below that threshold it competes as a negative, which is the adaptive-false-positive idea extended across images. Precision at each threshold is computed from $\hat r_i$, and the classification loss is one minus the average over thresholds of this smoothed AP. Its gradient reaches only the classification branch.
Localization weighting. The localization branch receives GIoU with a per-box weight:
$$ w_i = \frac{1}{T}\sum_{t} \widehat{\mathrm{prec}}_t(\hat r_i)\, g'(u_i - t). $$
Here $T=10$ is the number of thresholds, $\widehat{\mathrm{prec}}_t(\hat r_i)$ is the estimated precision at box $i$'s global rank under threshold $t$, and $g'$ is the derivative of a smooth step. Read together, $w_i$ is approximately the AP gained per unit increase in box $i$'s IoU. Boxes ranked near the top whose IoU is just below a threshold get large weights. Boxes ranked deep in the list, or boxes already far past every threshold, get small ones. The weight is held constant (no gradient flows through it), so the ranking signal does not leak into the localization branch's features. This is our answer to the tension between separating the branches and unifying their objective: one dataset-level quantity is computed, and each branch receives only its own projection of it.
Analysis. Beyond accuracy, the program measures three things:
- Rank error: how far $\hat r_i$ is from the true rank computed by a full pass over the training set at checkpoints.
- Cache staleness: how much the rescored cache values $\tilde s_k$ differ from scores produced by running the current full network on the cached images.
- Gradient conflict: how often the gradients from the two branches point against each other on any parameters the branches still share.
Baselines
Naive reference. The reference point is the standard decoupled-head detector trained with focal loss plus GIoU. Searching Parameterized AP Loss reports RetinaNet with Focal + GIoU at 39.2 AP on COCO. We rerun it ourselves with identical settings so that every method uses the same schedule, augmentation and number of seeds. Any gain must be measured against our own rerun, not against the cited figure.
Strongest ranking competitor. This is APE loss with adaptive pair selection from Revisiting AP Loss. It is the closest method in spirit, since it also uses IoU to decide which positives count as correct, and it reports 41.1 AP for RetinaNet and 41.5 AP for FCOS with ResNet-50. We run it with the authors' published settings and the same epoch budget as our method.
Strongest alignment competitor. This is TOOD's task-aligned head with its alignment learning. The file gives only TOOD's 51.1 AP with a ResNeXt-101-DCN backbone and no ResNet-50 number, so we report our own ResNet-50 rerun as its reference. To isolate the loss, we swap our loss into TOOD's head and leave the head unchanged.
Other reference numbers. DR Loss (41.7 mAP for RetinaNet ResNet-101 on test-dev) and Parameterized AP Loss (40.5 AP for RetinaNet) are reported for completeness. We do not rerun Parameterized AP Loss's search; we use the published searched loss.
Ablations. Five ablations isolate the key ingredient:
- per-image ranking with the same loss, which removes everything cross-image;
- whole-batch ranking with no cache;
- the cache with stored scores that are never rescored;
- no correction for the sampled positive-to-negative ratio;
- TOOD's fixed weights $s u^{6}$ in place of $w_i$.
Fairness and success criterion. Every method gets the same hyperparameter budget of about eight tuning runs on a held-out split of train2017, and every result averages three seeds. Beating a competitor means a gain over the best of APE/ARPS and TOOD (each with ResNet-50) larger than the seed standard deviation. The gain should be concentrated in AP75 and in classes whose per-image prediction counts vary widely, because that is where cross-image misranking should matter most.
Why not just…?
Why not just rank across all images in the mini-batch, or enlarge the batch across GPUs? This is the most serious threat, and the "whole-batch ranking, no cache" ablation tests it directly. SOPRC's analysis argues that a mismatch between the batch's positive-to-negative ratio and the dataset's ratio biases the estimator whatever the batch size. CBA-MR argues that the rare high-score negatives that set the top of the ranking are seldom present in any one batch. Detection batches are small, typically two to four images per GPU. We sweep the total batch from 8 to 64 images. If whole-batch ranking at 64 images matches the cache method, we will say the cache is unnecessary and report the estimator's value as limited to small-batch training.
Why not just use TOOD-style task alignment, since its targets already depend on IoU? Task alignment trains each score toward an absolute target. That could calibrate scores across images implicitly, with no explicit comparison. It is a real threat. The test is the diagnostic described below together with the head-held-fixed comparison. If TOOD's detector already shows little cross-image misranking, our loss should gain nothing on top of it, and we will report that result.
Why not just recalibrate scores per class after training? Any increasing remapping of one class's scores leaves that class's ordering unchanged. COCO AP depends only on that ordering, so post-hoc recalibration cannot fix the cross-image errors we target. Per-image recalibration would be a learned model in its own right and falls outside the "simpler" category.
Why not just search the loss shape, as in Parameterized AP Loss? The search costs many full training runs and still ranks locally. Our weights $w_i$ come from the metric's own threshold structure at no search cost. If the published searched loss beats ours, that would mean the shape of the loss matters more than where the comparisons come from.
Proposed Experiments and Decisive Checks
The go/no-go diagnostic. Before building anything, we take trained Focal+GIoU, APE and TOOD detectors on COCO val2017. For each, we split the AP deficit into two parts: misranked pairs within one image and misranked pairs across images. We do this by computing AP after re-sorting each image's own predictions into their ideal order while leaving cross-image order intact, and the reverse. If cross-image pairs account for under roughly a fifth of the deficit for the strongest detector, the core claim is weak, and the project narrows to the localization weighting alone.
Main experiments. Training and evaluation details:
- COCO: 1x and 2x schedules with ResNet-50 on RetinaNet, FCOS and TOOD heads, reporting AP, AP50 and AP75.
- Transformer detector: a Decoupled DETR run with ResNet-50-DC5, against its reported 47.0 AP.
- VisDrone 2019-DET: this dataset is dense and dominated by small objects, which makes it the strongest test of the claim. The number of objects per image varies widely, so per-image ranks and dataset-level ranks should disagree most there. The reported reference is the asymmetric decoupled head with Vectorized IoU from Lu et al. at 44.6% [email protected]. That number comes from a different detector family (YOLOv5s), so our comparison runs within one detector family.
Two decisive checks. The first is whether the measured cross-image misranking rate falls during training under our loss and not under the per-image ablation. The second is whether rescoring keeps the rank-estimate error flat as the learning rate increases. If rank error grows with learning rate even with rescoring, staleness defeats the approach at practical training speeds. We would then report that limit rather than tune it away.
References
- DR Loss: Improving Object Detection by Distributional Ranking
- Revisiting AP Loss for Dense Object Detection: Adaptive Ranking Pair Selection
- Searching Parameterized AP Loss for Object Detection
- Smooth-AP: Smoothing the Path Towards Large-Scale Image Retrieval
- Exploring the Algorithm-Dependent Generalization of AUPRC Optimization with List Stability
- When False Positive is Intolerant: End-to-End Optimization with Low FPR for Multipartite Ranking
- Mining Hard Samples Globally and Efficiently for Person Reidentification
- TOOD: Task-aligned One-stage Object Detection
- Decoupled DETR: Spatially Disentangling Localization and Classification for Improved End-to-End Object Detection
- Generalized Intersection Over Union: A Metric and a Loss for Bounding Box Regression.
- Object Detection for UAV Aerial Scenarios Based on Vectorized IOU