betaFeedback

WorksComputer Science

Certified Defense against Adversarial Patches on Traffic Signs via Mask-Aware Training

Abstract

Adversarial patches are a practical threat to traffic-sign recognition: a small sticker on a sign can change a classifier's decision. PatchCleanser is a certified defense that applies two rounds of masking and, for every image it certifies, provably returns the correct label for any patch that fits inside one mask. We show that on traffic signs the defense certifies almost nothing when paired with a normally trained classifier (1.7% to 4.8% certified accuracy on GTSRB), because a single mask can hide the small central symbol that distinguishes sign classes. We propose mask-aware training, which trains the classifier on images occluded by random pairs drawn from the defense's own mask set, with a sampling bias toward masks over the sign's centre. The defense, mask set and certification procedure are unchanged, so the guarantee is preserved. For an ImageNet-pretrained ResNet-50, mask-aware training raises certified accuracy from 4.8% to 60.0%. Under real per-image adversarial patches, the defended ResNet-50 reaches 85.7% accuracy, versus 74.6% for the original PatchCleanser with a normally trained ResNet-50.

Introduction

Deep classifiers used in driver assistance and autonomous driving read traffic signs from camera images. Physical adversarial patches, small printed stickers placed on or near an object, can cause confident misclassification [2, 3]. Empirical defenses are routinely broken by adaptive attacks, which motivates certified defenses: methods that prove a prediction cannot be changed by any patch of a given size [4, 5, 6].

PatchCleanser [1] is a certified defense that works with any image classifier. It evaluates the classifier on images occluded by one and then two masks from an RR-covering mask set and certifies an image when all two-mask predictions agree with the label.

Traffic signs are harder. A sign’s class is decided by a small symbol at its centre (the digits of a speed limit, the pictogram of a warning sign), and a mask sized to cover a patch can hide that symbol entirely. We find that PatchCleanser with a normally trained model certifies only 1.7% to 4.8% of GTSRB test images. This paper makes the following contributions:

  • An end-to-end certified-patch-defense pipeline for traffic signs (GTSRB), including training, per-image adversarial patch generation, two-mask inference and certification.

  • Mask-aware training: training with random pairs from the defense’s own mask set, biased toward the grid centre. It requires no change to inference and keeps the certificate valid.

  • A comparison with the original PatchCleanser on a wide CNN and a ResNet-50: certified accuracy rises from 1.7–4.8% to 53.5–60.0%, and accuracy under real adversarial patches from 72.8–74.6% to 80.9–85.7%.

Adversarial patches

  1. Adversarial patches: Brown et al. [2] introduced universal, printable adversarial patches, and Eykholt et al. [3] demonstrated physical sticker attacks that cause stop signs to be misread. The attacker controls all pixels inside a contiguous region and nothing outside it.

  1. Certified patch defenses: Interval bound propagation [4], derandomized smoothing [5] and small-receptive-field models [6] give provable guarantees but constrain the architecture. PatchCleanser [1] is architecture-agnostic, and later work improves its efficiency and utility [7, 8]. Saha et al. [9] show that occlusion-based training (Greedy Cutout) improves PatchCleanser on natural-image benchmarks; PatchCleanser itself fine-tunes with Cutout [10]. We study the traffic-sign domain, where the defense fails without such training, and train with the defense’s own mask pairs.

Certified patch defenses

Double masking

  1. Double masking: Let ff be a classifier and xx an image. A mask m∈{0,1}H×Wm \in\{0,1\}^{H \times W} zeroes a square region. A mask set M={m1,…,mk}\mathcal{M} = \{m_1,\ldots,m_k\} is RR-covering for a p×pp \times p patch if every possible patch location is fully covered by at least one mask. With stride ss and mask size p+s−1p+s-1, a k×k\sqrt{k} \times\sqrt{k} grid of masks is RR-covering [1]. The defense computes one-mask predictions y^i=f(x⊙mi)\hat{y}_i = f(x \odot m_i) and, when they disagree, two-mask predictions y^ij=f(x⊙mi⊙mj)\hat{y}_{ij} = f(x \odot m_i \odot m_j) (Algorithm 2). If y^ij=y\hat{y}_{ij} = y for all i,ji,j on the clean image, the output equals yy for every patched version of xx [1]; this is the certificate (Algorithm 3).

Method

Threat Model and Mask Set

The attacker places one square patch covering 2.4% of the image pixels at any location with arbitrary content: 5×55 \times5 on 32×3232 \times32 inputs and 20×2020 \times20 on 128×128128 \times128 inputs. We use a 6×66 \times6 grid (k=36k = 36) of 9×99 \times9 masks at stride 5 (respectively 38×3838 \times38 at stride 19), which is R-covering for the patch. A two-mask prediction uses an unordered pair {i,j}\{i,j\} of masks, with i=ji = j meaning a single mask, so there are (362)+36=630+36=666\binom{36}{2} + 36 = 630 + 36 = 666 of them, i.e. k(k+1)/2k(k + 1)/2. Certification requires all 666 to be correct; inference needs at most 666, since Algorithm 2 evaluates two-mask predictions only for disagreeing masks. We compute all 666 once per image and reuse them for both. Figure 2 summarizes the pipeline.

Pipeline for mask-aware training and PatchCleanser inference

Figure 2. Pipeline. (a) The classifier is trained on images occluded by pairs from the defense’s own R-covering mask set. (b) Inference and certification use the unmodified double-masking defense.

Why Traffic Signs Are Hard to Certify

Figure 3 shows the error of the normally trained wide CNN when one mask is applied. Masks at the border cost about 3%, but the four masks over the centre raise the error to 50–59%, and none of the 651 speed-limit test images is certified: once the digits are hidden, 30, 50 and 80 look the same. Because certification needs all 666 two-mask predictions to be correct, these central failures are enough to break the certificate on almost every image.

Figure 3. Error (%) when a single mask is applied, by mask position on the 6×66 \times6 grid. Left: the wide CNN with normal training; right: the same network with mask-aware training (ours), which removes the central failure mode.

Mask-Aware Training

We train the classifier to predict the correct label from images occluded by pairs of the defense’s own masks (Algorithm 1):

min⁡θ E(x,y)E(i,j)∼πℓ(fθ(x⊙mi⊙mj),y),(1)\min_{\theta}\ \mathbb{E}_{(x,y)}\mathbb{E}_{(i,j)\sim\pi}\ell\left(f_{\theta}(x \odot m_i \odot m_j), y\right), \tag*{(1)}

where ℓ\ell is cross-entropy. The sampling distribution π\pi draws jj uniformly and, with probability 12\frac{1}{2}, draws ii from the interior masks I\mathcal{I} of the grid (the 4×44 \times4 centre), otherwise uniformly.

Algorithm 1 Mask-aware training

Input: data D\mathcal{D}, mask set M\mathcal{M}, interior set I⊂M\mathcal{I} \subset\mathcal{M}, keep rate qq, epochs EE

Output: classifier fθf_\theta

  1. for e=1e = 1 to EE do

  2. for each batch {(xb,yb)}⊂D\{(x_b, y_b)\} \subset\mathcal{D} do

  3. xb←xb⋅ub, ub∼U(0.7,1.3)x_b \leftarrow x_b \cdot u_b,\ u_b \sim\mathcal{U}(0.7, 1.3) ▷ brightness

  4. jb∼U(M)j_b \sim\mathcal{U}(\mathcal{M})

  5. ib∼U(I)i_b \sim\mathcal{U}(\mathcal{I}) w.p. 12\frac{1}{2}, else ib∼U(M)i_b \sim\mathcal{U}(\mathcal{M})

  6. x~b←xb\tilde{x}_b \leftarrow x_b w.p. qq, else xb⊙mib⊙mjbx_b \odot m_{i_b} \odot m_{j_b}

  7. θ←θ−η∇θ1B∑bℓ(fθ(x~b),yb)\theta\leftarrow\theta- \eta\nabla_\theta\frac{1}{B} \sum_b \ell(f_\theta(\tilde{x}_b), y_b)

  8. end for

  9. end for

Algorithm 2 Double-masking inference [1]

Input: image xx, classifier ff, mask set M\mathcal{M}

Output: label y^\hat{y}

  1. y^i←f(x⊙mi)\hat{y}_i \leftarrow f(x \odot m_i) for i=1..ki = 1..k

  2. if all y^i\hat{y}_i are equal then

  3. return y^1\hat{y}_1 ▷ Case I: agreement

  4. end if

  5. ymaj←y_{\mathrm{maj}} \leftarrow majority of {y^i}\{\hat{y}_i\}

  6. for each ii with y^i≠ymaj\hat{y}_i \ne y_{\mathrm{maj}} do

  7. if f(x⊙mi⊙mj)=y^if(x \odot m_i \odot m_j) = \hat{y}_i for all jj then

  8. return y^i\hat{y}_i ▷ Case II: consistent disagreer

  9. end if

  10. end for

  11. return ymajy_{\mathrm{maj}} ▷ Case III

Algorithm 3 Certification [1]

Input: clean image xx, label yy, classifier ff, mask set M\mathcal{M}

  1. for $1 \le i \le j \le k$ do

  2. if f(x⊙mi⊙mj)≠yf(x \odot m_i \odot m_j) \ne y then

  3. return not certified

  4. end if

  5. end for

  6. return certified ▷ no patch can change the output

A fraction qq of each batch is left unmasked. In our models every training image is masked (q=0q = 0). Since inference and certification are not modified, the PatchCleanser guarantee holds for the trained model.

Experimental Setup

Dataset. GTSRB [11]: 26,640 training and 12,630 test images, 43 classes. We evaluate on a fixed random subset of 2,000 test images; every method sees the same images and patch locations.

Models. Table I lists the classifiers. The wide CNN (five convolutional layers) is trained from scratch at 32×3232 \times32. ResNet-50 [12] starts from ImageNet weights and is fine-tuned at 128×128128 \times128 on a Colab T4 GPU with mixed precision. For each model, the original PatchCleanser uses the normally trained network and ours uses the mask-aware one; the defense is identical.

ModelParamsInput (px)Patch (px)Epochs
Wide CNN (from scratch)0.73M32540
ResNet-50 (pretrained)23.6M1282030

Table I. Model architectures and parameters

Each model is trained twice with the same recipe: normally (original PatchCleanser) and with mask-aware training (ours). Both wide CNNs also use a random ±2\pm2-pixel translation during training.

Clean imagesAdversarial patch
MethodNo def.DefenseCertifiedNo def.Defense
Wide CNN
PatchCleanser97.993.81.776.172.8
Ours97.393.253.570.080.9
ResNet-50
PatchCleanser99.296.14.876.674.6
Ours97.993.760.080.785.7

Table II. Original PatchCleanser vs. ours on 2,000 GTSRB test images (%). Shaded cells highlight our gains.

Attack. Adversarial patch: per-image, untargeted, 100 Adam [13] steps on the patch pixels maximizing the cross-entropy of the undefended model at a random location. Certified accuracy covers every patch content and location in the threat model.

Results

Certified Accuracy

tbl:2 and Figure 4 compare the original PatchCleanser with ours. The original certifies only 1.7% (wide CNN) and 4.8% (ResNet-50) of test images. With mask-aware training the same defense certifies 53.5% and 60.0%, gains of 51.8 and 55.2 points. Clean accuracy with the defense drops by 0.6 and 2.4 points.

Figure 4. Original PatchCleanser vs. ours on GTSRB (2.4% patch). Left: certified accuracy; right: accuracy with the defense under a real adversarial patch.

Robustness to Real Adversarial Patches

Without a defense, adversarial patches reduce accuracy to 70.0–80.7% (Table II). The original PatchCleanser makes this slightly worse (72.8% vs. 76.1% and 74.6% vs. 76.6%).

because the normally trained model misclassifies the masked images. With ours the defended accuracy reaches 80.9% and 85.7%, 8.1 and 11.1 points above the original. Figure 1 shows examples.

Figure 1. Examples of GTSRB test signs (top) and the same signs with an adversarial 5×55 \times5 patch (bottom), using the wide CNN trained with our method (Table I). Without a defense the classifier is fooled (e.g., Speed limit 100 →\to 120); with mask-aware training (ours) inside the unchanged double-masking defense it returns the correct class.

Limitations

We use 2,000 of the 12,630 test images (666 forward passes per image). The adversarial patch targets the undefended model, not the defense; certified accuracy holds against any patch. Each setting is trained once, and all patches are digital.

Conclusion

PatchCleanser’s guarantee transfers to traffic-sign recognition only if the classifier can recognize signs with a mask over their central symbol. Mask-aware training with the defense’s own mask pairs and a centre bias supplies this ability without modifying the defense. On GTSRB our best model, a ResNet-50, goes from 4.8% to 60.0% certified and reaches 85.7% defended accuracy under adversarial patches. Future work includes the full test set and physical stickers.

Terminology and Definitions

GTSRB: The German Traffic Sign Recognition Benchmark [11] contains 39,270 natural images of 43 road sign classes (26,640 train, 12,630 test) across diverse scales, lighting, and degradation. We evaluate on a fixed subset of 2,000 test images with identical patch coordinates across all models.

Adversarial patch: A localized perturbation [2], [3] where an adversary freely modifies pixels within a bounded spatial region (e.g., a physical sticker on a sign), leaving other pixels intact. In our threat model, the patch covers 2.4% of pixels (5 × 5 on 32 × 32, 20 × 20 on 128 × 128).

Threat model: Formal adversary definition: placing one square patch of up to 2.4% pixel area anywhere on the sign with arbitrary continuous RGB values to cause misclassification, subject to no LpL_p-norm bound.

Defense: An algorithmic pipeline wrapped around a classifier to resist attacks. Here, we evaluate PatchCleanser, a certified defense based on two rounds of spatial masking.

PatchCleanser: An architecture-agnostic certified defense [1] that guarantees robustness against localized patches via double masking without modifying model weights.

Mask: A spatial occlusion operator m∈{0,1}H×Wm \in\{0,1\}^{H \times W} setting pixels to zero in a square window (x⊙mx \odot m) prior to inference (9 × 9 for 32 × 32; 38 × 38 for 128 × 128), suppressing adversarial patches.

Mask set, kk: A discrete set M={m1,…,mk}\mathcal{M} = \{m_1,\ldots,m_k\} of k=36k = 36 masks arranged on a uniform 6 × 6 grid across the image, governing spatial resolution and evaluation overhead.

R-covering: The structural property ensuring every valid p×pp \times p patch location is fully enclosed by at least one mask. Sizing masks to p+s−1p+s-1 for stride ss guarantees covering across continuous offsets.

One-/two-mask prediction: Model inferences on occluded inputs: y^i=f(x⊙mi)\hat{y}_i = f(x \odot m_i) for single mask mim_i; y^ij=f(x⊙mi⊙mj)\hat{y}_{ij} = f(x \odot m_i \odot m_j) for mask pair {mi,mj}\{m_i,m_j\} (i=ji = j denotes single mask).

666 (Two-mask evaluations): Total count of unordered mask pairs from k=36k = 36 masks, including a pairing with itself: (362)+36=36×372=666\binom{36}{2} + 36 = \frac{36 \times37}{2} = 666, evaluated once per sample and shared.

Double masking: PatchCleanser’s inference rule (Algorithm 2). It checks consensus among one-mask predictions (Case I) and identifies if a minority prediction consistently disagrees across secondary masks (Case II); otherwise majority vote is returned (Case III).

Certificate: Formal verification that no patch in the threat model can change the defended output on a clean image (Algorithm 3), proven when all 666 two-mask evaluations match label yy.

Certified accuracy: Fraction of test images correctly classified and certified, establishing an attack-independent lower bound on defended accuracy against any admissible patch.

No defense / Defense: Comparative evaluation settings: No defense measures raw classifier accuracy; Defense measures accuracy when wrapped inside the double-masking pipeline.

Mask-aware training: Our training method (Algorithm 1) optimizing the classifier on images occluded by sampled pairs from M\mathcal{M}, conditioning it to recognize signs under dual occlusions.

Centre bias: A sampling distribution π\pi during training where mask ii is drawn from interior masks I⊂M\mathcal{I} \subset\mathcal{M} (4 × 4) with probability 0.5 (else uniformly), forcing reliance on peripheral cues.

qq (keep rate): The fraction of each training minibatch left unmasked. We set q=0q = 0, occluding every training image to maximize robustness to severe occlusions.

Normal training: Standard training on clean images with brightness scaling only; serves as the baseline model in original PatchCleanser.

PatchCleanser (original): Baseline combining the unmodified PatchCleanser defense with a normally trained neural network.

Ours: The combination of the exact PatchCleanser defense and certification procedure with a classifier trained via mask-aware training.

Wide CNN: A five-layer convolutional neural network (0.73M parameters) trained from scratch on 32 × 32 inputs with ±2-pixel random translations and brightness augmentations for 40 epochs.

ResNet-50: A 50-layer residual network (23.6M parameters) [12] initialized with ImageNet weights and fine-tuned on GTSRB at 128 × 128 for 30 epochs using mixed precision on GPU.

References

  1. [1]C. Xiang, S. Mahloujifar, and P. Mittal, “PatchCleanser: Certifiably robust defense against adversarial patches for any image classifier,” in Proc. USENIX Security Symp., 2022.arxiv.org/abs/2108.09135
  2. [2]T. B. Brown, D. Mané, A. Roy, M. Abadi, and J. Gilmer, “Adversarial patch,” arXiv:1712.09665, 2017.arxiv.org/abs/1712.09665
  3. [3]K. Eykholt et al., “Robust physical-world attacks on deep learning visual classification,” in Proc. IEEE/CVF CVPR, 2018.DOI
  4. [4]P. Chiang, R. Ni, A. Abdelkader, C. Zhu, C. Studer, and T. Goldstein, “Certified defenses for adversarial patches,” in Proc. ICLR, 2020.arxiv.org/abs/2003.06693
  5. [5]A. Levine and S. Feizi, “(De)randomized smoothing for certifiable defense against patch attacks,” in Proc. NeurIPS, 2020.arxiv.org/abs/2002.10733
  6. [6]C. Xiang, A. N. Bhagoji, V. Sehwag, and P. Mittal, “PatchGuard: A provably robust defense against adversarial patches via small receptive fields and masking,” in Proc. USENIX Security Symp., 2021.arxiv.org/abs/2005.10884
  7. [7]C. Xiang, T. Wu, S. Dai, J. Petit, S. Jana, and P. Mittal, “PatchCURE: Improving certifiable robustness, model utility, and computation efficiency of adversarial patch defenses,” in Proc. USENIX Security Symp., 2024.arxiv.org/abs/2310.13076
  8. [8]J. Li, H. Zhang, and C. Xie, “ViP: Unified certified detection and recovery for patch attack with vision transformers,” in Proc. ECCV, 2022.DOI
  9. [9]A. Saha, S. Yu, M. S. Nourouzadeh, W.-Y. Lin, and C. K. Mummadi, “Revisiting image classifier training for improved certified robust defense against adversarial patches,” Trans. Mach. Learn. Res., 2023.arxiv.org/abs/2306.12610
  10. [10]T. De Vries and G. W. Taylor, “Improved regularization of convolutional neural networks with Cutout,” arXiv:1708.04552, 2017.arxiv.org/abs/1708.04552
  11. [11]J. Stallkamp, M. Schlipsing, J. Salmen, and C. Igel, “Man vs. computer: Benchmarking machine learning algorithms for traffic sign recognition,” Neural Networks, vol. 32, pp. 323–332, 2012.DOI
  12. [12]K. He, X. Zhang, S. Ren, and J. Sun, “Deep residual learning for image recognition,” in Proc. IEEE CVPR, 2016.arxiv.org/abs/1512.03385
  13. [13]D. P. Kingma and J. Ba, “Adam: A method for stochastic optimization,” in Proc. ICLR, 2015.arxiv.org/abs/1412.6980

Paper details

vlnc:W_q5dkdcyw
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 2

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Computer Science

Not recorded for this paper

View statement
Looking for related papers…
Contents