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.
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
224
and512
- with the option of face superresolution (via GPen) at resolutions
256
and512
- with the option of face superresolution (via GPen) at resolutions
- lower quality face swap (via OpenCV)
- FOMM, First Order Motion Model for image animation
Installation
Install Pre-requisites
-
Linux
sudo apt install ffmpeg cmake
-
MacOS
brew install ffmpeg cmake
-
Windows
no pre-requisites to be installed, skip this step
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
cudatoolkit
fromconda
:conda install cudatoolkit=<cuda_version_no>
(replace<cuda_version_no>
with the version on your machine) - Install
torch
andtorchvision
dependencies:pip install torch==1.9.0+<cuda_tag> torchvision==0.10.0+<cuda_tag> -f https://download.pytorch.org/whl/torch_stable.html
, where<cuda_tag>
is the CUDA tag defined by Pytorch. For example,pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 -f https://download.pytorch.org/whl/torch_stable.html
for CUDA 11.1. See here for a list of all availabletorch
andtorchvision
versions.
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 CPU Support (slow, not recommended)
conda env create -f envs/environment-cpu.yaml
conda activate dot
Install dot
pip install -e .
Download Models
-
Download GitHub Release binaries from here or use the following
wget
commands:wget https://github.com/sensity-ai/dot/releases/download/1.0.0/dot_model_checkpoints.z01 \ && wget https://github.com/sensity-ai/dot/releases/download/1.0.0/dot_model_checkpoints.z02 \ && wget https://github.com/sensity-ai/dot/releases/download/1.0.0/dot_model_checkpoints.zip
-
Unzip the binaries and place them in the root directory of the repository:
zip -s 0 dot_model_checkpoints.zip --out saved_models.zip \ && unzip saved_models.zip
-
Clean up the downloaded binaries:
rm -rf *.z*
Usage
Running dot
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
Disclaimer: We use the
SimSwap
technique 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:
Virtual Camera Injection
Instructions vary depending on your operating system.
Windows
-
Install OBS Studio.
-
Install VirtualCam plugin.
Choose Install and register only 1 virtual camera
.
-
Run OBS Studio.
-
In the Sources section, press on Add button ("+" sign),
select Windows Capture and press OK. In the appeared window, choose "[python.exe]: fomm" in Window drop-down menu and press OK. Then select Edit -> Transform -> Fit to screen.
-
In OBS Studio, go to Tools -> VirtualCam. Check AutoStart,
set Buffered Frames to 0 and press Start.
-
Now
OBS-Camera
camera should be available in Zoom(or other videoconferencing software).
Ubuntu
sudo apt update
sudo apt install v4l-utils v4l2loopback-dkms v4l2loopback-utils
sudo modprobe v4l2loopback devices=1 card_label="OBS Cam" exclusive_caps=1
v4l2-ctl --list-devices
sudo add-apt-repository ppa:obsproject/obs-studio
sudo apt install obs-studio
Open OBS Studio
and check if tools --> v4l2sink
exists.
If it doesn't follow these instructions:
mkdir -p ~/.config/obs-studio/plugins/v4l2sink/bin/64bit/
ln -s /usr/lib/obs-plugins/v4l2sink.so ~/.config/obs-studio/plugins/v4l2sink/bin/64bit/
Use the virtual camera with OBS Studio
:
- Open
OBS Studio
- Go to
tools --> v4l2sink
- Select
/dev/video2
andYUV420
- Click on
start
- Join a meeting and select
OBS Cam
MacOS
- Download and install OBS Studio for MacOS from here
- Open OBS and follow the first-time setup (you might be required to enable certain permissions in System Preferences)
- Run dot with
--use_cam
flag to enable camera feed - Click the "+" button in the sources section → select "Windows Capture", create a new source and enter "OK" → select window with "python" included in the name and enter OK
- Click "Start Virtual Camera" button in the controls section
- Select "OBS Cam" as default camera in the video settings of the application target of the injection
Run dot with an Android emulator
If you are performing a test against a mobile app, virtual cameras are much harder to inject. An alternative is to use mobile emulators and still resort to virtual camera injection.
-
Run
dot
. Check running dot for more information. -
Run
OBS Studio
and set up the virtual camera. Check virtual-camera-injection for more information. -
Download and Install Genymotion.
-
Open Genymotion and set up the Android emulator.
-
Set up dot with the Android emulator:
- Open the Android emulator.
- Click on
camera
and selectOBS-Camera
as front and back cameras. A preview of the dot window should appear. In case there is no preview, restartOBS
and the emulator and try again. If that didn't work, use a different virtual camera software likee2eSoft VCam
orManyCam
. dot
deepfake output should be now the emulator's phone camera.
Speed
Tested on a AMD Ryzen 5 2600 Six-Core Processor with one NVIDIA GeForce RTX 2070
Simswap: FPS 13.0
Simswap + gpen 256: FPS 7.0
SimswapHQ: FPS 11.0
FOMM: FPS 31.0
License
This is not a commercial Sensity product, and it is distributed freely with no warranties
The software is distributed under BSD 3-Clause. dot utilizes several open source libraries. If you use dot, make sure you agree with their licenses too. In particular, this codebase is built on top of the following research projects:
- https://github.com/AliaksandrSiarohin/first-order-model
- https://github.com/alievk/avatarify-python
- https://github.com/neuralchen/SimSwap
- https://github.com/yangxy/GPEN
Contributing
If you have ideas for improving dot, feel free to open relevant Issues and PRs. Please read CONTRIBUTING.md before contributing to the repository.
Maintainers
Contributors
dot
on pre-recorded image and video files
Run
FAQ
dot
is very slow and I can't run it in real time
Make sure that you are running it on a GPU card by using the --use_gpu
flag. CPU is not recommended.
If you still find it too slow it may be because you running it on an old GPU model, with less than 8GB of RAM.
- Does
dot
only work with a webcam feed or also with a pre-recorded video?
You can use dot
on a pre-recorded video file by these scripts or try it directly on Colab.