Networks that clean up compressed images, removing blocking, ringing and blur, work well on the compression format they were trained on and degrade sharply on formats they have not seen. A model tuned on JPEG meets HEVC, VVC, AVIF, or a learned neural codec such as HiFiC, and quality drops. One published remedy is adversarial training: during training, perturb each input in the direction that most hurts the model, so the model learns to handle inputs worse than any it has seen. Generalized Real-World Super-Resolution through Adversarial Robustness (RSR) showed this helps super-resolution generalize to unseen corruptions. It has two problems. First, it uses many-step pixel-space attacks over a full ESRGAN generator, which is expensive. Second, those attacks are small additive noise bounded in each pixel, and that noise does not look like the structured, non-additive artifacts real codecs produce.
We propose to move the adversary out of pixel space and into the space of codec settings, then make it cheap. Concretely, the adversary picks the worst-case quantization pattern. That pattern is either a per-block, per-frequency map of quantization step sizes in a transform codec with variable block sizes, or a perturbation of the compressed latent inside a pretrained neural codec. The adversary finds it with a single randomly initialized gradient step and reuses gradients across steps, following the fast and free adversarial training methods from classification. The claim is that a restorer trained against a worst case from within a family of plausible codecs transfers to held-out codecs better than two alternatives at equal GPU-hours. The first is a restorer trained on a uniform mix of real codecs. The second is one trained against pixel-norm adversaries. The new part is neither "adversarial training for restoration" nor "fast adversarial training," both of which exist. It is the combination of a codec-structured perturbation set with a single-step solver, and a direct test of whether gradient-chosen hard codecs beat simply sampling hard codecs.
Core Claim
Let $x$ be a clean image and $C_\phi$ a differentiable proxy codec, where $\phi$ denotes the codec settings. For the transform family, $\phi$ is a map of log quantization steps over blocks and frequency bands, and the block partition is sampled from a quadtree to mimic HEVC and VVC partitioning. For the neural family, $\phi$ is an offset added to the latent of a frozen learned codec before its decoder. Let $R_\theta$ be the restoration network with weights $\theta$. We train
$$\min_\theta \; \mathbb{E}_{x,\phi_0}\Big[\max_{\phi \in \mathcal{B}(\phi_0)} \big\|R_\theta(C_\phi(x)) - x\big\|_1\Big],$$
Here $\phi_0$ is a randomly drawn nominal setting, and $\mathcal{B}(\phi_0)$ is a box around it in which the rate stays within a fixed band. The rate is estimated from the proxy's own entropy model, so the adversary cannot win by simply deleting information. Rounding is replaced during training by additive uniform noise, the standard relaxation used when training learned codecs. The inner maximization is solved by one signed gradient step from a uniform random start inside $\mathcal{B}$, as in Fast is better than free. Optionally, following Adversarial training for free!, the input gradient from the weight-update backward pass is recycled so the adversary costs almost nothing extra.
We use a pixel-level $\ell_1$ objective deliberately. Deep Universal Generative Adversarial Compression Artifact Removal documents the tension between fidelity metrics and perceptual realism. Mixing in perceptual or discriminator losses would confound "generalizes across codecs" with "hallucinates plausibly," so we stay on the fidelity track, where claims can be checked.
Relation to Prior Work
Three papers motivate the gap. RSR establishes that worst-case training aids out-of-distribution restoration. It uses pixel $\ell_\infty$ multi-step attacks and does not evaluate on modern or neural codecs. We keep its premise and change both the perturbation set and the solver. SR+Codec shows that no super-resolution model is uniformly good across video codecs, which is evidence that the cross-codec gap is real and not closed by scale alone. Sensitivity Decouple Learning and the sub-patch GAN work show that priors tied to a fixed block grid fail on non-grid artifacts. This constrains our design: the transform adversary must vary block partitions and not assume $8\times 8$.
Three papers supply the machinery. Fast and free adversarial training supply the single-step and gradient-recycling solvers. They also carry a known failure mode, catastrophic overfitting, where the model looks robust to one-step attacks but fails against multi-step ones. We test for its analogue explicitly. HYPIR++ cuts cost by moving generator-versus-discriminator training into a latent space. Our neural-codec adversary borrows the "work in latent space" idea but applies it to the input perturbation, a different min-max than a GAN discriminator.
The closest competitors on the task are prompt-based universal restorers. UCIP predicts per-pixel mixtures of small prompt bases and reaches unseen codecs (WebP, ELIC) through prompt tuning on those codecs. PromptCIR encodes unknown compression settings implicitly. MoE-DiffIR routes among diffusion-prior experts but hallucinates textures. All of them train on a fixed list of real codecs. We instead train against a worst case inside a parametric codec family, and we measure transfer with no target-codec data at all. Robustness Tokens make robustness cheap by tuning a few tokens on a frozen transformer. We treat that as a secondary variant, adversarially tuning only UCIP's prompt bases, and not as the core method, because it was only shown for classification and segmentation under pixel noise.
Research Program
We build two differentiable proxy codecs. The first is a variable-block transform codec with a learnable quantization-step map and a simple entropy model for the rate constraint. The second is a frozen Cheng-style learned codec whose latent receives the adversarial offset. The restoration backbone is a UCIP-sized network (about 11.4M parameters). We use it because it is the strongest efficient universal restorer in the file and allows prompt-only variants. Training data is DIV2K plus LSDIR clean images, as in PromptCIR.
The central protocol is leave-codec-family-out. The adversary's families (block-transform and one neural codec) and any real codecs used for mixing are kept strictly disjoint from the test codecs. Test codecs are HEVC, VVC, AVIF, WebP, HiFiC and ELIC under the UCSR and Universal CIR settings, plus the real multi-generation VP9, H.264 and AV1 artifacts in StreamSR from Exploring Real-Time Super-Resolution. A second experiment asks whether the single-step structured adversary hides a gap. Every checkpoint is attacked with a 10-step adversary in the same codec family. If the loss under one step and under ten steps diverge sharply, that is the restoration analogue of catastrophic overfitting. We also record the cost of the adversary in GPU-hours and memory for each solver: 10-step, single-step, and recycled.
Baselines
The naive reference is the same backbone trained only on JPEG and one neural codec with no adversary. It shows the size of the cross-codec gap under our split.
The strongest simple competitor is uniform multi-codec mixing. The same backbone is trained on the real training codecs across randomized quality settings, plus images passed through our proxy codecs with $\phi$ sampled uniformly from the same boxes the adversary uses. It gets the same GPU-hours as our method, the extra budget going to more iterations, and the same learning-rate search. Beating it means a better average PSNR across the six held-out codecs, with no held-out codec losing more than a small margin. The gain must hold across three seeds and exceed seed variance.
The ablation that isolates the key ingredient is loss-guided hard-setting sampling. It uses the same proxy codec family, but settings are chosen by evaluating several random $\phi$ per image and training on the one with the highest loss, with no gradient. It is matched in compute to the single-step adversary. If our gradient adversary does not beat this, the contribution reduces to "the codec family matters," and we will say so.
The pixel-noise baseline is RSR's recipe on the same backbone. We run it in its original 10-step form as a cost reference and in a single-step random-start form matched to our compute. This isolates structured versus unstructured perturbations.
The strongest existing method is UCIP trained on its original six-codec mix. For WebP and ELIC we also run UCIP with prompt tuning on target data, as an upper bound that uses information our method never sees. The file gives only relative results for it: 0.45 dB PSNR over PromptIR with 11.4M versus 35.7M parameters on UCSR. It also reports PromptCIR at 34.68 dB PSNR on the DIV2K blind track versus 34.52 for PromptIR, and RSR at an average LPIPS 0.35 lower than ESRGAN on NTIREsyn and AIMsyn. No reported result was found on Lacuna for absolute held-out-codec PSNR of any method under a leave-family-out split, so we will reproduce all baselines ourselves under a single protocol.
Why not just…?
Why not just train on a big mix of real codecs? This is the real threat. PromptCIR's large-data training and StreamSR fine-tuning both show that diversity helps. Our answer is empirical, not rhetorical. The mixing baseline sees the same proxy codec family, uniformly sampled, at matched compute. If it matches our method on held-out codecs, the adversary adds nothing. SR+Codec's finding that no single model is uniformly good across codecs suggests that uniform mixing leaves hard regions under-trained, and that is precisely the gap the worst-case objective targets.
Why not just use RSR-style pixel adversarial training, made fast? Pixel $\ell_\infty$ noise is additive and roughly uniform across space. Codec artifacts are block-aligned, directional, or smooth structural loss. The RSR paper itself notes that misaligned perturbations push the generator toward artifacts or over-smoothing. The compute-matched single-step pixel baseline tests directly whether structure matters. We expect it to help most on noisy real content in StreamSR and least on neural-codec blur.
Why not just sample hard codec settings instead of computing gradients? This alternative could plausibly work as well, which is why it is the key ablation and not a straw man. A gradient step can reach per-block, per-frequency step-size maps that random sampling almost never produces. Whether that matters is exactly what the comparison settles.
Why not just prompt-tune UCIP on each new codec? That needs data from the target codec and a tuning run per codec. Our setting assumes the deployment codec is unknown. Prompt-tuned UCIP serves as an upper bound. Closing a substantial fraction of the distance between zero-shot UCIP and prompt-tuned UCIP, without target data, is a meaningful result even if we do not surpass it.
Proposed Experiments and Decisive Checks
The primary metric is PSNR and SSIM on each held-out codec across UCSR and Universal CIR settings on LIVE1, BSDS500 and DIV2K, reported per codec and not only on average. It is paired with training GPU-hours, which gives held-out gain per GPU-hour. LPIPS is reported as a secondary check that fidelity gains do not come from over-smoothing. On StreamSR, which has no clean references at the source resolution, we use its paired downscaled evaluation and a small preference study against the mixing baseline.
Three outcomes would be decisive. The proposal succeeds if the structured single-step adversary beats compute-matched uniform mixing and hard-setting sampling on held-out codecs, especially the neural codecs HiFiC and ELIC, whose artifacts differ most from block transforms. It also requires that the 10-step versus 1-step loss gap stays small throughout training. It fails if hard-setting sampling matches it, which would mean the codec family and not the gradient does the work. It is unsafe in its fast form if the multi-step check reveals overfitting-style collapse. In that case we would report the cost at which the recycled or two-step solver stays stable. A final small experiment tunes only UCIP's prompt bases against the adversary with the backbone frozen, as a Robustness-Tokens-style variant. It asks whether cross-codec robustness can be added to an existing restorer in a few hundred steps.
References
- Generalized Real-World Super-Resolution through Adversarial Robustness
- Fast is better than free: Revisiting adversarial training
- Adversarial training for free!
- Deep Universal Generative Adversarial Compression Artifact Removal
- SR+Codec: a Benchmark of Super-Resolution for Video Compression Bitrate Reduction
- Sensitivity Decouple Learning for Image Compression Artifacts Reduction
- Enhanced Latent-Space Adversarial Training for Super-Resolution
- UCIP: A Universal Framework for Compressed Image Super-Resolution Using Dynamic Prompt
- PromptCIR: Blind Compressed Image Restoration with Prompt Learning
- MoE-DiffIR: Task-Customized Diffusion Priors for Universal Compressed Image Restoration
- Robustness Tokens: Towards Adversarial Robustness of Transformers
- Exploring Real-Time Super-Resolution: Benchmarking and Fine-Tuning for Streaming Content