mahmoods01 / agns

Implementation of AGNs, proposed in: M. Sharif, S. Bhagavatula, L. Bauer, M. Reiter. "A General Framework for Adversarial Examples with Objectives." In ACM TOPS, 2019.
36 stars 6 forks source link

Final eye glasses output for printing #2

Closed phuccuongngo99 closed 3 years ago

phuccuongngo99 commented 5 years ago

Thank you so much for the open source code. I'm able to run the training with my own image without trouble. However, i can't seem to find the generated eyeglasses anywhere to print out to try on physical attack. What am i missing? Thank you

mahmoods01 commented 5 years ago

Hello. Once the training of AGNs is done, you should use the generator to create the adversarial eyeglasses (i.e., you should provide the generator with input "noise" and it'll output candidate eyeglasses that you can use to fool face recognition).

phuccuongngo99 commented 5 years ago

Thank you. Would it be better if we have a script to print out generated frames? And a script to do classification? Anyone who is interested can see the actual result quite easily. I'm sorry, but i'm not familiar with matlab, so it do take a while to get things configured

0xekez commented 4 years ago

@mahmoods01 really appreciate you open sourcing this as well.

I have a similar question. Could you elaborate more on the "noise" that we ought to provide to the generator? At the moment I'm doing the following, based on the code in agn.m and having run demo.m:

% Load in the results matrix from the demo training.
load('results/demo-physical-dodege-openface143.mat', 'result');
gen = result.gen;

% Set options.
% These are the same as the ones in agn.m
latent_dim = 25;
sample_latent = @(n,d)(single(2*(rand(n,d)-0.5)));
batch_size = 25;
inv_transform = @(im)((permute(im, [3 4 2 1])+1)*127.5);

% Create the "noise"(?)
z = sample_latent(batch_size, latent_dim);

% Dislpay the first pair of eyeglasses.
res = vl_simplenn(gen, z);
A = uint8(inv_transform(res(end).x));
imshow(A(:,:,:,1));

I'm getting results that look like this:

image

Is this the correct way to generate the adversarial eyeglasses?

I'm also interested in rather or not there is a way to increase the resolution of the output glasses? These seem to be fairly low resolution for printing.

mahmoods01 commented 4 years ago

Hi, Zeke. This is indeed the right way to do it. Nice job! :-)

As for the image's size, we've been using simple resizing before printing (specifically, A = imresize( A, [124 364] ) makes an image that fits the average-ish face when printed on letter-sized paper). I imagine that you might get better results by using a super-resolution algorithm or a similar approach, but we haven't tried that.

0xekez commented 4 years ago

Great! Thanks Mahmood.

If you'd like, I'd be happy to write up something to add to the README about getting this working with a custom face and printing. I can open a pull request if that would be helpful :)