Roop Deepfake is a tool that lets you swap faces in videos with just one image of the desired face. You don’t need to collect many images or train a model to do this. You need to run a Python script and select the face and the target video. Roop Deepfake will do the rest for you. It uses a library called insightface and some models to detect and replace faces. You can also use GPU acceleration to speed up the process. Roop Deepfake is an experimental project that aims to make deepfake technology more accessible and easy to use.
1- Basic Installation
- install
python
(ifneed, installpip
too) - install
git
- install
ffmpeg
- If you are using Windows, you have to install Visual Studio 2022 (with desktop development C++).
git clone https://github.com/s0md3v/roop
cd roop && pip install -r requirements.txt
- Download this file and keep it in roop directory. Mirror #1, Mirror #2, Mirror #3, Mirror #4. Rename the downloaded file to
inswapper_128.onnx
if it isn’t already named.
Done. You should be able to use this tool with the command: python run.py
.
1- GPU Acceleration Installation
AMD
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/rocm5.4.2
pip uninstall onnxruntime
git clone https://github.com/microsoft/onnxruntime && cd onnxruntime
./build.sh --config Release --build_wheel --update --build --parallel --cmake_extra_defines CMAKE_PREFIX_PATH=/opt/rocm/lib/cmake ONNXRUNTIME_VERSION=$ONNXRUNTIME_VERSION onnxruntime_BUILD_UNIT_TESTS=off --use_rocm --rocm_home=/opt/rocm
pip install build/Linux/Release/dist/*.whl
NVIDIA
Linux
- install CUDA toolkit from here
- install CUDNN from here
pip uninstall onnxruntime onnxruntime-gpu
pip install torch torchvision torchaudio --force-reinstall --index-url https://download.pytorch.org/whl/cu118
pip install onnxruntime-gpu
Mac
brew install wget cmake protobuf git git-lfs
git clone https://github.com/cansik/onnxruntime-silicon && cd onnxruntime-silicon
./build-macos.sh
pip install dist/*whl
(Depending on the situation, you may have to adapt this step accordingly.)
Intel
pip uninstall onnxruntime
- install the intel-specific onnxruntime called OpenVINO
To start this window, run the command: python run.py
To swap faces on photos or videos, follow these steps:
- Select a face photo (the one you want to use as a replacement) and a target photo or video (the one you want to change the face on).
- Click on Start and wait for the AI to process your request.
- Find the output file in the folder you chose. The folder name will be the same as the target file name.
- Enjoy your face-swapped result!
Some of the additional command-line arguments that you can use are::
options:
-h, --help show this help message and exit
-f SOURCE_IMG, --face SOURCE_IMG
use this face
-t TARGET_PATH, --target TARGET_PATH
replace this face
-o OUTPUT_FILE, --output OUTPUT_FILE
save output to this file
--gpu use gpu
--keep-fps maintain original fps
--keep-frames keep frames directory
--max-memory MAX_MEMORY
maximum amount of RAM in GB to be used
--max-cores CORES_COUNT
number of cores to be use for CPU mode
To run the program without a graphical interface, you can use the -f or –face argument. This will enable the CLI mode.
how to unistall it?