Introduction
Vision Transformers (ViTs) have revolutionized computer vision but often require heavy regularization to overcome their lack of inductive biases, such as translation invariance. While data augmentation techniques like Mixup and CutMix are standard, they rely on a flawed assumption: that the importance of an image region is strictly proportional to its area. TransMix addresses this by using the model's own self-attention maps to dynamically weight labels during the mixing process.
The Limitation of Area-Based Mixing
In standard CutMix, if 30% of Image A is replaced by a patch from Image B, the resulting label is a fixed 70/30 blend. However, if the 30% patch contains only background while the remaining 70% of Image A contains the primary object, the area-based label becomes misleading. This "label-input gap" forces the model to learn from noisy supervision, potentially hindering performance and generalization.
The TransMix Method: Leveraging Spatial Intelligence
TransMix bridges this gap by leveraging the inherent spatial intelligence of ViTs. Instead of using arbitrary area ratios, it utilizes the multi-head class attention map from the final transformer block to calculate the mixing proportion $\lambda$.
The process is straightforward:
- Input Mixing: A random region from Image B is pasted into Image A, similar to CutMix.
- Attention Extraction: During the forward pass, the model generates a class attention map ($A$) indicating which patches are most relevant for classification.
- Dynamic Labeling: The label weight for Image B is determined by the sum of attention values within the pasted patch's coordinates.
Because the attention map is already a part of the standard ViT forward pass, TransMix adds zero extra parameters and introduces negligible computational overhead (FLOPs).
Qualitative Impact on Label Assignment
By using attention, TransMix "corrects" labels on the fly. If a model focuses heavily on a newly introduced patch, that label receives more weight; if the patch is ignored as background, the original label remains dominant. This ensures that the model is not penalized for correctly identifying the most discriminative features in a mixed image.
Key Results and Robustness
TransMix consistently improves performance across various architectures and tasks:
- Classification Gains: It improves ImageNet-1k top-1 accuracy by approximately 0.9% for models like DeiT-S and XCiT-L. In head-to-head comparisons, TransMix (80.7%) outperformed more complex methods like Puzzle-Mix (79.8%) and Attentive-CutMix (77.5%).
- Downstream Transferability: Pre-training with TransMix enhances performance in semantic segmentation (Pascal Context) and object detection (COCO), improving mIoU by up to 0.9%.
- Enhanced Robustness: TransMix-trained models are significantly more resilient to occlusion and spatial shuffling. Even when 70% of image information is lost, TransMix models maintain significantly higher accuracy than vanilla ViTs.
Conclusion
TransMix is an "embarrassingly simple" yet powerful refinement of data augmentation for Vision Transformers. By aligning the label space with the model's visual focus, it provides a more accurate supervisory signal, leading to better generalization, robustness, and transferability without the need for external saliency models or additional parameters.
Summary updated