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

Constrained Sampling for Class-Agnostic Weakly Supervised Object Localization

Shakeeb Murtaza, Soufiane Belharbi, Marco Pedersoli, Aydin Sarraf, Eric Granger · DOI

Abstract

Weakly Supervised Object Localization (WSOL) aims to localize objects using only image-level labels. Traditional methods relying on Class Activation Maps (CAMs) often suffer from discriminative bias and thresholding sensitivity. This paper introduces a novel approach that leverages self-supervised Vision Transformer (ViT) attention and a "constrained sampling" strategy to generate high-quality pseudo-labels. By producing decisive, bimodal activation maps, the proposed method achieves state-of-the-art performance on the CUB-200-2011 benchmark without requiring manual, per-image threshold tuning.

Introduction

Object localization typically requires expensive, pixel-perfect annotations like bounding boxes or masks. WSOL attempts to bypass this by training models to find objects using only image-level labels (e.g., "this image contains a bird"). The standard tool for this is Class Activation Mapping (CAM). However, CAMs have two major flaws:

  1. Discriminative Bias: They tend to highlight only the most "telling" part of an object (like a bird’s beak) rather than the whole body.
  2. Thresholding Sensitivity: CAMs produce continuous heatmaps. To get a bounding box, researchers must pick a threshold value, which often varies wildly from one image to the next, leading to inconsistent performance.

The authors aim to create a class-agnostic system that produces sharp, binary-like maps covering the entire object, eliminating the need for per-image threshold tuning.

Methodology

The proposed approach shifts the focus from class-specific features to self-supervised attention. The pipeline works as follows:

  • Attention Extraction: The model uses a Vision Transformer (ViT) trained in a self-supervised manner. It extracts attention maps from the last layer (specifically the [cls] token).
  • Proposal Generation: It selects the top four attention maps plus an average map. These are converted into binary maps using Otsu thresholding to generate several potential bounding box "proposals."
  • Best Proposal Selection: To find the best box, the system applies a Gaussian blur to everything outside each proposed box and passes the images through a classifier. The box that yields the highest classification confidence is chosen.
  • Constrained Sampling for Pseudo-labels: Instead of using the whole map, the authors sample the top $n\%$ of pixels as "foreground" and the bottom $n\%$ as "background." These act as high-confidence pseudo-labels.
  • Training: A localization map predictor is then trained using these pseudo-labels with a standard cross-entropy loss. They also incorporate a Conditional Random Field (CRF) loss to ensure the predicted maps align closely with the actual object boundaries.

Key Insights: Bimodal Activation

One of the most striking findings is that while baseline methods have a messy distribution of pixel intensities, the proposed method produces a clear bimodal distribution. This means pixels are either "definitely foreground" or "definitely background," making the localization much more decisive and robust to thresholding.

Activation distributions across different methods.

Results and Evaluation

The researchers evaluated their method on the CUB-200-2011 dataset, a standard benchmark consisting of 200 bird species. They utilized the MaxBoxAccV2 metric, which is designed to be more robust than older localization metrics.

The proposed method significantly outperformed existing state-of-the-art (SOTA) WSOL techniques:

  • MaxBoxAcc: Reached 97.0%, a substantial jump over the previous SOTA, F-CAM (91.5%).
  • MaxBoxAccV2: Achieved 90.9%, compared to F-CAM’s 84.3%.

Visual results demonstrate that while other methods (like ACoL or SPG) often produce fragmented or overly small boxes, the proposed method consistently captures the full extent of the object with high Intersection over Union (IoU) scores.

Qualitative comparison of localization results showing IoU scores.

Conclusion

By leveraging self-supervised priors and constrained sampling, this method effectively addresses the discriminative bias inherent in traditional CAM-based WSOL. While the current pipeline involves multiple steps and is focused on single-object datasets, it sets a new performance benchmark and provides a path toward more robust, threshold-independent object localization. Future work will focus on streamlining the architecture and testing on multi-object datasets like COCO.

Summary updated

BibTeX
@misc{murtaza2022constrained,
  author = {Shakeeb Murtaza and Soufiane Belharbi and Marco Pedersoli and Aydin Sarraf and Eric Granger},
  title = {{Constrained Sampling for Class-Agnostic Weakly Supervised Object Localization}},
  year = {2022},
  eprint = {2209.09195},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2209.09195},
}
Figure