TL;DR
This paper introduces PatchCensor, a novel method for certifying the robustness of Vision Transformers (ViTs) against adversarial patch attacks. By employing an exhaustive testing strategy that leverages ViT's self-attention mechanism, PatchCensor can detect malicious patches and provide a provable guarantee of robustness, outperforming existing methods in certified accuracy.
What Problem Does This Paper Address?
Vision Transformers (ViTs) have achieved state-of-the-art performance in various computer vision tasks. However, like other deep neural networks, they are vulnerable to adversarial perturbations, particularly "patch attacks" where a small region of an image is modified. These attacks pose a significant threat to the deployment of ViTs in safety-critical applications. While existing methods aim to improve robustness, they often require extensive retraining, sacrifice clean accuracy, or struggle with real-world scenarios. This paper addresses the need for a robust, efficient, and practical method to certify ViT's resilience against adversarial patches.
Methods
PatchCensor employs a testing-based certified detection approach. Instead of retraining the ViT model to be inherently robust, PatchCensor leverages a pre-trained ViT and applies an exhaustive testing strategy at inference time. The core idea is to use ViT's self-attention mechanism to mask out different regions of the input image. By performing multiple inferences with these masked attention maps, PatchCensor can detect if an adversarial patch is influencing the prediction.
The key innovation lies in the mutation strategy:
- Abstract Feature Level Masking: The masking is applied at the abstract feature level within the Transformer encoder, rather than directly on pixels. This is facilitated by ViT's architecture.
- Exhaustive Testing: The method systematically explores all possible locations where an adversarial patch could be present by sliding a mask across the input.
- Consensus Voting: A prediction is considered "verified" only if all masked inferences (including at least one guaranteed to exclude the patch) agree on the same class prediction as the original, unmasked inference. This ensures that the adversarial patch, if present, does not alter the final decision.
This approach is "zero-shot" as it reuses a pre-trained ViT backbone and requires no additional training for robustness.
Datasets
The paper evaluates PatchCensor on several standard computer vision datasets:
- CIFAR-10: A common benchmark for image classification.
- ImageNet: A large-scale dataset for image classification.
- GTSRB (German Traffic Sign Recognition Benchmark): A dataset for traffic sign recognition.
- Food-101: A dataset for food image classification.
The authors also use rescaled versions of CIFAR-10, as well as ImageNet object detection and PartImageNet datasets to specifically evaluate performance under small Region of Interest (ROI) scenarios.
Key Insights and Ideas
- ViT's Self-Attention is Key: The self-attention mechanism in ViTs provides a natural and efficient way to mask out specific regions of the input at the feature level, which is crucial for PatchCensor's strategy.
- Detection vs. Recovery: The paper strongly advocates for certified detection over certified recovery for adversarial patches. Detection offers a more practical guarantee, especially in real-world scenarios where perfect recovery might be impossible or too costly.
- Small ROI Challenges Certified Recovery: Certified recovery methods, which rely on local features, struggle significantly when the Region of Interest (ROI) is small, leading to a sharp drop in certified accuracy. PatchCensor, by considering the whole image with masked regions, performs better in such cases.
- Patch Size Flexibility: PatchCensor can handle a range of adversarial patch sizes, making it more adaptable than methods that are tuned for a specific patch size.
- Statistical Guarantee is Practical: While not a deterministic guarantee for every single input, the statistical guarantee provided by PatchCensor is argued to be more practical and useful in real-world applications due to its superior performance and efficiency.
Key Results
- High Certified Accuracy: PatchCensor achieves significantly higher certified accuracy compared to existing certified detection and recovery methods across various datasets and patch sizes. For example, on ImageNet with 2% adversarial patches, it achieves 67.1% certified accuracy, outperforming prior work.
- Competitive Clean Accuracy: PatchCensor maintains a clean accuracy comparable to the base ViT model, demonstrating that it doesn't sacrifice performance on clean data.
- Robustness to Large Patches: The method shows strong performance even with large adversarial patches (up to 25%), a scenario where many other methods fail.
- Efficiency: PatchCensor offers a good trade-off between certified accuracy and inference latency, especially when using smaller ViT models or larger patch sizes. It requires less training effort compared to fine-tuning-based methods.
Limitations and Future Work
- "Bypassed" Scenarios: The paper acknowledges a specific scenario where certified detection might fail: when the majority of benign voters incorrectly classify an image, and this consensus is then flipped by an adversarial patch to another incorrect class. This leads to a "certified" but wrong prediction. The authors argue this is rare and can be mitigated by using more powerful base models.
- Multiple Patches: The current defense is designed for a single adversarial patch. Extending it to handle multiple patches or complex shapes is a direction for future work, though it might increase the number of necessary mutations.
- NLP Extension: The abstract feature-level masking strategy is generalizable and could potentially be adapted for Natural Language Processing (NLP) tasks.
- Improving Certified Recovery: The paper suggests that incorporating additional features like texture or color could improve certified recovery methods.
Summary updated