Abstract
Vision transformers (ViTs) have demonstrated a superior ability to handle occlusions compared to convolutional neural networks (CNNs), a property termed "patch selectivity." This study investigates whether this inductive bias can be "hardwired" into CNNs using Patch Mixing, a data augmentation technique that swaps image patches and interpolates labels. We find that while ViTs naturally possess high patch selectivity and do not benefit further from this augmentation, CNNs trained with Patch Mixing show significant improvements on occlusion benchmarks and acquire the ability to ignore out-of-context information.
Introduction: The Challenge of Occlusion
In computer vision, the "CNN vs. ViT" debate often highlights differences in how these architectures process spatial information. ViTs, through their self-attention mechanisms, can focus on relevant features regardless of their spatial proximity. In contrast, CNNs have a local inductive bias; they primarily process neighboring pixels. This locality often causes CNNs to struggle with occlusions, as their attention tends to "bleed" from the object of interest into the occluding patch, leading to misclassification.
The Robustness Gap
The inherent vulnerability of CNNs to information loss is a key motivator for this work. As illustrated in Figure 6, standard CNN architectures like ConvNeXt exhibit a much steeper decline in accuracy compared to Swin Transformers when image information is systematically removed. This gap suggests that ViTs possess a natural robustness to partial data that CNNs lack.
Methodology: Patch Mixing and c-RISE
To bridge this gap, the authors propose Patch Mixing. This augmentation strategy involves dividing two images into a grid (e.g., 7x7 or 14x14) and randomly swapping patches between them. Unlike CutMix, which replaces a single large rectangular region, Patch Mixing uses multiple smaller patches to force the model to learn context-independent feature recognition. During training, labels are interpolated based on the proportion of patches from each class. A critical finding was that for modern CNNs, "random erasing" must be disabled during Patch Mixing to prevent excessive information loss that hinders learning.
To evaluate the effectiveness of this approach, the researchers developed c-RISE (Contrastive RISE). This explainability metric quantifies "patch selectivity" by generating heatmaps that show how much a model values "in-context" pixels (the object) versus "out-of-context" pixels (the occluder).
Experimental Evaluation and Datasets
The study introduces two new benchmarks to test realistic occlusion scenarios:
- Realistic Occlusion Dataset (ROD): A collection of 40+ objects from 16 classes photographed with physical occluders like wooden blocks.
- Superimposed Masked Dataset (SMD): An occluded version of the ImageNet validation set using diverse, non-ImageNet masks (e.g., 3D renders of drones or bacteria) segmented via Meta’s Segment Anything Model.
Key Results
- Performance Gains: On the SMD dataset, ConvNeXt-T accuracy improved from 47.6% to 48.9%. On the ROD benchmark, performance increased from 40.4% to 42.6%.
- The ViT Ceiling: Patch Mixing did not improve ViT performance, confirming that these models already possess high levels of patch selectivity.
- Qualitative Improvements: Saliency maps generated via c-RISE demonstrate that Patch-Mixed CNNs successfully ignore prominent occluders (like a bright red block) to focus on the underlying object, mimicking the behavior of ViTs.
Conclusion
Patch Mixing provides a robust method for simulating ViT-like inductive biases in CNNs without requiring architectural changes. By "hardwiring" patch selectivity through training, CNNs become significantly more resilient to occlusions and less dependent on global spatial structure. While a performance gap between CNNs and ViTs remains, this work demonstrates that clever data augmentation can effectively transfer desirable properties between different model families.
The implementation and datasets are available on the project page.
Summary updated