Inverting and Understanding Object Detectors

Ang Cao, Justin JohnsonarXiv 2021

Abstract: As a core problem in computer vision, the performance of object detection has improved drastically in the past few years. Despite their impressive performance, object detectors suffer from a lack of interpretability. Visualization techniques have been developed and widely applied to introspect the decisions made by other kinds of deep learning models; however, visualizing object detectors has been underexplored. In this paper, we propose using inversion as a primary tool to understand modern object detectors and develop an optimization-based approach to layout inversion, allowing us to generate synthetic images recognized by trained detectors as containing a desired configuration of objects. We reveal intriguing properties of detectors by applying our layout inversion technique to a variety of modern object detectors, and further investigate them via validation experiments: they rely on qualitatively different features for classification and regression; they learn canonical motifs of commonly co-occurring objects; they use different visual cues to recognize objects of varying sizes. We hope our insights can help practitioners improve object detectors.

Introduction

While deep learning has made object detection incredibly accurate, these models remain "black boxes." We know they work, but we don't fully understand how they make decisions. For simple image classifiers, researchers often use "activation maximization"—generating an image that makes the model recognize a specific class. However, object detectors are much harder to visualize because they output a variable number of bounding boxes, scores, and masks, and use non-differentiable operations like Non-Maximum Suppression (NMS) to filter duplicates. These operations break the gradients needed for standard visualization techniques, making it nearly impossible to back-calculate what pixels the model is actually looking for.

Methodology: Layout Inversion

The researchers introduced Layout Inversion, an optimization strategy inspired by the Alternating Direction Method of Multipliers (ADMM). Instead of trying to differentiate through the entire detector at once, they alternate between two steps:

  1. Image Update: Updating the image so the network's raw output matches a set of "pseudo-targets" using standard gradient descent.
  2. Pseudo-target Update: Updating the pseudo-targets to be a minimal perturbation of the current output that would result in the desired final layout after post-processing.

This approach allows for the "hallucination" of images for a wide range of architectures, including single-stage (RetinaNet, FCOS) and two-stage (Faster R-CNN, Mask R-CNN) detectors.

Key Insights and Ideas

Classification vs. Regression

One of the most significant findings is that the different "heads" of a detector have distinct priorities. The classification head focuses on local textures and distinct parts (like an animal's head), while the regression head—responsible for drawing the bounding box—prioritizes global structure, boundaries, and corners.

Visualizing the different priorities of classification, regression, and mask heads. The regression head (Reg) focuses on boundaries, while the classification head (Cls) focuses on internal features.

The Role of Context and Scale

Detectors are context-aware to a fault, learning "canonical motifs" of objects that frequently co-occur. For example, when asked to visualize a carrot, the model often hallucinates broccoli nearby. Furthermore, visual cues change with size: small objects are recognized primarily by their context and overall shape, whereas the model shifts focus toward internal textures and amalgamations of parts as objects get larger.

Key Results

Qualitative Success

The inverted images show clear, recognizable structures across various architectures. For instance, inversions for people show shoes, pants, and faces, while cars show wheels and windows. This demonstrates that the inversion technique successfully captures the internal representations of these complex models.

Qualitative results of layout inversion across different detector architectures, including Mask R-CNN, Faster R-CNN, RetinaNet, and FCOS.

Inversion Transfer and Texture Bias

By performing "Inversion Transfer" (testing an image generated for one model on another), the study found that Faster R-CNN and Mask R-CNN share very similar internal representations (yielding an Average Precision of 86.1). However, transferring from Faster R-CNN to the anchor-free FCOS model saw a drop to 75.1 AP, indicating single-stage models perceive the world differently. Additionally, the authors confirmed a heavy texture bias for large objects; model confidence drops significantly if texture is removed, even if the shape remains intact.

Limitations and Future Work

While robust, the method still struggles with small objects and crowded scenes. The generated images also rely on image regularizers to remain natural-looking; without them, inversions can become noisy. Future work could involve using these insights to design "sibling heads" that better balance classification and localization needs, or using inversion to diagnose failure modes in safety-critical applications like autonomous driving.

Summary updated

BibTeX
@misc{cao2021inverting,
  author = {Ang Cao and Justin Johnson},
  title = {{Inverting and Understanding Object Detectors}},
  year = {2021},
  eprint = {2106.13933},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2106.13933},
}
Figure