Giter VIP home page Giter VIP logo

mtcnnattack's Introduction

Real-world attack on MTCNN face detection system

By Edgar Kaziakhmedov, Klim Kireev, Grigorii Melnikov, Mikhail Pautov and Aleksandr Petiushko

This is the code for the research article. The video is available here.

Abstract

Recent studies proved that deep learning approaches achieve remarkable results on face detection task. On the other hand, the advances gave rise to a new problem associated with the security of the deep convolutional neural network models unveiling potential risks of DCNNs based applications. Even minor input changes in the digital domain can result in the network being fooled. It was shown then that some deep learning-based face detectors are prone to adversarial attacks not only in a digital domain but also in the real world. In the paper, we investigate the security of the well-known cascade CNN face detection system - MTCNN and introduce an easily reproducible and a robust way to attack it. We propose different face attributes printed on an ordinary white and black printer and attached either to the medical face mask or to the face directly. Our approach is capable of breaking the MTCNN detector in a real-world scenario.

The repo

The repository is organized as follows:

  • input_img stores all images to be used for training, should be colored with patch markers. A row in the grid must be same-colored. The color difference between the neighbouring marker rows must not be greater than 1;
  • mtcnn provides with public FaceNet implementation of MTCNN;
  • utils contains multi-patch manager;
  • weights weights for MTCNN sub-networks taken from the public FaceNet implementation;
  • output_img all generated patches will be stored here (you also can try to convert it to B/W before printing).

The attack is implemented in adversarial_gen.py source file, in order to train the patches follow the guideline:

  1. Set images (at least 5-6);
  2. Specify patches parameters;
  3. Specify losses.

The rest of the code is well-documented.

NOTE: paste yout own TensofFlow implementation of resize_area_batch function (INTER_AREA resize algorithm) OR use this one

Citation

@article{kaziakhmedov2019real,
  title={Real-world attack on MTCNN face detection system},
  author={Kaziakhmedov, Edgar and Kireev, Klim and Melnikov, Grigorii and Pautov, Mikhail and Petiushko, Aleksandr},
  journal={arXiv preprint arXiv:1910.06261},
  year={2019}
}

License

This project is licensed under the MIT License - see the LICENSE file for details.

mtcnnattack's People

Contributors

edosedgar 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

Watchers

 avatar  avatar  avatar  avatar  avatar

mtcnnattack's Issues

AttributeError: module 'tensorflow' has no attribute 'contrib'

Hello, I'm having the following error in your code:
"AttributeError: module 'tensorflow' has no attribute 'contrib'"
Yes, I know this is because of the TensorFlow older version.
But can you please suggest the following code modification for the TensorFlow 2.3 or latest version?

patch_transformed = tf.contrib.image.transform(patch_batched, Mb,
interpolation="NEAREST",
name="perspective")

N.B.: I know that "tf.contrib" has moved out of TF starting TF 2.0 alpha.
Thanks in advance.

How to realize the Projective transform?

Dear sir, would you mind share the code realizing the projective transform? I have not found the codes and the input images of adversarial_gen.py are the images with patches which has been projected to the face. Thank you sir.

【Novice programmer】version of tensorflow and python

Hello!

I'm a third year college student, and I'm learning about the project of adversarial attack. This is the first project I studied.

Due to the version problem of tensorflow and python. I have been debugging problems with the version of the software for a long time.

So would you like to tell me the version of tensorflow and python in this project that you use?

What is the reason for the checkerboard?

Hello
First, thank you for that wonderful contribution.

  1. What is this checkerboard for?
    Why did you use it instead of just marking the 8 points straight on the face? (with no checkerboard at all).
  2. Does your code generate a mask on the checkerboard's place, or uses it as a physical mask? (in order to apply the patch addition on the image).
    Thank you!

Attack failed

@edosedgar I tried training with 6 images and for 2000, 4000 epochs, but the patch trained seems of no use in detection using MTCNN. Even with trained patches, the detector can detect faces.
left_cheek
right_cheek

Set mask on my photo

@edosedgar

Hello.
I've changed the input photo with my own photo with two checkerboard squares on my face.

The grid_size with your image is (3,3) but with my image its (1,9).

so, I am getting this error

Traceback (most recent call last):
File "adversarial_gen.py", line 266, in
adv_mask.build(sess)
File "adversarial_gen.py", line 57, in build
self.pm.compile()
File "/ssd_scratch/cvit/surabhi/mtcnnattack/utils/patch_mng.py", line 188, in compile
self.patches[patch_key].init_transforms(self.images)
File "/ssd_scratch/cvit/surabhi/mtcnnattack/utils/patch_mng.py", line 148, in init_transforms
xx_dst, yy_dst = image.get_grid(self.init_clr, self.grad_clr, self.grid_size)
File "/ssd_scratch/cvit/surabhi/mtcnnattack/utils/patch_mng.py", line 62, in get_grid
xx_dst, yy_dst = self.add_new_line(xx_dst, yy_dst, dots_mask, i)
File "/ssd_scratch/cvit/surabhi/mtcnnattack/utils/patch_mng.py", line 52, in add_new_line
xx[i,:], yy[i,:] = points[:,1], points[:,0]
ValueError: could not broadcast input array from shape (20) into shape (9)

How to set the mask array

Hello.
I've changed the input photo with my own photo with two checkerboard squares on my face.
Then when I run adversarial_pen.py,there is a error:
`
File ".\mtcnnattack-master\utils\patch_mng.py", line 124, in init_src_parts
x = np.linspace(0, self.mask_np.shape[1], self.grid_size[1]).astype(np.int32)

TypeError: 'NoneType' object is not subscriptable`

If the reason is that I didn't set masks = {
'left_cheek: [np zeros ((150, 180, 1)), (0, 255, 0), (0, 1, 0)].
'right_cheek: [np zeros ((150, 180, 1)), (255, 0, 0), (1, 0, 0)].
}

And How can I set the masks?
Thanks a lot!

Understanding the pipeline

@edosedgar It would be really helpful if you can explain the steps of the pipeline in short. After applying checkerboard on the face, how projective transform is done ? I didn't get the concept of patch. Is patch the checkerboard or something else ?

built own mask

Hi Dear,
thank you for sharing your work,
I tested ur code and is working fine, however I could not figure out how to set my own mask on my photo.
I would be grateful if you explain the steps.
Regards

How to test the attacked face

Hello
First of all, thank you for your great contribution.

I am curious how you will verify the effect of the "attacked1.png" you generate.
I have tried detect_face(attacked_face) but there are no output.

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.