Universal Adversarial Purification with DDIM Metric Loss for Stable Diffusion
Li Zheng, Liangbin Xie, Jiantao Zhou, He YiMin
TL;DR
This work introduces UDAP, a universal adversarial purification framework tailored for diffusion-based Stable Diffusion models. By exploiting DDIM inversion and a novel DDIM metric loss $\\mathcal{L}_{\\mathrm{DDIM}}$, UDAP removes adversarial noise from latent representations, while a dynamic epoch strategy adjusts purification effort to the perturbation strength, dramatically improving efficiency. The approach demonstrates robust defense against diverse SD attacks (e.g., PID, Anti-DB, MIST) and generalizes across SD versions and prompts, achieving superior purification metrics on DreamBooth experiments. The results suggest practical viability for deploying SD securely in real-world applications with mixed clean and adversarial data.
Abstract
Stable Diffusion (SD) often produces degraded outputs when the training dataset contains adversarial noise. Adversarial purification offers a promising solution by removing adversarial noise from contaminated data. However, existing purification methods are primarily designed for classification tasks and fail to address SD-specific adversarial strategies, such as attacks targeting the VAE encoder, UNet denoiser, or both. To address the gap in SD security, we propose Universal Diffusion Adversarial Purification (UDAP), a novel framework tailored for defending adversarial attacks targeting SD models. UDAP leverages the distinct reconstruction behaviors of clean and adversarial images during Denoising Diffusion Implicit Models (DDIM) inversion to optimize the purification process. By minimizing the DDIM metric loss, UDAP can effectively remove adversarial noise. Additionally, we introduce a dynamic epoch adjustment strategy that adapts optimization iterations based on reconstruction errors, significantly improving efficiency without sacrificing purification quality. Experiments demonstrate UDAP's robustness against diverse adversarial methods, including PID (VAE-targeted), Anti-DreamBooth (UNet-targeted), MIST (hybrid), and robustness-enhanced variants like Anti-Diffusion (Anti-DF) and MetaCloak. UDAP also generalizes well across SD versions and text prompts, showcasing its practical applicability in real-world scenarios.
