Dot
The Deepfake Offensive Toolkit
Install / Use
/learn @sensity-ai/DotREADME
<a href="https://colab.research.google.com/github/sensity-ai/dot/blob/main/notebooks/colab_demo.ipynb"><img src="https://colab.research.google.com/assets/colab-badge.svg" height=20></a>
</div>dot (aka Deepfake Offensive Toolkit) makes real-time, controllable deepfakes ready for virtual cameras injection. dot is created for performing penetration testing against e.g. identity verification and video conferencing systems, for the use by security analysts, Red Team members, and biometrics researchers.
If you want to learn more about dot is used for penetration tests with deepfakes in the industry, read these articles by The Verge and Biometric Update.
dot is developed for research and demonstration purposes. As an end user, you have the responsibility to obey all applicable laws when using this program. Authors and contributing developers assume no liability and are not responsible for any misuse or damage caused by the use of this program.
<p align="center"> <img src="./assets/dot_intro.gif" width="500"/> </p>How it works
In a nutshell, dot works like this
flowchart LR;
A(your webcam feed) --> B(suite of realtime deepfakes);
B(suite of realtime deepfakes) --> C(virtual camera injection);
All deepfakes supported by dot do not require additional training. They can be used in real-time on the fly on a photo that becomes the target of face impersonation. Supported methods:
- face swap (via SimSwap), at resolutions
224and512- with the option of face superresolution (via GPen) at resolutions
256and512
- with the option of face superresolution (via GPen) at resolutions
- lower quality face swap (via OpenCV)
- FOMM, First Order Motion Model for image animation
Running dot
Graphical interface
GUI Installation
Download and run the dot executable for your OS:
-
Windows (Tested on Windows 10 and 11):
- Download
dot.zipfrom here, unzip it and then rundot.exe
- Download
-
Ubuntu:
- ToDo
-
Mac (Tested on Apple M2 Sonoma 14.0):
- Download
dot-m2.zipfrom here and unzip it - Open terminal and run
xattr -cr dot-executable.appto remove any extended attributes - In case of camera reading error:
- Right click and choose
Show Package Contents - Execute
dot-executablefromContents/MacOSfolder
- Right click and choose
- Download
GUI Usage
Usage example:
- Specify the source image in the field
source. - Specify the camera id number in the field
target. In most cases,0is the correct camera id. - Specify the config file in the field
config_file. Select a default configuration from the dropdown list or use a custom file. - (Optional) Check the field
use_gputo use the GPU. - Click on the
RUNbutton to start the deepfake.
For more information about each field, click on the menu Help/Usage.
Watch the following demo video for better understanding of the interface
<p align="center"> <img src="./assets/gui_dot_demo.gif" width="500" height="406"/> </p>Command Line
CLI Installation
Install Pre-requisites
-
Linux
sudo apt install ffmpeg cmake -
MacOS
brew install ffmpeg cmake -
Windows
- Download and install Visual Studio Community from here
- Install Desktop development with C++ from the Visual studio installer
Create Conda Environment
The instructions assumes that you have Miniconda installed on your machine. If you don't, you can refer to this link for installation instructions.
With GPU Support
conda env create -f envs/environment-gpu.yaml
conda activate dot
Install the torch and torchvision dependencies based on the CUDA version installed on your machine:
-
Install CUDA 11.8 from link
-
Install
cudatoolkitfromconda:conda install cudatoolkit=<cuda_version_no>(replace<cuda_version_no>with the version on your machine) -
Install
torchandtorchvisiondependencies:pip install torch==2.0.1+<cuda_tag> torchvision==0.15.2+<cuda_tag> torchaudio==2.0.2 --index-url https://download.pytorch.org/whl/cu118, where<cuda_tag>is the CUDA tag defined by Pytorch. For example,pip install torch==2.0.1+cu118 torchvision==0.15.2+cu118 torchaudio==2.0.2 --index-url https://download.pytorch.org/whl/cu118for CUDA 11.8.Note:
torch1.9.0+cu111can also be used.
To check that torch and torchvision are installed correctly, run the following command: python -c "import torch; print(torch.cuda.is_available())". If the output is True, the dependencies are installed with CUDA support.
With MPS Support(Apple Silicon)
conda env create -f envs/environment-apple-m2.yaml
conda activate dot
To check that torch and torchvision are installed correctly, run the following command: python -c "import torch; print(torch.backends.mps.is_available())". If the output is True, the dependencies are installed with Metal programming framework support.
With CPU Support (slow, not recommended)
conda env create -f envs/environment-cpu.yaml
conda activate dot
Install dot
pip install -e .
Download Models
- Download dot model checkpoints from here
- Unzip the downloaded file in the root of this project
CLI Usage
Run dot --help to get a full list of available options.
-
Simswap
dot -c ./configs/simswap.yaml --target 0 --source "./data" --use_gpu -
SimSwapHQ
dot -c ./configs/simswaphq.yaml --target 0 --source "./data" --use_gpu -
FOMM
dot -c ./configs/fomm.yaml --target 0 --source "./data" --use_gpu -
FaceSwap CV2
dot -c ./configs/faceswap_cv2.yaml --target 0 --source "./data" --use_gpu
Note: To enable face superresolution, use the flag --gpen_type gpen_256 or --gpen_type gpen_512. To use dot on CPU (not recommended), do not pass the --use_gpu flag.
Controlling dot with CLI
Disclaimer: We use the
SimSwaptechnique for the following demonstration
Running dot via any of the above methods generates real-time Deepfake on the input video feed using source images from the data/ folder.
When running dot a list of available control options appear on the terminal window as shown above. You can toggle through and select different source images by pressing the associated control key.
Watch the following demo video for better understanding of the control options:
<p align="center"> <img src="./assets/dot_demo.gif" width="480"/> </p>Docker
Setting up docker
-
Build the container
docker-compose up --build -d -
Access the container
docker-compose exec dot "/bin/bash"
Connect docker to the webcam
Ubuntu
-
Build the container
docker build -t dot -f Dockerfile . -
Run the container
xhost + docker run -ti --gpus all \ -e NVIDIA_DRIVER_CAPABILITIES=compute,utility \ -e NVIDIA_VISIBLE_DEVICES=all \ -e PYTHONUNBUFFERED=1 \ -e DISPLAY \ -v .:/dot \ -v /tmp/.X11-unix:/tmp/.X11-unix:rw \ --runtime nvidia \ --entrypoint /bin/bash \ -p 8080:8080 \ --device=/dev/video0:/dev/video0 \ dot
Windows
-
Follow the instructions here under Windows to set up the webcam with docker.
-
Build the container
docker build -t dot -f Dockerfile . -
Run the container
docker run -ti --gpus all \ -e NVIDIA_DRIVER_CAPABILITIES=compute,utility \ -e NVIDIA_VISIBLE_DEVICES=all \ -e PYTHONUNBUFFERED=1 \ -e DISPLAY=192.168.99.1:0 \ -v .:/dot \ --runtime nvidia \ --entrypoint /bin/bash \ -p 8080:8080 \ --device=/dev/video0:/dev/video0 \ -v /tmp/.X11-unix:/tmp/.X11-unix \ dot
macOS
-
Follow the instructions here to set up the webcam with docker.
-
Build the container
docker build -t dot -f Dockerfile . -
Run the container
docker run -ti --gpus all \ -e NVIDIA_DRIVER_CAPABILITIES=compute,utility \ -e NVIDIA_VISIBLE_DEVICES=all \ -e PYTHONUNBUFFERED=1 \ -e DISPLAY=$IP:0 \ -v .:/dot \ -v /tmp/.X11-unix:/tmp/.X11-unix \ --runtime nvidia \ --entrypoint /bin/bash \
