Abstract
As diffusion-based image editing tools become increasingly accessible, the risk of unauthorized image manipulation—such as the creation of deepfakes and misinformation—has grown significantly. While existing defensive frameworks attempt to protect images by injecting adversarial perturbations, they often fail against inpainting attacks because the attacker's mask effectively removes the protection from the target area. This paper introduces AdvPaint, a novel defensive framework that shifts the focus from global latent shifting to the disruption of internal attention mechanisms. By targeting cross-attention and self-attention layers within the diffusion model, AdvPaint ensures that even when a mask is applied, the surrounding protected pixels disrupt the generation process, leading to nonsensical and poorly aligned outputs.
1. Introduction
Diffusion models have democratized high-quality image manipulation. Inpainting, a specific subset of these tools, allows users to mask a region of an image and replace it with new content based on a text prompt. While beneficial for creative industries, this technology is easily weaponized. Current defensive measures like PhotoGuard or Glaze primarily target the global latent representation of an image. However, these methods are inherently vulnerable to inpainting: because an adversary must apply a mask to the area they wish to change, they inadvertently "delete" the protective perturbations in the very region where protection is most needed. AdvPaint addresses this fundamental flaw by targeting the model's "brain"—its attention mechanism.
2. The AdvPaint Framework
AdvPaint moves away from simple latent shifting, instead employing a strategy of "attention disruption." The framework targets two primary components of the U-Net architecture used in diffusion models:
2.1 Attention Mechanism Targeting
- Cross-Attention Disruption: Diffusion models use cross-attention to align text prompts with image features. AdvPaint perturbs the "query" ($q$) input, breaking this alignment. This prevents the model from accurately placing the requested object within the masked area, as it can no longer map the text prompt to the spatial features of the image.
- Self-Attention Disruption: By targeting the query, key, and value ($q, k, v$) within the image's self-attention blocks, AdvPaint destroys the model's ability to maintain semantic and spatial consistency. This results in distorted, messy, or completely unrelated generated content.
2.2 Two-Stage Perturbation Strategy
A significant challenge in defending against inpainting is that the defender does not know the exact shape or size of the mask an attacker will use. AdvPaint utilizes a "Grounded SAM" (Segment Anything Model) to identify potential target objects and create an enlarged bounding box. It then optimizes separate perturbations for the region inside the box and the background outside. This "outside-in" approach ensures that even if the attacker's mask does not perfectly match the original object, the surrounding protected pixels remain powerful enough to distract the model's attention away from the target area.
3. Experimental Evaluation
The researchers evaluated AdvPaint against a variety of state-of-the-art inpainting models and datasets to test its robustness and transferability.
- Datasets: The evaluation used 100 high-resolution images (512x512) from Pexels and Unsplash, paired with 50 diverse prompts generated by ChatGPT (e.g., "A gorilla in a forest clearing") to simulate realistic adversarial scenarios.
- Models: The defense was tested against Stable Diffusion (SD) Inpainter, HD-Painter, DreamShaper, and SD-2-Inpainting.
- Transferability: The team also explored how well the defense held up against newer Diffusion Transformer (DiT) architectures, such as Flux and Stable Diffusion 3 (SD3).
4. Key Results and Insights
AdvPaint significantly outperformed existing state-of-the-art defenses like PhotoGuard and AdvDM across both quantitative and qualitative metrics.
4.1 Quantitative Performance
AdvPaint achieved over a 100-point increase in Fréchet Inception Distance (FID) compared to baseline defenses. In the context of generative AI, a higher FID indicates that the generated images are of significantly lower quality and deviate heavily from real data distributions. Furthermore, there was a substantial drop in precision, indicating the models failed to generate objects that matched the user's prompt.
4.2 Qualitative Impact
Visually, while older defenses might allow a realistic (if slightly distorted) object to appear, AdvPaint typically results in "nothingness," blurry textures, or objects that are completely misaligned with the background. The disruption of the attention maps effectively prevents the model from forming a coherent structure within the masked region.
5. Discussion and Limitations
While AdvPaint represents a major step forward, it faces certain challenges:
- Computational Cost: Optimizing perturbations for multiple objects within a single image increases the computational overhead for the defender.
- Purification Attacks: Like most adversarial methods, AdvPaint can be weakened if an attacker applies "purification" techniques, such as heavy JPEG compression or adding secondary noise, before attempting the inpaint.
- DiT Architectures: Models using patch-based processing (like Flux) show more resistance to global perturbations. Future iterations of AdvPaint may require patch-level optimization to maintain high protection levels against the next generation of DiT-based models.
6. Conclusion
AdvPaint demonstrates that the most effective way to protect images from AI-driven inpainting is to disrupt the model's internal attention mechanisms. By recognizing that the "mask is the weakness" of traditional defenses, AdvPaint provides a robust, spatially-aware solution that forces malicious edits to fail, thereby preserving the integrity of digital content in an era of increasingly sophisticated generative AI.
Summary updated