Cached Attacks for Cheap Robustness in Frozen Detectors

Object detectors, the models that draw labeled boxes around every object in an image, fail almost completely under small, deliberately crafted pixel changes. The standard fix is adversarial training: during training, generate a worst-case perturbation for each image and teach the model to resist it. For detectors this fix is expensive twice over. Each training step needs an inner attack loop, typically 10 to 20 extra forward and backward passes through the backbone, feature pyramid, and heads. It also costs a lot of clean accuracy. Towards Adversarially Robust Object Detection reports an SSD detector falling from 72.1% to 48% clean mAP (mean Average Precision) on PASCAL VOC after robust training. Using Feature Alignment Can Improve Clean Average Precision And Adversarial Robustness In Object Detection cites clean-AP drops of up to 25 points.

This note proposes an approach that ties the two costs together. We freeze a strong pretrained detector and train only a small add-on module, about 1% of the weights, that makes it robust. Because almost nothing in the network changes, a perturbation computed against the detector stays close to worst-case for many training steps. We therefore store one perturbation per training image in a cache and refresh it with a single cheap gradient step each time the image comes around, instead of recomputing a full multi-step attack. A separate term keeps the module's effect on clean images near zero. If the claim holds, robustness becomes a detachable, cheap add-on whose clean-accuracy cost can be set explicitly.

Core Claim

Our central hypothesis concerns how quickly cached attacks go stale. We call a cached perturbation stale when its loss falls below that of a freshly computed multi-step attack. We expect staleness to be governed mainly by how many parameters are being trained. When only a small module changes, a cache refreshed with one step per visit should track a fresh 10-step attack closely enough that robustness against fully adaptive attacks matches multi-step adversarial fine-tuning of the same module. The training cost should be close to standard fine-tuning.

The second half of the claim is about clean accuracy. We anchor the module's clean-image outputs to those of the frozen detector, and we point the attack at the classification branch using class-balanced losses. Under those conditions the clean-mAP loss should shrink to a controllable quantity, below what full adversarial fine-tuning pays at equal robustness.

The first half is the new part. Fast adversarial training for detectors already exists. Class-Aware Robust Adversarial Training for Object Detection (CWAT) and PBCAT both reuse gradients in the FreeAT style, and both update all detector weights. Under full-weight updates, stale perturbations are exactly what causes catastrophic overfitting, the failure in which single-step training appears robust but collapses under stronger attacks. Reliably fast adversarial training via latent adversarial perturbation reports FGSM training dropping to 0.01% on CIFAR-10 under PGD-50. Our proposal is that freezing is what makes perturbation reuse safe. We will measure this directly rather than assume it.

Research Program

Base detectors and the trainable module. We start from detectors with Vision Transformer backbones, since that is where full adversarial training is least affordable. We add one convolutional detector so our results can be compared against the older literature. The trainable module follows two recent designs for making frozen classifiers robust.

The first is the LayerNorm-plus-low-rank adapters of FullLoRA-AT. That work showed plain low-rank adaptation fails under adversarial training because adversarial noise shifts the LayerNorm statistics, and that adapting LayerNorm matches full fine-tuning within 1–2% while training about 5% of parameters. The second is the learnable prefix tokens of Robustness Tokens. Both were validated almost entirely on classification, with Robustness Tokens adding one segmentation result.

We add a third placement motivated by Adversarially-Aware Robust Object Detector. That work found the classification sub-task far more fragile than localization. The placement is a small adapter on the features entering the classification head only, with the box-regression path left untouched. Comparing the three placements tells us where in a detector robustness has to be bought.

The perturbation cache. Each training image keeps a stored perturbation within the $\ell_\infty$ budget, meaning no pixel changes by more than a fixed amount. The cache is initialized with a multi-step PGD (projected gradient descent, repeated small gradient steps projected back into the budget) against the frozen base detector. Each time the image is revisited, the cached perturbation receives one signed-gradient step. That gradient is taken from the same backward pass used for the module update, in the FreeAT manner. This makes the per-step cost essentially that of standard fine-tuning.

To guard against the jagged loss surfaces behind catastrophic overfitting, we add SLAT's single-step latent perturbations at an early backbone stage. We also re-randomize a small fraction of cache entries every epoch. We keep one diagnostic running throughout: on a held-out batch, the loss of the cached perturbation divided by the loss of a fresh PGD-10 perturbation. This staleness ratio is the quantity the core claim is about.

Training objective. Let $f_\phi$ be the frozen detector, $f_{\phi,\theta}$ the detector with module parameters $\theta$, $\delta_i$ the cached perturbation for image $x_i$ with annotations $y_i$, and $\lambda$ a weight. We minimize

$$\mathcal{L}(\theta) = \mathcal{L}^{\text{bal}}_{\text{det}}\big(f_{\phi,\theta}(x_i+\delta_i), y_i\big) + \lambda\, D\big(f_{\phi,\theta}(x_i),\, f_\phi(x_i)\big).$$

Here $\mathcal{L}^{\text{bal}}_{\text{det}}$ is the detection loss with CWAT's per-class normalization and per-object clipping. Those were introduced to stop the attacker from breaking only the easiest or most common object while leaving rare classes undefended, a problem CWAT calls the "lazy" attacker. $D$ is a divergence between the class scores and box outputs of the adapted and frozen detectors on the clean image.

The anchor term is our explicit handle on the robustness-accuracy trade-off. Sweeping $\lambda$ traces a curve of clean mAP against adversarial mAP. It replaces the moving teacher targets that Robust and Accurate Object Detection via Self-Knowledge Distillation (UDFA) had to stabilize with a fixed reference: the unchanged detector itself.

The attack that refreshes the cache maximizes the balanced classification loss plus the localization loss. Following the gradient-misalignment finding of Towards Adversarially Robust Object Detection (the MTD method), it alternates which of the two losses dominates the refresh on successive visits. We do this instead of generating both candidates at every step, which doubles cost in MTD.

Baselines

Undefended detector. The naive reference point is the frozen detector with no defense. It fixes the clean-accuracy ceiling and the near-zero robust floor. On PASCAL VOC, prior reports for SSD are 72.1% clean mAP collapsing to near zero (Towards Adversarially Robust Object Detection), and 0.752 collapsing to nearly zero under PGD-10 (Class-Aware Robust Adversarial Training for Object Detection).

Full-weight robust training (FA and UDFA). On the question of clean accuracy versus robustness, the strongest existing detection method with a reported number is feature alignment (FA). It aligns a student's adversarial features to clean features and reaches 0.500 acAP (the average of clean and adversarial AP) with Faster R-CNN-FPN on PASCAL VOC, against 0.454 for vanilla adversarial training and 0.470 for TOD (Using Feature Alignment Can Improve Clean Average Precision And Adversarial Robustness In Object Detection). UDFA reports +1.6 clean AP and +0.5 adversarial AP over prior adversarial training on GFLV2-ResNet-50 on VOC (Robust and Accurate Object Detection via Self-Knowledge Distillation), but the file gives no absolute acAP.

We will re-run FA and UDFA under our own attack protocol on the same base detectors. Beating them means higher acAP at equal or lower measured GPU-hours. Clean AP must stay within one point of the undefended detector in the high-$\lambda$ setting.

Fast full-weight training (CWAT). On the cost question, the strongest competitor is CWAT with FreeAT acceleration, which reports 0.224 robust mAP under PGD-10 for SSD on VOC. We run it with the same pass budget as our method. Beating it means higher robust mAP under adaptive attack at equal passes, with less clean loss.

Strongest direct extension (Robustness Tokens with fresh attacks). This is Robustness Tokens applied to the detector backbone and trained with fresh multi-step attacks. It reports ADE20K mIoU under attack rising from 4.7 to 23.3 in segmentation. No reported detection result was found on Lacuna for any parameter-efficient robust fine-tuning method.

Ablations. These isolate the key ingredient. First, the same module trained with fresh PGD-10 every step, which is the cost the cache must avoid. Second, the module trained on perturbations computed once against the base detector and never refreshed. Third, the cache with the anchor removed ($\lambda=0$). Fourth, the anchor replaced by the gradient projection of Conflict-Aware Adversarial Training (CA-AT), which removes the component of the adversarial gradient that opposes the clean gradient. All methods share data, the base checkpoint, a fixed tuning budget of the same number of hyperparameter trials, and GPU-hour accounting.

Why not just…?

Why not just adversarially fine-tune the whole detector with FreeAT, as PBCAT and CWAT do? That already runs at roughly standard training cost. However, both methods update every weight, and the file records the result: CWAT's 0.224 robust mAP sits far below the 0.752 clean baseline, and PBCAT's authors acknowledge a clean-accuracy loss. Full-weight fast training also exposes the model to catastrophic overfitting on dense detection losses. Our CWAT comparison at matched passes tests whether freezing buys a better clean-versus-robust curve. If full-weight FreeAT dominates at equal cost, the freezing half of our claim is wrong.

Why not just attach Robustness Tokens to a ViT detector and train with ordinary attacks? This is the most serious threat. The method already restored DINOv2-G from 0.3% to 63.1% robust accuracy with clean accuracy barely moving (85.2 vs 85.6), and it converges in 200 steps. If that transfers to detection, the placement and anchor pieces add little. What it does not address is inner-loop cost across a full detection dataset, or the lazy-attacker imbalance across classes. Our experiment runs it both with fresh attacks and with our cache. If the cache matches fresh attacks inside the token setup, the contribution is the cache, and the tokens become one module choice among several. If the cache fails, our claim fails regardless of module.

Why not just precompute adversarial examples once against the base detector and train on them as static data? This is the cheapest option imaginable, and it is the zero-refresh endpoint of our design. Its known weakness is that the module learns to defeat perturbations tuned to a model that no longer exists, which inflates robustness against transfer attacks while leaving adaptive attacks intact. The staleness ratio and the adaptive-attack gap between static and cached training quantify exactly how much refreshing is needed. If static training matches the cache under adaptive attack, we will report that simpler result.

Why not just use CA-AT's gradient projection instead of an output anchor? Projection prevents updates that raise the clean loss, but it was validated only on classifiers, and it operates on one aggregated clean gradient. In detection, that gradient is itself a mixture of classification and localization terms that conflict. The anchor instead constrains outputs directly, per box and per class score. The ablation swaps one for the other at equal robust mAP.

Proposed Experiments

The main setting is MS-COCO 2017 and PASCAL VOC 2007. We use three detectors. The first is a ViT-backbone two-stage detector, since ViTDet-style models appear in the COCO-O results. The second is DN-DETR, the transformer detector PBCAT already supports. The third is an SSD-VGG16 run on VOC only, so our numbers sit against the reported SSD results. Robustness is evaluated under white-box $\ell_\infty$ PGD-20 and PGD-50 attacks that target classification, localization, and their sum. The attacker knows the full adapted model, including the module. We also run attacks crafted against the frozen base alone, and a large gap between the two would signal that the cache is fitting base-model attacks rather than producing real robustness. We report clean mAP, adversarial mAP, acAP, per-class adversarial AP for the rarest categories, and small-object AP. As a check that the anchor does not simply memorize the training distribution, we report clean-side generalization on COCO-O (COCO-O) using the alibaba/easyrobust harness. Cost is reported as forward-backward passes per image and wall-clock GPU-hours.

The first decisive check is the staleness curve. We plot the ratio of cached to fresh-PGD loss over training for trainable fractions spanning head-only adapters, about 1% of weights, about 5% (FullLoRA-AT's scale), and full fine-tuning. The claim predicts the ratio stays near one for small fractions and degrades as the trainable fraction grows. If the ratio collapses even at 1%, the cache idea is refuted.

The second decisive check compares the cached module against the fresh-PGD-10 module under adaptive PGD-50. The cache should reach at least 90% of the fresh variant's adversarial mAP at roughly one tenth of the inner-loop cost.

The third check is the $\lambda$ sweep. We plot the resulting curve alongside FA's reported 0.500 acAP on VOC Faster R-CNN and our re-runs of FA, UDFA, and CWAT. The anchored module should reach higher acAP than each at lower GPU-hours, while holding clean mAP within one point of the undefended detector at the high-anchor end.

Finally, the placement comparison of backbone tokens, LayerNorm-low-rank adapters, and a classification-branch-only adapter tests whether most of the robustness gain can be bought on the classification side alone. That result would turn the asymmetric-vulnerability observation into a cost-saving design rule.