Task-Driven Glimpses for Defending Frozen Image Classifiers Against Patches

An adversarial patch is a small printed or pasted region that makes an image classifier output the wrong label. A natural way to defend a classifier you cannot retrain is to have it look at many small views of the image, which we call glimpses, and then take a vote. A patch can only corrupt the glimpses it overlaps. The cost of this defense is clean accuracy. Small views chosen blindly often miss the object, so the vote is wrong even when no attack is present. Biology-inspired defenses show this tension clearly. Training on Foveated Images Improves Robustness to Adversarial Attacks (R-Blur) blurs the image periphery around fixations chosen by a stimulus-driven gaze model. It loses clean accuracy. In an oracle experiment, the authors found that picking the right fixation point brings clean accuracy back to the level of an undefended network. They left open how to choose that point.

We propose to separate where to look from how much any single region can matter. A small policy chooses glimpse locations in a top-down way: it is conditioned on the classifier's own first guesses about what the image contains. A hard structural rule sits around that policy. No image region of patch size may appear in more than $m$ of the $n$ glimpses, wherever the policy points. The robustness guarantee comes only from this rule, so it holds even if an attacker fully hijacks the policy. The policy's job is to recover the clean accuracy that blind glimpse voting gives up. Neither the classifier's weights nor its gradients are touched. The classifier is only queried on crops.

Core Claim

Task-driven glimpse selection, wrapped in a policy-independent coverage cap, can recover most of the clean-accuracy gap between blind glimpse voting and an undefended frozen ImageNet classifier. It should do so at the same certified patch robustness and the same number of classifier calls. The new element is the decoupling itself. Prior attention-based defenses either let the attention mechanism carry the robustness, which is exactly what an attacker exploits, or require retraining.

Relation to Prior Work

Three lines of work motivate this proposal.

Bottom-up attention fails when the observer has a goal. A large benchmark of 32 models, Analysis of Scores, Datasets, and Models in Visual Saliency Prediction, found that saliency models degrade once observers have a specific goal. Probabilistic learning of task-specific visual attention found that top-down signals predict gaze roughly 15% better than bottom-up models. Attention, Please! Adversarial Defense via Attention Rectification and Preservation observed that attacks succeed by pulling a network's attention onto irrelevant regions. That paper's defense requires white-box Grad-CAM and adversarial retraining, and we require neither.

Active vision supplies the method. Emulating human-like adaptive vision for efficient and flexible machine visual perception (AdaptiveNN) trains a fixation-selecting agent with reinforcement learning and adds a stopping rule. However, it trains its recognition network jointly with the agent and was never tested under attack. Embodied Active Defense: Leveraging Recurrent Feedback to Counter Adversarial Patches shows that sequential viewpoint changes cut patch attack success from 98% to 13.7%. That result needs a movable 3D camera. We move the "camera" within a static 2D image instead.

Model-agnostic defense constrains the design. Denoised Smoothing: A Provable Defense for Pretrained Classifiers and (Certified!!) Adversarial Robustness for Free! show that a module placed in front of a frozen classifier can carry certified guarantees. They target diffuse $L_2$ noise, not localized patches. R-Blur reports that undefended classifiers suffer when fed blurred-periphery images without retraining. So we use crop-and-resize glimpses, which ImageNet classifiers already see during training, rather than retinal blur. Improving the Accuracy-Robustness Trade-off of Classifiers via Adaptive Smoothing shows that mixing in probability space rather than logit space stops one adversarial component from dominating. Our aggregator follows this rule. Don't sweat the small stuff, classify the rest: Sample Shielding to protect text classifiers against adversarial attacks is the text analogue of random-subsample voting. Its blind sampling is precisely what we aim to improve on in vision.

Research Program

The pipeline has four parts.

  1. Coarse glance. The frozen classifier $f$ sees one downsampled whole image and returns its top-$K$ class hypotheses.
  2. Glimpse proposal. A lightweight policy network receives the coarse image and those hypotheses and proposes glimpse centers and scales. Its target is the locations whose crops best separate the candidate classes, so the hypotheses act as the "task."
  3. Projection onto the coverage constraint. The proposals are projected onto the set of glimpse layouts that satisfy the coverage rule.
  4. Classification and voting. Each crop is classified by $f$, and the softmax outputs are combined into a vote. An adaptive stopping rule ends sampling early once the vote margin is safe.

The policy is trained only against a surrogate classifier (ResNet-50), using reinforcement learning on vote correctness with a per-glimpse cost. It is then transferred unchanged to other classifiers. This mirrors how Denoised Smoothing transferred surrogate-trained denoisers to commercial APIs.

The guarantee is a counting argument. Let $n$ be the number of glimpses. Let $m(s)$ be the maximum number of glimpses that any square region of side $s$ can intersect under the enforced layout constraint. Let $c_y$ be the number of glimpse votes for class $y$. A patch of side at most $s$ can change at most $m(s)$ votes. The prediction $\hat y$ is therefore certified whenever

$$c_{\hat y} - \max_{y \neq \hat y} c_y > 2\,m(s).$$

The inequality holds for any policy output, including an adversarially steered one. The policy affects only how often the margin is large on clean and attacked images. The research questions are three. First, how much clean accuracy and certified margin does top-down selection buy over blind layouts? Second, how should the projection trade spatial freedom against $m(s)$? Third, does an adaptive attacker who differentiates through the coarse glance and the policy reduce empirical robustness, or only clean-vote margins?

Baselines

Undefended reference. The frozen classifier on the full image. It sets clean accuracy and the attacked floor. R-Blur reports this floor as 0% accuracy for a ResNet on ImageNet under APGD at $\ell_\infty = 0.004$.

Blind glimpse voting. This is the strongest competitor and the key ablation. The glimpse layout is random or a fixed grid, but it obeys the identical coverage cap, glimpse count, crop scales, classifier, and aggregator. It isolates the contribution of task-driven selection, since the certificate is identical by construction. Beating it means at least 3 points higher clean top-1 at equal certified patch accuracy and equal classifier calls, or equal clean accuracy with fewer calls.

Hypothesis-free learned policy. The same policy architecture and training budget, but without the top-$K$ hypotheses as input. This isolates whether the gain comes from top-down conditioning or merely from learned saliency.

DeepGaze-III-selected glimpses. The R-Blur fixation source, applied to our crop glimpses on the frozen classifier with no retraining. This tests whether bottom-up gaze already suffices. For reference, R-Blur reports 18–22% accuracy at $\ell_\infty = 0.004$ on ImageNet, but with a retrained classifier, so that number is not directly comparable.

PAD. PAD: Patch-Agnostic Defense against Adversarial Patch Attacks localizes patches by context mismatch and inpaints them. It reports 83.23% mAP for Faster R-CNN on COCO under naturalistic patches, versus 66.12% for Jedi. No reported result found on Lacuna for PAD on ImageNet classification, so we will run its released pipeline in front of the same frozen classifiers.

Oracle glimpses. Glimpses centered on ground-truth object boxes. This gives the upper bound the policy is trying to approach.

All methods share the classifiers (ResNet-50, ViT, and BEiT-large, all frozen), the evaluation images, and the attack budgets. All learned components get the same surrogate-training compute.

Why not just…?

Why not just vote over random glimpses? This is the real threat. The evidence that it falls short is indirect: R-Blur's oracle result shows that fixation choice drives clean accuracy for foveated defenses. The blind-voting ablation settles it directly. If the policy gains less than about 2 clean points at matched certificate and budget, the policy is not worth its complexity. In that case we would refocus the project on the coverage-cap certificate for frozen classifiers alone.

Why not just use PAD's statistical patch detection? PAD uses no expectation of what should be present. Its authors note that naturalistic patches mimicking background statistics could evade it. It also offers no certificate. We will evaluate both methods under adaptive patches optimized to match local mutual-information statistics.

Why not just adversarially train the classifier? It violates the frozen, black-box setting. It also carries a clean-accuracy cost, which Adaptive Smoothing's roughly 10-point CIFAR-100 clean gain over robust models illustrates. Ours is offered as a complement.

Why not just purify with a diffusion model? Diffusion purification targets diffuse $L_2$ noise. It reaches 71.1% certified accuracy at $L_2 = 0.5$ on ImageNet in the Carlini et al. paper, but it is not designed to remove sharp, localized patches. We include it under patch attacks to measure that gap rather than assume it.

Proposed Experiments

Main experiment. We use ImageNet validation images with patches covering 1–3% of the image. Attacks include universal patches and per-image patches. Adaptive attacks optimize through the coarse glance and the policy using expectation over the stochastic projection. We report four quantities:

  • clean top-1;
  • empirical robust accuracy;
  • certified patch accuracy from the counting bound;
  • average classifier calls per image.

Decisive check. Plot clean accuracy against certified accuracy for blind voting, the hypothesis-free policy, DeepGaze-III glimpses, our policy, and the oracle, all at matched calls. The proposal succeeds only if our curve sits clearly between blind voting and the oracle. It must also stay there under the policy-targeting attack.

Transfer test. A policy trained on ResNet-50 is applied to ViT and BEiT without retuning.

Secondary probe. On ImageNet-100-typo, we ask whether hypothesis-conditioned glimpses avoid typographic stickers without disabling reading. Dyslexify: A Mechanistic Defense Against Typographic Attacks in CLIP reports a 22.06% gain there by ablating attention heads. That approach permanently impairs reading and requires internal model access. We compare on both attack accuracy and an OCR task (IIIT5K) to measure the reading cost each defense pays.