NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Re-Attention Transformer for Weakly Supervised Object Localization

Hui Su, Yue Ye, Zhiwei Chen, Mingli Song, Lechao Cheng

Abstract

Weakly Supervised Object Localization (WSOL) aims to localize objects using only image-level category labels. Traditional methods based on Class Activation Maps (CAM) often suffer from localizing only the most discriminative parts of an object, while Vision Transformer (ViT) approaches frequently include excessive background noise. This paper introduces the Token Refinement Transformer (TRT), a dual-branch framework that combines the local precision of CAM with a novel Token Priority Scoring Module (TPSM). By adaptively filtering background tokens and performing re-attention on object-related patches, TRT achieves state-of-the-art performance on the ImageNet and CUB-200-2011 benchmarks.

Introduction

The goal of Weakly Supervised Object Localization (WSOL) is to identify the spatial extent of an object without the need for expensive bounding box annotations during training. Historically, this has been achieved through Class Activation Maps (CAM), which identify the regions of an image most responsible for a specific classification. However, CAM-based methods typically focus on the "most discriminative" parts—such as the head of a bird—rather than the entire object.

While Vision Transformers (ViTs) offer a potential solution by capturing global dependencies, their expansive receptive fields often lead to "attention leakage," where the model highlights background elements along with the object. The Re-Attention Transformer (TRT) addresses this by introducing a mechanism to prune background noise and refocus the model’s attention strictly on the object of interest.

The Token Refinement Transformer (TRT)

The TRT framework utilizes a dual-branch architecture designed to balance local discriminative power with global structural integrity. The final localization map ($M$) is derived from the element-wise multiplication of two distinct branches: $M = M_C \odot M_T$.

1. The CAM Branch

The CAM branch generates a standard class-aware activation map ($M_C$). This branch ensures that the model maintains a strong signal for the specific category being localized, providing a foundation of local discriminative features.

2. The Token Priority Scoring Module (TPSM)

The TPSM is the core innovation of the TRT, designed to refine the transformer's global attention. It operates through a three-stage process:

  • Preliminary Attention: The module aggregates attention scores from the class (CLS) token to all patch tokens across the transformer layers, creating an initial map of feature importance.
  • Adaptive Thresholding via Inverse Transform Sampling: Unlike static "Top-K" selection methods, TRT uses a Cumulative Distribution Function (CDF) to select tokens. By calculating the relative contribution of each token to the total attention weight, the model can adaptively decide how many patches constitute the object. This allows the model to remain "tight" on small objects and "expansive" on larger ones.
  • Token Re-Attention: After the background tokens are filtered out, the model performs a second attention pass using only the high-priority tokens. This "re-attention" forces the transformer to model relationships exclusively within the object area, effectively suppressing background noise.

Experimental Results

The TRT framework was evaluated on two primary benchmarks for WSOL: CUB-200-2011 (a fine-grained dataset of bird species) and ILSVRC (ImageNet-1K).

Quantitative Performance

TRT demonstrated significant improvements over previous state-of-the-art (SOTA) methods:

  • CUB-200-2011: Utilizing a DeiT-Base backbone, TRT achieved a 94.1% Gt-Known localization accuracy, representing a 3.3% improvement over the previous leader, TS-CAM.
  • ImageNet-1K: The model reached 70.7% Gt-Known accuracy, outperforming the LCTR method (67.1%).

Qualitative Analysis

Visualizations indicate that TRT successfully bridges the gap between CAM and standard ViTs. While CAM often misses the body of an object and standard ViTs often include the surrounding environment (e.g., a branch or the ground), TRT consistently produces heatmaps that cover the entire object while maintaining clean boundaries at the background interface.

Discussion and Insights

The success of TRT highlights several key principles for future WSOL research:

  • The Necessity of Re-Attention: Simply identifying important tokens is insufficient; the model must re-evaluate the relationships between those tokens in isolation to eliminate background interference.
  • Flexibility via CDF: The use of CDF-based selection is a superior alternative to fixed thresholds. It provides the mathematical flexibility required to handle objects of varying scales within a single dataset.
  • Synergy of Architectures: The paper reinforces that CNN-style local features and Transformer-style global context are complementary. The multiplication of the CAM and TPSM maps ensures that the final output is both category-specific and structurally complete.

Limitations

Despite its performance, TRT introduces higher computational overhead due to the dual-branch structure and the additional re-attention pass. Furthermore, while the model excels in single-object localization, its performance in complex, multi-object scenes remains an area for future investigation. Finally, the adaptive thresholding mechanism relies on a hyperparameter $u$ that may require specific tuning for different datasets.

Summary updated

BibTeX
@inproceedings{su2022re,
  author = {Hui Su and Yue Ye and Zhiwei Chen and Mingli Song and Lechao Cheng},
  title = {{Re-Attention Transformer for Weakly Supervised Object Localization}},
  booktitle = {BMVC},
  year = {2022},
  url = {https://openreview.net/forum?id=KPTuFU5d3I},
}
Figure