Coder Social home page Coder Social logo

guided-denoise's Introduction

Guided-Denoise

The winning submission for NIPS 2017: Defense Against Adversarial Attack of team TSAIL

Paper

Defense against Adversarial Attacks Using High-Level Representation Guided Denoiser

File Description

  • prepare_data.ipynb: generate dataset

  • Originset, Originset_test: the folder for original image

  • toolkit: the program running the attack in batch

  • Attackset: the attacks

  • Advset: the adversarial images

  • checkpoints: the models checkpoint used, download here

  • Exps: the defense model

  • GD_train, PD_train: train the defense model using guided denoise or pixel denoise

How to use

the attacks are stored in folder Attackset the script is in the toolkit folder. in the run_attacks.sh file: modify models to the attacks you want to generate, separate by comma, or use "all" to include all attacks in Attackset. use the command to run:

bash run_attacks.sh $gpuids

where gpuids is the id of the gpus you want to use, they are number separated by comma. It will generate the training set. Then change the line DATASET_DIR="${parentdir}/Originset" to DATASET_DIR="${parentdir}/Originset_test", and run the command bash run_attacks.sh $gpuids again.

Then specify a model you want to use, the models are stored in Exp folder, there is a sample folder, it refers to a model named "sample", let's use it. Then go to GD_train if you want to use guided denoiser, run

python main --exp sample

The program will load Exp/sample/model.py as a model to train. and also you can specify other parameters defined in the GD_train/main.py

guided-denoise's People

Contributors

lfz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

guided-denoise's Issues

Link for Imagenet subset

Can you provide the extracted images from Imagenet? The original dataset is too big to download.

Training Dataset Size

Hi,
I wonder how many images do you select per class as training dataset? In the paper, you select 30 images per class but in prepare_data n_per_class is set to 4.

Thanks

the load of dataset

in prepare_data.ipynb, dose the imagenet_path means the whole imagenet2012 datasets? it seems so big for this dataset

Meet problem when load model dict

Hello, I have met some problem with loading the dictionary of the model.

The code of mine is like this. I choose InceptionV3 model. I want to load the "inception_v3.ckpt" dictionary provided by you.
However, it failed and return an error. The error is shown below.

    input_size = [299, 299]
    block = Conv
    fwd_out = [64, 128, 256, 256, 256]
    num_fwd = [2, 3, 3, 3, 3]
    back_out = [64, 128, 256, 256]
    num_back = [2, 3, 3, 3]
    n = 1
    hard_mining = 0
    loss_norm = False
    denoise = Denoise(input_size[0], input_size[1], block, 3, fwd_out, num_fwd, back_out, num_back)
    net = Inception3(denoise)

    model_path = "inception_v3.ckpt"
    pretrain_dict = torch.load(model_path)
    state_dict = net.state_dict()
    for key in pretrain_dict.keys():
        assert state_dict.has_key(key)
        value = pretrain_dict[key]
        if not isinstance(value, torch.FloatTensor):
            value = value.data
        state_dict[key] = value

    net.load_state_dict(state_dict)

image

Could you please tell me where is the bug? The pytorch version used by me is 1.2.0.
Thank you very much!

Which version of tensorflow did you use in this respository?

When i tried to run this code, i encountered the following errors in the 'attack_iter.py' file.

W tensorflow/core/framework/op_kernel.cc:1192] Invalid argument: Shape mismatch in tuple component 0. Expected [299,299,3], got [2038,1500,3]
OutOfRangeError (see above for traceback): FIFOQueue '_1_batch/fifo_queue' is closed and has insufficient elements (requested 3, current size 0)
         [[Node: batch = QueueDequeueUpToV2[component_types=[DT_UINT8, DT_STRING], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/device:CPU:0"](batch/fifo_queue, batch/n)]]

I just changed the image format from '.png' to '.jpg', and changed the following code:

    image = tf.image.decode_png(image_file)

to

    image = tf.image.decode_jpeg(image_file, channels=3)

I have tried some methods to solve it, but nothing worked. So i guess maybe the version of my tensorflow(1.4) is different from yours.

Wish to receive your reply, thank you!

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.