Boltzmann Attention Sampling for Image Analysis with Small Objects

Theodore Zhao, Sid Kiblawi, Naoto Usuyama, Ho Hin Lee, Sam Preston, Hoifung Poon, Mu Wei

Abstract

Transformer-based segmentation models often struggle with small objects because standard attention mechanisms allocate significant computation to irrelevant background pixels, introducing noise that degrades performance. This paper introduces BoltzFormer, a novel architecture that utilizes a temperature-annealed Boltzmann distribution to dynamically sample and focus attention on the most relevant image patches. By treating attention as a dynamic search process, BoltzFormer significantly improves text-prompted segmentation accuracy for small objects while reducing attention computation by an order of magnitude.

Introduction

Promptable vision foundation models, such as the Segment Anything Model (SAM) and SEEM, have revolutionized image segmentation by allowing users to define targets via points, boxes, or text. However, these models encounter a significant bottleneck when tasked with identifying very small objects, particularly when relying solely on text descriptions (e.g., "lung nodule"). In specialized domains like biomedicine, target objects frequently occupy less than 0.1% of the total image area. For a standard transformer, this results in 99.9% of the attention computation being spent on irrelevant background pixels. This is not merely a matter of efficiency; the overwhelming amount of background data acts as noise, making it difficult for the model to isolate and precisely segment tiny targets.

The BoltzFormer Architecture

To address the limitations of full-attention mechanisms, BoltzFormer replaces static attention with a dynamic, probabilistic sampling approach. The architecture is built around three core innovations:

Boltzmann Attention Sampling

Instead of computing attention across the entire image, BoltzFormer uses a set of latent queries—initialized by the text prompt—to estimate a probability field over the image. The model then draws a small sample of image patches from this distribution. By ensuring that queries only attend to these sampled patches, the model effectively filters out the background noise that typically confuses standard models.

Temperature Annealing

To manage the initial uncertainty regarding an object's location, BoltzFormer employs a decaying temperature schedule, similar to simulated annealing in reinforcement learning. In the early layers of the transformer, the temperature is high, encouraging the model to sample broadly across the image (exploration). As the data progresses through later layers, the temperature "cools," causing the sampling to concentrate tightly around the most confident regions (exploitation). This allows the model to "hunt" for the object globally before zooming in for fine-grained segmentation.

Pixel Grounded Mask Aggregation (PiGMA)

Because the sampling process is stochastic, BoltzFormer utilizes an ensemble of multiple queries that communicate via self-attention. If one query identifies the target during its random sampling, it can update the others. The PiGMA module then uses a lightweight convolutional network to aggregate predictions from these multiple queries, grounding them back to the original high-resolution pixels to produce the final segmentation mask.

Experimental Results

BoltzFormer was evaluated on a suite of seven public medical image segmentation datasets, including the Medical Segmentation Decathlon (MSD), LIDC-IDRI, and AMOS22. These datasets were enriched with GPT-4 generated text prompts to test text-prompted segmentation across a wide range of object sizes (0.002% to 20% of the image area).

Performance Benchmarks

BoltzFormer demonstrated significant improvements over state-of-the-art foundation models:

  • General Accuracy: Achieved a +12.4% Dice score improvement over SAM and +12.6% over SAM 2.
  • Small Object Dominance: For objects occupying less than 1% of the image, BoltzFormer achieved a Dice score of 71.4, substantially higher than SAM (64.5) and SEEM (68.9).
  • Expert Comparison: A single, text-prompted BoltzFormer model outperformed 35 separate, fully-supervised nnU-Net expert models trained for individual tasks.

Computational Efficiency

The model achieved its peak performance while sampling only 10% of the visual features per layer. This reduction effectively slashes the attention computation by an order of magnitude compared to standard full-attention decoders, proving that restricting the model's view can actually enhance its focus and accuracy.

Conclusion and Future Work

BoltzFormer demonstrates that probabilistic sampling and temperature annealing can overcome the "needle in a haystack" problem inherent in small object segmentation. While the model shows a minor failure rate (1.4%) in cases of extremely low contrast or visually similar distractors, its ability to filter background noise sets a new standard for efficiency and accuracy. Future research will focus on expanding BoltzFormer to 3D medical volumes, video segmentation, and a broader variety of non-medical object types.

Summary updated

BibTeX
@inproceedings{zhao2025boltzmann,
  author = {Theodore Zhao and Sid Kiblawi and Naoto Usuyama and Ho Hin Lee and Sam Preston and Hoifung Poon and Mu Wei},
  title = {{Boltzmann Attention Sampling for Image Analysis with Small Objects}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2025},
  doi = {10.1109/cvpr52734.2025.02417},
}
Figure