> For the complete documentation index, see [llms.txt](https://facegsm.gitbook.io/facegsm-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://facegsm.gitbook.io/facegsm-documentation/facegsm.md).

# FaceGSM

**FaceGSM** designed for performing **targeted adversarial attacks** using the **FGSM (Fast Gradient Sign Method)** in **Facial Recognition Embedding Model**. FaceGSM revolutionizes security testing with a suite of innovative features, including:

* **Static** - Takes **static images** as input for FaceGSM.
* **Capture** - Takes image **captured** by camera as input for FaceGSM
* **Live** - Takes **real-time** live video feed frames as input for FaceGSM.

|                                                                <p>Attacker's Face<br>(Clario)</p>                                                                |                                                               <p>Target's Face<br>(Clints)</p>                                                               |                                                                    <p>Output :<br>Generated Adversarial Image</p>                                                                    |                                                          <p>Attack Result :<br>Attacker's Face Predicted as Victim</p>                                                         |
| :--------------------------------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
| ![Original](https://binusianorg-my.sharepoint.com/personal/clintswood_binus_ac_id/Documents/SkripsiFileShare/Assets/original_cropped.png?csf=1\&web=1\&e=sKzFrh) | ![Target](https://binusianorg-my.sharepoint.com/personal/clintswood_binus_ac_id/Documents/SkripsiFileShare/Assets/target_cropped.png?csf=1\&web=1\&e=yOCv5y) | ![Generated Adversarial Image](https://binusianorg-my.sharepoint.com/personal/clintswood_binus_ac_id/Documents/SkripsiFileShare/Assets/adversarial_image.png?csf=1\&web=1\&e=exOqm9) | ![After Attack](https://binusianorg-my.sharepoint.com/personal/clintswood_binus_ac_id/Documents/SkripsiFileShare/Assets/adv_img_prediction_cropped.png?csf=1\&web=1\&e=2US3mR) |

## \[🔑] Key Features

✅ Fully compatible with **multiple facial recognition embedding model** including [FaceNet](https://github.com/davidsandberg/facenet), [ArcFace](https://insightface.ai/arcface), [GhostFaceNet](https://github.com/HamadYA/GhostFaceNets), [DeepID](https://github.com/Ruoyiran/DeepID), and [VGGFace2](https://github.com/bariarviv/VGGFace2)\
✅ Supports **multiple input media**, including static image, captured image and live video feed\
✅ Saved generated adversarial image as **checkpoints** to increase efficiency for future attacks\
✅ Works with your own **Custom Face Datasets**\
✅ Provide **easy** installation and **intuitive** UI/UX<br>

## \[⚙️] Installation

### Clone the Repository

```bash
# Clone the FaceGSM repository
$ git clone https://github.com/facegsmproject/FaceGSM
```

### Conda Environment

Install Conda from [here](https://docs.anaconda.com/miniconda/miniconda-install/). After installing Conda, Run the following commands :

```bash
# Create the environment for FaceGSM using the provided facegsm.yml file
$ conda env create --name facegsm --file facegsm.yml

# Activate the FaceGSM environment
$ conda activate facegsm
```

For more detail about the installation, please refer to our [Installation Guide](https://facegsm.gitbook.io/facegsm-documentation/facegsm/installation)

## \[⌛] Quick Start

To test if FaceGSM is working properly you can use FaceGSM's default datasets and run the following command:

```bash
$ python3 facegsm.py static --original ./datasets/04.jpg --target ./datasets/74.jpg
```

### Help

```
$ python3 facegsm.py --help

Usage: python3 facegsm.py [ static | capture | live | database ] --help
Options:
  static: Static input for FGSM attack in FaceGSM.
  capture: Capture original and target photos in FaceGSM.
  live: Live camera feature in FaceGSM includes real-time face recognition and attack capabilities.
  database: Create a database based on datasets for FaceGSM.
  --help: Show help for available options.
```

### Custom Face Datasets

Generate your own custom face datasets by running the following command:

```bash
$ python3 facegsm.py database --dataset ./your_custom_dataset_folder
```

Run FaceGSM with your custom face datasets:

```bash
$ python3 facegsm.py static --original ./your_custom_dataset_folder/a.jpg --target ./your_custom_dataset_folder/b.jpg
```

## Credits

FaceGSM is developed by :

* [Excy](https://github.com/Excillius)
* [Fejka](https://github.com/clariojohan)
* [Maskirovka](https://github.com/delbertgiovanni)
