Back to paper library
arXiv 2021ICCV 2021Object detectionPaper notes

TOOD

The End of Misalignment

Original paper

TOOD: Task-aligned One-stage Object Detection

Paper authors

Chengjian Feng · Yujie Zhong · Yu Gao · Matthew R. Scott · Weilin Huang

Publication
ICCV 2021Conference
First submitted to arXiv
arXiv:2108.07755
Cite this paper · BibTeX

The citation identifies the linked source version. It cites the original paper and its authors.

@misc{objectdetectiontood2021,
  title = {{TOOD: Task-aligned One-stage Object Detection}},
  author = {Chengjian Feng and Yujie Zhong and Yu Gao and Matthew R. Scott and Weilin Huang},
  year = {2021},
  eprint = {2108.07755},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2108.07755}
}
On this page

Continuing the line of thinking from ATSS, we now explore subsequent research.

Problem Definition

What is object detection? Most people can recite the answer by heart.

It consists of two sub-tasks:

  • Classification: Identifies the most distinguishable part of the object and answers "What is it?"
  • Localization: Precisely outlines the entire boundary and answers "Where is it?"

The problem is that these two tasks can pull in different spatial directions: classification focuses on local salient features, while localization requires the full boundary. When the model optimizes both, their learned feature distributions may differ, causing predictions to “speak past each other.”

In recent years, one-stage detectors have tried to unify the two tasks using the "center hypothesis."

  • FCOS, ATSS: Use a centerness branch so that anchors near the center score higher and the localization loss gets a greater weight.
  • FoveaBox: Simply defines the center region as positive samples.

These designs have indeed improved performance, but two core concerns remain:

  1. Task Independence:

    Most existing methods maintain a "dual-branch architecture": one branch handles classification, the other handles localization.

    The result is a lack of communication between the two tasks, which can lead to situations like:

    • The classification branch says, "This is a dining table"!
    • The localization branch, however, more accurately boxes a pizza.

    Their preferred locations differ, and the combined prediction can be wrong.

  2. Sample Assignment Failure:

    Traditional anchor-based methods use IoU thresholds to determine positive and negative samples; anchor-free methods use geometric rules (like the center region).

    All these strategies are based on an implicit assumption:

    Classification and localization can share the same set of samples.

    But in reality, the optimal points for classification and localization often do not overlap.

    For example, see the figure below:

    It looks like the best localization box (green patch) is not at the object center, and in the end, it's suppressed by an anchor (red patch) that scores higher in classification but is less accurate in localization, resulting in it being discarded during NMS.

In other words: Not only do classification and localization differ in learning direction, they also depend on different sets of samples.

This makes us ask:

  • Since the two are naturally misaligned, can they truly be coordinated?
  • Can we get "the most accurate score" and "the most accurate box" on the same anchor?

Or have our designs all along been fundamentally mistaken?

Problem Solving

Let’s follow the diagram provided by the authors to walk through TOOD’s architecture.

In traditional approaches, after FPN output, features are directly split into two branches, each predicting classification and localization separately. As a result, we often get predictions with high scores but poor boxes, or accurate boxes with low scores that are drowned out during NMS.

Here, the authors' idea is straightforward: explicitly “align” the two branches at the prediction stage.

Task Interaction Features

Let the FPN features be Xfpn∈RH×W×CX^{fpn}\in\mathbb{R}^{H\times W\times C}.

TOOD no longer splits into branches at the start, but first uses a shared trunk to transform feature representations.

We stack NN convolutional layers in sequence (each followed by ReLU), obtaining task interaction features {Xkinter}k=1N\{X^{inter}_k\}_{k=1}^N with different effective receptive fields:

Xkinter={δ ⁣(convk(Xfpn)),k=1δ ⁣(convk(Xk−1inter)),k>1X^{inter}_k= \begin{cases} \delta\!\big(\mathrm{conv}_k(X^{fpn})\big), & k=1\\ \delta\!\big(\mathrm{conv}_k(X^{inter}_{k-1})\big), & k>1 \end{cases}

The purpose of this step is to let classification and localization first use the same stack of interactive features and its different effective receptive fields, rather than working in isolation.

TAP: Layer-wise Attention

But sharing also introduces friction: the preferred layers for classification and localization are actually different.

So, after sharing, we use the Task-Aligned Predictor (TAP) for “division of labor.”

The method is to learn a layer-wise attention w∈RNw\in\mathbb{R}^N from Xkinter{X^{inter}_k} to determine “for a given task, which layers should be emphasized more.”

First, concatenate Xkinter{X^{inter}_k} and perform global average pooling to get xinterx^{inter}, then pass it through two fully connected layers and a Sigmoid:

w=σ ⁣(fc2(δ(fc1(xinter)))) .w=\sigma\!\Big(\mathrm{fc}_2\big(\delta(\mathrm{fc}_1(x^{inter}))\big)\Big)\, .

For “classification” or “localization,” apply element-wise scaling to the kk-th layer’s features:

Xktask=wk⋅Xkinter(k=1,…,N) ,X^{task}_k = w_k \cdot X^{inter}_k \quad (k=1,\dots,N)\, ,

Concatenate all XktaskX^{task}_k into XtaskX^{task}, then use a 1 ⁣× ⁣11\!\times\!1 convolution for dimensionality reduction and another convolution to produce the task-specific prediction tensor:

Ztask=conv2 ⁣(δ(conv1(Xtask))) .Z^{task}=\mathrm{conv}_2\!\big(\delta(\mathrm{conv}_1(X^{task}))\big)\, .

From here, we get the classification probability map P∈RH×W×CclsP\in\mathbb{R}^{H\times W\times C_{\text{cls}}} (after Sigmoid) and bounding box regression B∈RH×W×4B\in\mathbb{R}^{H\times W\times 4}.

BB is the decoded box tensor; before decoding, the localization branch predicts FCOS/ATSS-style distances to the four boundaries, (l,t,r,b)(l,t,r,b).

If a feature point (scaled by stride) corresponds to image coordinates (x,y)(x,y), then the reconstructed box is (x−l,  y−t,  x+r,  y+b)(x-l,\;y-t,\;x+r,\;y+b).

Up to this point, classification and localization still share information on the same features, but each also gets their preferred layer-wise representation.

Explicit Alignment: MM and OO

Sharing alone is not enough—the authors further “lock together” the two tasks at the output.

First, align classification.

From the shared XinterX^{inter}, another spatial probability map M∈RH×W×1M\in\mathbb{R}^{H\times W\times 1} is learned:

M=σ ⁣(conv2(δ(conv1(Xinter)))) .M=\sigma\!\big(\mathrm{conv}_2(\delta(\mathrm{conv}_1(X^{inter})))\big)\, .

It is then combined with the classification probability PP via geometric mean to produce the aligned classification output:

Palign=P×M .P^{align}=\sqrt{P\times M}\, .

The intuition: MM learns from shared features how compatible the two tasks are at this location.

The geometric mean lets both PP and MM influence the aligned score rather than relying on either alone.


Second, align localization.

Localization is more direct: each side of the box can sample a prediction at a learned nearby location.

From XinterX^{inter}, a set of offset maps O∈RH×W×8O\in\mathbb{R}^{H\times W\times 8} is learned, providing a pair of (Δi,Δj)(\Delta i,\Delta j) offsets for each of the four sides. Then, bilinear sampling is performed on BB:

Balign(i,j,c)=B ⁣(i+O(i,j,2c),  j+O(i,j,2c+1),  c),c∈{0,1,2,3} .B^{align}(i,j,c)=B\!\big(i+O(i,j,2c),\;j+O(i,j,2c+1),\;c\big),\quad c\in\{0,1,2,3\}\, .

Meaning: the four sides (top, bottom, left, right) each use a learned offset to bilinearly sample nearby box predictions; the four sides need not use the same point. The authors aim to improve the predictions for each side and align the spatial distributions of classification and localization. The offsets do not explicitly identify a proven best neighbor.

Finally, there’s one last part: how does the model adapt to this alignment?

TOOD designs a simple “ruler” tt to measure whether both the classification score ss and localization quality (IoU) uu are simultaneously high for the same anchor:

t=sα uβ .t = s^{\alpha} \, u^{\beta}\, .

α,β\alpha,\beta control the relative importance of the two tasks.

This ruler has a key property: as long as either side is poor, tt will remain low.

The authors use it in two places: sample assignment and loss weighting.

Task-aligned Sample Assignment

For each ground-truth object, compute tt for all candidate anchors, and select the top mm as positive samples, with the rest as negatives.

This step directly writes “two-task alignment” into the rules for who can be a positive sample.

From now on, the model learns primarily from those examples that are “high-scoring and well-localized,” naturally steering learning toward alignment.

Loss Design

Directly using tt as a soft label can cause numerical stability issues (when α,β\alpha,\beta are large, tt becomes very small).

Thus, the paper adopts instance-level normalization: within each object, scale tt to a reasonable range while retaining the relative localization quality indicated by the maximum IoU of each object.

The method is to set the maximum t^\hat t within an instance to the maximum IoU for that instance:

t^i  =  ti⋅umax⁡tmax⁡ ,umax⁡=max⁡kuk,  tmax⁡=max⁡ktk .\hat t_i \;=\; t_i \cdot \frac{u_{\max}}{t_{\max}}\, ,\qquad u_{\max}=\max_k u_k,\ \ t_{\max}=\max_k t_k\, .

This keeps the soft labels for “difficult objects” (those with low overall tt) from becoming too small, while retaining differences in localization quality between instances.

  • Classification Loss

    Replace the BCE label for positive samples from 1 to t^i\hat t_i, and add a Focal-style hard example modulation (with exponent γ\gamma):

    Lcls=∑i=1Npos∣t^i−si∣γ BCE(si,t^i)  +  ∑j=1Nnegsjγ BCE(sj,0) .L_{cls} =\sum_{i=1}^{N_{pos}} \big|\hat t_i - s_i\big|^{\gamma}\,\mathrm{BCE}(s_i,\hat t_i) \;+\; \sum_{j=1}^{N_{neg}} s_j^{\gamma}\,\mathrm{BCE}(s_j,0)\, .

    The more misaligned positive samples (∣t^i−si∣|\hat t_i-s_i| large), the higher their weight; among negatives, lower scores are suppressed, focusing on hard negatives.

  • Localization Loss

    For positive samples, use t^i\hat t_i as the weight to focus on high-quality boxes, using GIoU as an example:

    Lreg=∑i=1Npost^i LGIoU ⁣(bi,bˉi) .L_{reg}=\sum_{i=1}^{N_{pos}} \hat t_i \, \mathrm{L}_{GIoU}\!\big(b_i,\bar b_i\big)\, .

The paper's total loss is the sum of both:

L=Lcls+Lreg L = L_{cls} + L_{reg}\,

This assignment and weighting mechanism is known as Task Alignment Learning (TAL).

Discussion

All results below are based on MS COCO 2017:

The paper calls its training split trainval135k (115K) and its ablation split minival (5K); final results are reported on test-dev using COCO AP. Those split names are the paper's own wording.

All model architectures use Backbone → FPN → Head, with a single anchor per location (same as ATSS), and pretrained backbones include ResNet-50/101, ResNeXt-101-64×4d. The number of interaction layers in T-head is N=6N=6, and the classification focal parameter is γ=2\gamma=2.

Is T-head Worth Replacing?

The authors first replace the traditional parallel dual-head with the T-head on several one-stage detector bases.

The result is clear: T-head yields a consistent improvement of about +0.7 to +1.9 AP, with fewer parameters and FLOPs.

This table conveys two layers of meaning:

  • Simply using the interaction-sharing → layer-wise division → output alignment head design already achieves strong results.
  • The improvement is consistent, not occasional, indicating that this "interact first, then align" approach is transferable.

TAL Effectiveness

Next is the sample assignment part, where the authors test fixed (geometric/IoU rule-based) and adaptive (learning-based) methods.

The TAL approach uses: t=sαuβt=s^{\alpha}u^{\beta}.

This metric simultaneously determines positive/negative assignment (Top-mm) and positive sample weights t^\hat t.

In the 12-epoch comparison, TAL reaches 40.3 AP, above ATSS at 39.2. At 18 epochs, TAL reaches 40.9 AP, tied with PAA + IoU prediction. The TAL + TAP row predicts from aligned features in the last head tower and reaches 42.5 AP at 18 epochs; this row does not directly substitute the complete T-head, and subtracting the 12-epoch TAL score would mix schedules.

The Complete TOOD

When T-head + TAL are combined, the authors validate both anchor-free and anchor-based versions: 42.5 AP vs. 42.4 AP—almost equally strong.

Compared with corresponding ATSS versions, anchor-free AP rises 3.3 points and anchor-based AP 3.1 points. Under the stricter AP75_{75} metric, the gains are 4.2 and 3.3 points, respectively. This fits the methodology's emphasis:

  • When scores are aligned with localization, box quality improves.

In the anchor-free ablation, TOOD's overall gain (+3.3 AP) is greater than the sum of "T-head + ATSS" (+1.9) and "Parallel head + TAL" (+1.1). Here, head interaction/alignment and TAL's learning rules show a complementary effect.

Comparison with SOTA

Under the same settings on test-dev, single-model single-scale, 2× schedule (24 epochs), scale jitter 480–800:

  • ResNet-101: 46.7 AP; ResNeXt-101-64×4d: 48.3 AP.
  • On matched backbones, TOOD is 3.1 AP above ATSS with ResNet-101 and 2.7 AP above ATSS with ResNeXt-101-64×4d. ResNet-101 GFL has 45.0 AP, 1.7 points below TOOD. The ResNeXt GFL rows use 32×4d rather than TOOD's 64×4d, so those rows are not exactly backbone-matched.

Interestingly, the paper places DCN in the first two layers of the head tower—TOOD’s improvement is 48.3→51.148.3 \rightarrow 51.1 (+2.8 AP), while ATSS is 45.6→47.745.6 \rightarrow 47.7 (+2.1 AP).

These rows show that TOOD also benefits from DCN in this configuration; the larger gain cannot be attributed solely to alignment from this table.

Did “Alignment” Actually Happen?

The authors provide two quantitative observations:

  1. Without NMS, for each instance, the top 50 classification-confidence predictions are taken, and PCC (Pearson correlation coefficient) is calculated for both "classification ranking" and "localization ranking," along with the mean IoU of the top 10.

    With T-head and TAL, PCC rises 0.408→0.452, while mean IoU of the top ten boxes rises 0.637→0.661. Higher scores and better boxes become more synchronized here, although correlation remains far from perfect.

  2. After NMS, the number of correct boxes (IoU≥0.5)/ redundant boxes (IoU≥0.5)/ incorrect boxes (0.1<IoU<0.5) is tallied: correct boxes rise 30,261→30,734, while redundant boxes fall 25,428→15,242 and incorrect boxes 92,677→69,013.

Finally, when looking at these alignment metrics together with AP, the total gain is about +3.3 AP.

How Was Misalignment Improved?

Lastly, the authors provide examples: a high-scoring but inaccurate box may appear near the center while a more accurate box has a lower score; with TOOD, high-scoring and accurate boxes often come closer in the shown cases. This is consistent with the whole design: MM adjusts classification scores, OO samples box sides at learned offsets, and TAL encourages alignment. The figure alone cannot isolate each component's effect.

Conclusion

TOOD addresses the long-standing misalignment between classification and localization with a clean, concise path:

First, T-head lets both tasks use interactive features, then layer-wise attention gives each a different emphasis. Next, MM (classification alignment) and OO (localization alignment) adjust the outputs, while t=sαuβt=s^{\alpha}u^{\beta} connects sample assignment and loss design. Together, they encourage the model to make a high score accompany a more accurate box.

This design reaches 51.1 AP on COCO in the ResNeXt-101-64×4d + DCN configuration and improves stricter metrics such as AP75_{75} in the reported ablations, supporting the paper's claim:

  • Alignment brings more accurate boxes.

However, it comes with some costs: the branches and bilinear sampling add implementation complexity, and the hyperparameters still need checking for each dataset. This paper does not separately test dense small objects, noisy labels, segmentation or pose, so how well the same balance between “sharing and division” transfers remains an open question.

In terms of impact, TOOD puts “score × localization quality” at the center of positive sample assignment and quality-aware classification. Its “share first, then divide” idea is a useful way to think about detection heads. Those are design lessons from this paper; broader adoption would need evidence from later systems.

For engineering use, TOOD is a candidate to benchmark alongside later YOLO and DETR-style detectors. Whether its alignment approach remains efficient and robust depends on the implementation, data and target hardware; the paper's COCO experiments alone cannot settle that question.