Object Localization with a Weakly Supervised CapsNet

Weitang Liu, Emad Barsoum, John D. Owens · DOI

Abstract

Inspired by CapsNet's routing-by-agreement mechanism with its ability to learn object properties, we explore if those properties in turn can determine new properties of the objects, such as the locations. We then propose a CapsNet architecture with object coordinate atoms and a modified routing-by-agreement algorithm with unevenly distributed initial routing probabilities. The model is based on CapsNet but uses a routing algorithm to find the objects' approximate positions in the image coordinate system. We also discussed how to derive the property of translation through coordinate atoms and we show the importance of sparse representation. We train our model on the single moving MNIST dataset with class labels. Our model can learn and derive the coordinates of the digits better than its convolution counterpart that lacks a routing-by-agreement algorithm, and can also perform well when testing on the multi-digit moving MNIST and KTH datasets. The results show our method reaches the state-of-art performance on object localization without any extra localization techniques and modules as in prior work.

1. Introduction

In computer vision, object localization typically requires supervised learning with bounding boxes—a labor-intensive labeling process. Weakly supervised methods attempt to find objects using only image-level class labels (e.g., "there is a digit here"), often relying on gradient-based heatmaps like Grad-CAM. However, these heatmaps can be noisy and imprecise.

This research addresses the challenge of achieving "equivariance"—the ability of a model to understand how spatial changes in the input should predictably change the internal representation. While standard Convolutional Neural Networks (CNNs) struggle with this, Capsule Networks (CapsNets) were designed specifically to handle part-whole relationships and spatial hierarchies. This paper explores whether that internal "understanding" of space can be explicitly extracted to pinpoint an object's center.

2. Proposed Methodology

The proposed architecture modifies the standard CapsNet to enable explicit coordinate derivation through several key innovations:

  • Coordinate Atoms: Two extra dimensions, representing $x$ and $y$ coordinates, are appended to the primary capsules. These coordinates are initialized based on the capsule's relative position in the initial feature map.
  • Weighted Average Routing: During the routing-by-agreement process, the coordinates of a high-level "digit capsule" are calculated as a weighted average of the coordinates of the low-level capsules that "agree" with it. This effectively turns the coupling coefficients ($c_{ij}$) into a localization mask.
  • Sparse Initialization: A critical discovery was that standard CapsNet routing distributes probabilities too evenly, causing calculated coordinates to "wash out" toward the image center. To fix this, the authors initialize routing with a strong bias toward an "unknown" class. This forces the network to be highly selective.
The proposed CapsNet architecture featuring coordinate atoms and routing-by-agreement for localization.
  • Convolutional Reconstruction: Instead of standard fully-connected layers, the model uses convolution-transpose layers for reconstruction. This preserves spatial features and acts as a regularizer, ensuring the latent space remains spatially meaningful.

3. Experimental Setup

The model was evaluated on several dynamic datasets to test its robustness and generalization:

  • Moving MNIST: Single-digit sequences for training; 1-, 2-, and 3-digit sequences for testing.
  • Moving Fashion MNIST: A more complex version using clothing items.
  • KTH Dataset: A real-world human action recognition dataset used to test the model's ability to locate people in video frames.
Sample inputs from the Moving MNIST (a-c) and KTH (d-f) datasets used for evaluation.

4. Results and Discussion

The "CapsNet with bias initial $c_{ij}$" significantly outperformed standard CNN benchmarks and traditional CapsNets. On the 3-digit moving MNIST test—a scenario the model never encountered during training—the CapsNet achieved a Mean Absolute Error (MAE) of 0.078, a 51% improvement over the best benchmark (ConvNet at 0.160).

Key insights include:

  • Zero-Shot Multi-Object Localization: Even when trained only on single digits, the model successfully distinguished and located multiple different digits in a single frame.
  • Controllability: By manually "tweaking" the coordinate atoms in the latent space, the reconstruction layers generated the object at the new, specified position, proving the network learned true spatial coordinates.
  • Real-world Generalization: On the KTH dataset, the model achieved an MAE of 0.088, outperforming a ResNet-20 model using Grad-CAM (0.090).

5. Conclusion

While effective, the model faces challenges such as property entanglement, where coordinate atoms may capture non-spatial information like stroke thickness. Additionally, sparse initialization increases training time. Future work will explore sparse entropy loss functions to better handle multiple objects of the same class, which remains a limitation of current capsule architectures.

Summary updated

Abstract

Inspired by CapsNet's routing-by-agreement mechanism with its ability to learn object properties, we explore if those properties in turn can determine new properties of the objects, such as the locations. We then propose a CapsNet architecture with object coordinate atoms and a modified routing-by-agreement algorithm with unevenly distributed initial routing probabilities. The model is based on CapsNet but uses a routing algorithm to find the objects' approximate positions in the image coordinate system. We also discussed how to derive the property of translation through coordinate atoms and we show the importance of sparse representation. We train our model on the single moving MNIST dataset with class labels. Our model can learn and derive the coordinates of the digits better than its convolution counterpart that lacks a routing-by-agreement algorithm, and can also perform well when testing on the multi-digit moving MNIST and KTH datasets. The results show our method reaches the state-of-art performance on object localization without any extra localization techniques and modules as in prior work.
BibTeX
@misc{liu2018object,
  author = {Weitang Liu and Emad Barsoum and John D. Owens},
  title = {{Object Localization with a Weakly Supervised CapsNet}},
  year = {2018},
  eprint = {1805.07706},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1805.07706},
}
Figure