Coder Social home page Coder Social logo

yrymax / diff-protect Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xavihart/diff-protect

0.0 0.0 0.0 73.77 MB

๐Ÿ›ก๏ธ[ICLR'2024] Toward effective protection against diffusion-based mimicry through score distillation, a.k.a SDS-Attack

Python 100.00%

diff-protect's Introduction

Toward effective protection against diffusion-based mimicry through score distillation [ICLR'2024]

Haotian Xue 1, Chumeng Liang 2,3, Xiaoyu Wu 2, and Yongxin Chen 1

1 Georgia Tech 2 SJTU 3 USC

TL;DR : novel insights into attacks agasint LDM, a more effective protection against malicious diffusion model editing

Updates

  • [01/15/2024] ๐ŸŽ‰ Our paper is accepted to ICLR'2024!
  • [11/24/2023] Paper finally shown on Arxiv
  • [09/27/2023] Paper will be released soon!
  • [09/27/2023] Our repo is alive!

Quick Setup

Install the envs:

conda env create -f env.yml
conda activate mist
pip install --force-reinstall pillow

Download the checkpoint of LDM [Stable-diffusion-model v1.4 checkpoint]

wget -c https://huggingface.co/CompVis/stable-diffusion-v-1-4-original/resolve/main/sd-v1-4.ckpt
mkdir ckpt
mv sd-v1-4.ckpt ckpt/model.ckpt

Run the Protection

Configs can be set in configs/attack/base.yaml, some keys arguments include:

attack:
    epsilon: 16 # l_inf budget
    steps: 100 # attack steps
    input_size: 512 # image size
    mode: sds 
    img_path: [IMAGE_DIR_PATH]
    output_path: [OUT_PATH]
    alpha: 1 # step size
    g_mode: "+"
    use_wandb: False
    project_name: iclr_mist
    diff_pgd: [False, 0.2, 'ddim100'] # un-used feature
    using_target: False
    target_rate: 5 # scale factor for L_S and L_T
    device: 0 # GPU id

here we offer some scripts to run different type of protections:

AdvDM:

python code/diff_mist.py attack.mode='advdm' attack.g_mode='+'

PhotoGuard:

python code/diff_mist.py attack.mode='texture_only' attack.g_mode='+'

Mist:

python code/diff_mist.py attack.mode='mist' attack.g_mode='+'

AdvDM(-):

python code/diff_mist.py attack.mode='advdm' attack.g_mode='-'

SDS(+):

python code/diff_mist.py attack.mode='sds' attack.g_mode='+'

SDS(-):

python code/diff_mist.py attack.mode='sds' attack.g_mode='-'

SDST(-):

python code/diff_mist.py attack.mode='sds' attack.g_mode='-' attack.using_target=True

the output includes: [NAME]_attacked.png which is the attacked image, [NAME]_multistep.png which is the SDEdit results, and [NAME]_onestep.png which is the onestep x_0 prediction results.

drawing drawing drawing

[From let to right]: AdvDM, Mist, SDS(-), using eps=16, SDS-version is much more effective than the previous two methods

Cited as:

@inproceedings{xue2023toward,
  title={Toward effective protection against diffusion-based mimicry through score distillation},
  author={Xue, Haotian and Liang, Chumeng and Wu, Xiaoyu and Chen, Yongxin},
  booktitle={The Twelfth International Conference on Learning Representations},
  year={2023}
}

diff-protect's People

Contributors

xavihart avatar njuaplusplus avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.