On the unreasonable vulnerability of transformers for image restoration -- and an easy fix

Shashank Agnihotri, Kanchana Vaishnavi Gandikota, Julia Grabinski, Paramanand Chandramouli, Margret Keuper

TL;DR

While Vision Transformers (ViTs) have revolutionized image restoration, they possess a surprising "glass jaw": extreme vulnerability to adversarial attacks. This paper demonstrates that state-of-the-art models like Restormer and NAFNet produce bizarre spectral artifacts under pressure, but reveals that simple architectural choices—specifically swapping out "activation-free" gates for standard ReLUs—can dramatically improve their robustness.

What Problem Does This Paper Address?

In the world of computer vision, Transformers are the new gold standard, not just for classifying images but for restoring them (e.g., removing blur or noise). A common narrative in research is that Transformers are inherently more robust than their Convolutional Neural Network (CNN) ancestors.

However, most of that research focuses on classification (picking a label). Image restoration is a different beast; it’s a regression task requiring precise pixel-wise predictions. The authors set out to see if the "robustness halo" of Transformers extends to restoration. They discovered that these models are, in fact, "unreasonably" vulnerable. A tiny, imperceptible perturbation to a blurred image can cause a state-of-the-art restorer to output an image filled with psychedelic color shifts and intense geometric patterns.

Methods

The researchers conducted a rigorous "stress test" using two primary adversarial attack methods:

  • Projected Gradient Descent (PGD): The industry standard for finding the small perturbations that most confuse a model.
  • CosPGD: A newer attack specifically designed for dense prediction tasks (like restoration) that uses cosine similarity to focus the attack on pixels the model is already struggling with.

They evaluated three main architectures:

  1. Restormer: A high-capacity Transformer-based model.
  2. Baseline Network: A simplified version of Restormer.
  3. NAFNet (Non-linear Activation-free Network): A highly efficient model that removes traditional activation functions (like ReLU) in favor of a "Simple Gate" (element-wise multiplication).

To fix the vulnerabilities, they employed Adversarial Training (AT) using the Fast Gradient Sign Method (FGSM) and performed architectural ablations to isolate which design choices were causing the most trouble.

Datasets

The study focused on the task of dynamic image deblurring using the GoPro dataset. This dataset contains 3,214 pairs of real-world blurry images and their corresponding sharp ground truths, captured with a high-speed camera. The data was split into 2,103 training images and 1,111 test images.

Key Insights and Ideas

  • The "Simple Gate" is a Liability: The most striking finding is that NAFNet’s "activation-free" design—intended for efficiency—is a major source of weakness. The element-wise multiplication in its "Simple Gate" seems to cause aliasing and color-mixing artifacts when the model is attacked.
  • Spectral Artifacts are Model-Specific: Different architectures fail in different ways. Restormer and the Baseline network tend to produce "ringing" artifacts (wavy lines), while NAFNet produces intense grid-like patterns and color distortions.
Comparing images reconstructed by all considered models after 5 iterations of CosPGD attack. We observe strong spectral artifacts in the reconstructed images.
  • ReLU is a Robustness Power-Up: In a surprising twist, the authors found that replacing the sophisticated "Simple Gate" or smooth GELU activations with the "old-school" ReLU significantly boosted robustness, even without any special adversarial training.
  • Capacity Matters for Defense: Larger models like the full Restormer were much better at "learning" to be robust during adversarial training compared to their simplified counterparts.

Key Results

The quantitative drop in performance under attack is staggering. On clean images, NAFNet achieves a high PSNR (Peak Signal-to-Noise Ratio) of 32.87. However, under a 20-iteration CosPGD attack, that crashes to a measly 5.81.

  • Adversarial Training (AT) helps: Training Restormer with adversarial examples (+ADV) brought its performance under attack from 7.59 up to 21.58 PSNR.
  • The ReLU Fix: An "Intermediate" network using ReLUs achieved 10.29 PSNR under attack without adversarial training, nearly doubling the performance of the standard NAFNet under the same conditions.
Images reconstructed by different models after CosPGD attack.

Limitations and Future Work

The authors acknowledge a classic trade-off: The Robustness-Accuracy Gap. While adversarial training and ReLU activations make the models much tougher, they also make the restored images slightly blurrier on "clean" (non-attacked) data.

Furthermore, while the "ReLU fix" removes the most egregious spectral artifacts, the resulting images are still not perfect restorations. The authors suggest that future work should move beyond just adversarial training to find new ways to ensure Transformer-based restorers can handle the unpredictable noise of the real world without sacrificing the crystal-clear output they are known for.

Summary updated

BibTeX
@inproceedings{agnihotri2023unreasonable,
  author = {Shashank Agnihotri and Kanchana Vaishnavi Gandikota and Julia Grabinski and Paramanand Chandramouli and Margret Keuper},
  title = {{On the unreasonable vulnerability of transformers for image restoration -- and an easy fix}},
  booktitle = {Workshops @ ICCV},
  year = {2023},
}
Figure