Giter Club home page Giter Club logo

one-pixel-attack-keras's People

Contributors

falcaopetri avatar hyperparticle avatar jaewoosong 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

one-pixel-attack-keras's Issues

About the function `perturb_image`, should it return one image or multi image depending the parameter `xs`

def perturb_image(xs, img):
    # If this function is passed just one perturbation vector,
    # pack it in a list to keep the computation the same
    if xs.ndim < 2:
        xs = np.array([xs])

    # Copy the image n == len(xs) times so that we can 
    # create n new perturbed images
    tile = [len(xs)] + [1] * (xs.ndim + 1)
    imgs = np.tile(img, tile)

    # Make sure to floor the members of xs as int types
    xs = xs.astype(int)

    for x, img in zip(xs, imgs):
        # Split x into an array of 5-tuples (perturbation pixels)
        # i.e., [[x,y,r,g,b], ...]
        pixels = np.split(x, len(x) // 5)
        for pixel in pixels:
            # At each pixel's x,y position, assign its rgb value
            x_pos, y_pos, *rgb = pixel
            img[x_pos, y_pos] = rgb

    return imgs

AttributeError: 'ResNet' object has no attribute '_model'

When I run python train.py --model resnet --epochs 200 --batch_size 128
It occurs an error:

Traceback (most recent call last):
File "train.py", line 40, in
model.train()
File "/home/cvers/zgz/one-pixel-attack-keras-master/networks/resnet.py", line 162, in train
self.param_count = self._model.count_params()
AttributeError: 'ResNet' object has no attribute '_model'
Exception ignored in: <bound method BaseSession.del of <tensorflow.python.client.session.Session object at 0x7f9c07081be0>>
Traceback (most recent call last):
File "/home/cvers/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 701, in del
TypeError: 'NoneType' object is not callable

About dataset

Hello, I want to ask a question about the dataset.
Here, "Attack on 1,3,5 pixel perturbations (100 samples)" refers to the result of an attack on 100 images randomly selected from the original cifar10 dataset?
Or is it the result of generating 100 adversarial images for each of the 10,000 images in the cifar10 test dataset? Thank you!

SyntaxError: invalid syntax

File "helper.py", line 32
x_pos, y_pos, *rgb = pixel
^
SyntaxError: invalid syntax
I met this problem while running the "imports" of "1_one-pixel-attack-cifar10", with both python2 and python3.

How does the targeted attack work?

Hello:
I feel puzzled about that if just changing one pixel can implement the targeted attack. I think only one-pixel change can not make the target that attacked with clear.
Please tell me how does the targeted attack work with so few pixel.
Thank you!

How to display the picture after the attack?

Hello, after running attack.py, the pkl file is saved. I would like to ask how to display the image after the attack? Attack is to perturb a single pixel. Has the value of other pixels in the image changed? Thank you and look forward to your reply.

rerunning attack on the same images

Hi,

Just a suggestion:
numpy.random.choice(img_samples, samples) should be changed to numpy.random.choice(img_samples, samples, replace=False)

so images aren't duplicated during larger iterations.

The argument targeted

There is a argument,targeted,in the attack.py .

parser.add_argument('--targeted', action='store_false', help='Set this switch to test for targeted attacks.')

Please tell me,if the action = 'store_false',the attack is targeted or not?
Thank u for answering my issue.

how to fix RuntimeWarning: divide by zero encountered in double_scalars

using model lenet , when attacking it warns that "RuntimeWarning: divide by zero encountered in double_scalars" convergence=self.tol / convergence) is True):
it means covergence is zero? i dont know how to fix this please help me!
the error is appears in differential _evolution.py :585

One pixel and three pixel attacks are pretty hard to get it seems

Hey, @Hyperparticle.

Such a nice collection of materials, thank you!

I tried extending the CIFAR10 example to do some comparisons. It appears to me that for the kind of computational budget you followed, it's pretty hard to get a successful attack even on a small CNN (15722 learnable parameters).

Here's my notebook that does the comparison - https://colab.research.google.com/drive/1TKxtY63dqcuWAvrrDaDx3PQ3M7_xntQr?usp=sharing.

Am I missing out on something? One of the things I have changed is I have scaled the pixel values to be in the range of [0, 1]. Any help is much appreciated. Thanks!

Passing img instead of id

Function attack_success takes argument img which is an id of the image in the dataset. Wouldn't it be clearer if this variable is called img_id or something like this? Or we could pass the whole image from the dataset instead.

How to use gpu in the model ?

I try to use the gpu in the one-pixel attack for imagenet, because the model run on imagenet is too slow, but I use os.environ["CUDA_VISIBLE_DEVICES"] seems did not work, can you give some help. Thanks so much !

Getting a lot of adversarial images

Hello everyone,

I am trying to fool the entire cifar10 data-set by using the one-pixel attack and download it for a project.
As I do not know how the attack function has been made, I will be glad to get help from someone.
I noticed that I can only fool one image per iteration. What I would do is to fool many image then download them.

Best regards

About image processing

Hello, I would like to ask why CIFAR-10 was not pre-processed in your code, while the image of ImageNet was pre-processed?
In addition, does the adversarial examples need to be pre-processed (such as normalization) before being fed into the model for reclassification?

Not able to reproduce Google Collab notebook

It seems like imports are broken, which version of tensorflow/keras has been used?

ImportError: cannot import name 'Adam' from 'keras.optimizers'

in line from networks.pure_cnn import PureCnn

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.