Skip to content

ElaineXHZhong/Face-Adversary-Attack-Defense-System

Repository files navigation

Face Adversary Attack Defense System


Inspiration

The code is heavily inspired by the AmI implementation and cleverhans implementation.

System Architecture

  • Creating Secure REST API in Node.js (run a very simple HTTP server) to provide online services to have public-facing APIs.
  • Using child_process module of Node.js to spawn subprocesses of command by batch (.bat).
  • Switching conda virtual environment and programs by batch.
  • Every GET request to the Node.js server will get corresponding result by a HTML page.

API Overview

API No. API Method Functionality
1 /facenet?{attack}&{victim} GET implement face verification between attacker's face and victim's face
2 /adv GET implement fgsm attack between attacker's face and victim's face and then implement face verification
3 /detect GET implement adversary detection between attacker's face and victim's face and give result

There are four sub-folders under /demo which are: photo, origin, adv, detect.

folder Content Changed by API
photo original face images of attacker and victim NaN
origin facenet verification result plot /facenet?{attack}&{victim}
adv attacker's face with adversarial noise and facenet verification result plot /adv
detect adversary detection result plot /detect

Prerequisite

  • Please download VGG-Face caffe model and unzip the model under model/ folder.

  • Please download facenet pre-trained model 20180402-114759 and unzip the model under model/ folder.

Compile Caffe

As we use VGG-Face caffe model to detect adversary, so we need to compile caffe before detecting adversary. Please click here to compile.

Environment Purpose
Visual Studio 2015 + Anaconda env(python 3.5) + CUDA 8.0 + cuDNN 5 Compile caffe for detecting adversary
Visual Studio 2015 + Anaconda env(python 3.6) + tensorflow-gpu 1.7.0 + CUDA 9.0 + cuDNN 7.0.5 For runing face verfication (using gpu) and fgsm attack
Visual Studio 2015 + Anaconda env(python 3.5) + tensorflow-gpu 1.7.0 + CUDA 9.0 + cuDNN 7.0.5 For runing detection part (using gpu)
Visual Studio 2015 + Anaconda env(python 3.5) + tensorflow 1.7.0 + CUDA 9.0 + cuDNN 7.0.5 For runing detection part (using cpu)

Configure Project Environment

Add system path

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\libnvvp
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\lib\x64
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\include
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\extras\CUPTI\lib64
C:\Program Files\NVIDIA Corporation\NVSMI
C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR
C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common
$nvcc -V            # to see if GPU is configured successfully
$vidia-smi.exe -l 1 # update GPU information every second

Create conda environment

for facenet verification & fgsm attack

$conda create -n attack python=3.6
$conda activate attack
$pip install -r requirements.txt
$pip install cleverhans==3.0.1 tensorflow-gpu==1.7.0 scikit-learn opencv-python numpy==1.16.2 scipy==1.2.1 matplotlib==3.1.1 Pillow pytest-shutil
$python origin\origin.py Elon_Musk Jeff_Bezos
$python adv/fgsm.py

for detecting adversary

$conda create -n detect python=3.5
$conda activate detect
$pip install scikit-image scipy==1.2.1 opencv-python scikit-learn matplotlib Pillow tensorflow-gpu==1.7.0 protobuf==3.4.0
$conda install protobuf
# copy caffe\python\caffe to conda_virtual_env\Lib\site-packages
$python detect/detect.py

Package environment

$pip freeze > requirements.txt
$conda env export > environment.yaml
# $conda activate xx && $pip install -r requirements.txt
# $conda env create -f environment.yaml

Run Project

Firstly, run Node.js server by the following command to start the http server:

$npm install
$node server.js

Secondly, open web browser to send your GET requests as follows:

http://127.0.0.1:3000/facenet?Elon_Musk&Jeff_Bezos
http://127.0.0.1:3000/adv
http://127.0.0.1:3000/detect

Maintainers

@ElaineZhong

Contribute

Contributions are always welcome! Feel free to dive in!

Please read the contribution guideline first, then open an issue open an issue or submit PRs.

This repository follows the Contributor Covenant Code of Conduct.

Contributors

This project exists thanks to all the people who contribute.

License

MIT © Elaine Zhong

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published