SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2503.10081 · ICLR · 2025

AdvPaint: Protecting Images from Inpainting Manipulation via Adversarial Attention Disruption

Jae Woo, Sung-Eui Yoon, Joonsung Jeon, Suhyeon Kim, Sooel Ha, Son

arXiv · PDF · Open in the Atlas

Code that ran

3 of 4 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 2 failures of our instrument; 1 no recorded run), measured 2026-11-23; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2503.10081.json · badge: /api/ran/2503.10081.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
joonsungjeon/advpaint canonical (classifier label)
classifier basis: classifier_2025
3 ran · 1 no recorded run
FunctionStatusWhere it lives
collate_fn Ran
ran, honoured the contract we drafted
joonsungjeon/advpaint/AdvPaint.py
code served (permissive licence) · get_code("90fadec0aec03c1b")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# The collate_fn function takes a batch parameter and unpacks it using zip(*batch)
# This is typically used with a DataLoader where batch is a list of samples
# Each sample should be a tuple/list of elements that can be zipped together

# Create a simple batch of data
# Each item in the batch is a tuple of (input, target)
batch = [
    (torch.randn(4, 3), torch.tensor([1, 0, 1, 0])),
    (torch.randn(4, 3), torch.tensor([0, 1, 0, 1])),
]

ARGS = {
    "batch": batch
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
hook_fn Ran
ran; our contract draft was wrong, not the code
joonsungjeon/advpaint/AdvPaint.py
code served (permissive licence) · get_code("b194fd93d187cadf")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned function. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Global dicts that the hook function expects to exist in the closure
self_maps = {}
self_query = {}
self_key = {}
self_value = {}
cross_query = {}

# Create a minimal processor class with the attributes the hook checks
class MinimalProcessor:
    def __init__(self):
        self.timestep = 0
        self.attn_map = torch.randn(2, 4, 3)
        self.self_Q = torch.randn(2, 4, 5)
        self.self_K = torch.randn(2, 4, 5)
        self.self_V = torch.randn(2, 4, 5)
        self.query = torch.randn(2, 4, 6)

# Create a minimal module with a processor attribute
class MinimalModule(nn.Module):
    def __init__(self):
        super().__init__()
        self.processor = MinimalProcessor()

# Create a minimal module that will serve as the 'module' argument to forward_hook
module = MinimalModule()

# Define the arguments for hook_fn
ARGS = {
    "name": "test_attention_block",
    "detach": True,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
register_cross_attention_hook Ran
ran; our contract draft was wrong, not the code
joonsungjeon/advpaint/AdvPaint.py
code served (permissive licence) · get_code("99a4a64e057a4ce4")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned MockUNet. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
from diffusers.models.attention_processor import (
    Attention,
    AttnProcessor,
    AttnProcessor2_0,
    LoRAAttnProcessor,
    LoRAAttnProcessor2_0,
)

torch.manual_seed(0)

# Create a minimal mock UNet with attention modules
class MockAttentionModule(nn.Module):
    def __init__(self):
        super().__init__()
        self.processor = AttnProcessor()
        self.processor.store_attn_map = False
        self.processor.store_query = False
        self.processor.timestep = 0
        self.processor.attn_map = None
        self.processor.self_Q = None
        self.processor.self_K = None
        self.processor.self_V = None
        self.processor.query = None

    def forward(self, x):
        return x


class MockUNet(nn.Module):
    def __init__(self):
        super().__init__()
        # Create attention modules with names matching the filtering logic
        self.down_blocks = nn.ModuleDict({
            'attn1': MockAttentionModule(),
            'attn2': MockAttentionModule(),
        })
        self.mid_block = nn.ModuleDict({
            'attn1': MockAttentionModule(),
        })
        self.up_blocks = nn.ModuleDict({
            'attn2': MockAttentionModule(),
        })

    def named_modules(self):
        # Override to provide custom naming that matches the filtering logic
        modules_list = [
            ('down_blocks.0.attn1', self.down_blocks['attn1']),
            ('down_blocks.1.attn2', self.down_blocks['attn2']),
            ('mid_block.attn1', self.mid_block['attn1']),
            ('up_blocks.0.attn2', self.up_blocks['attn2']),
        ]
        for name, module in modules_list:
            yield name, module


# Create UNet instance
unet = MockUNet()

# Define ARGS for the function
ARGS = {
    'unet': unet,
    'ATTN': 'attn1',
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
diffusers, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type MockUNet — a MockUNet output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a MockUNet output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
pgd_SelfQKV_And_Cross_Xadv Not yet run
unverified (harvested, no recorded run)
joonsungjeon/advpaint/AdvPaint.py
code served (permissive licence) · get_code("0cf3b50f33f2d43b")
How it ran

no invocation recorded.

Also present in other papers' code

Of 4 samples lifted from this paper's linked repositories, 4 carry a function identity and 0 do not. Of the 4 distinct functions with an identity, 1 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 0 later) and 3 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
collate_fn 7 other papers
7 dated earlier
1405.0312 (2014-05)
Microsoft COCO: Common Objects in Context
1811.10200 (2018-11)
IDD: A Dataset for Exploring Problems of Autonomous Navigation in Unconstrained Environments
1901.07973 (2019-01)
DeepFashion2: A Versatile Benchmark for Detection, Pose Estimation, Segmentation and Re-Identification of Clothing Images
and 4 more not named here

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

The outstanding capability of diffusion models in generating high-quality images poses significant threats when misused by adversaries. In particular, we assume malicious adversaries exploiting diffusion models for inpainting tasks, such as replacing a specific region with a celebrity. While existing methods for protecting images from manipulation in diffusion-based generative models have primarily focused on image-to-image and text-to-image tasks, the challenge of preventing unauthorized inpainting has been rarely addressed, often resulting in suboptimal protection performance. To mitigate inpainting abuses, we propose ADVPAINT, a novel defensive framework that generates adversarial perturbations that effectively disrupt the adversary's inpainting tasks. ADVPAINT targets the self-and cross-attention blocks in a target diffusion inpainting model to distract semantic understanding and prompt interactions during image generation. ADVPAINT also employs a two-stage perturbation strategy, dividing the perturbation region based on an enlarged bounding box around the object, enhancing robustness across diverse masks of varying shapes and sizes. Our experimental results demonstrate that ADVPAINT's perturbations are highly effective in disrupting the adversary's inpainting tasks, outperforming existing methods; ADVPAINT attains over a 100point increase in FID and substantial decreases in precision. The code is available at https://github.com/JoonsungJeon/AdvPaint.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2503.10081")
get_code_for_paper("2503.10081")
have("2503.10081")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2503.10081.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2503.10081.svg)](https://syntology.ai/paper/2503.10081)

Connect an agent — have() is free.