The Fast and Simple 'roop-like' Face Swap Extension Node for ComfyUI, based on ReActor (ex Roop-GE) SD-WebUI Face Swap Extension
English | Π ΡΡΡΠΊΠΈΠΉ
<div align="center">This Node goes without NSFW filter (uncensored, use it on your own responsibility)
What's new | Installation | Usage | Troubleshooting | Updating | Disclaimer | Credits | Note!
face_size
parameter of the restoration model) BEFORE pasting it to the target image (via inswapper algorithms), more information is here (PR#321)Basic workflow πΎ
If you don't have the "face_yolov8m.pt" Ultralytics model - you can download it from the Assets and put it into the "ComfyUI\models\ultralytics\bbox" directory <br> As well as "sam_vit_b_01ec64.pth" model - download (if you don't have it) and put it into the "ComfyUI\models\sams" directory;
Use this Node to gain the best results of the face swapping process:
<img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/0.5.0-whatsnew-02.jpg?raw=true" alt="0.5.0-whatsnew-02" width="100%"/>You can download models here: https://huggingface.co/datasets/Gourieff/ReActor/tree/main/models/facerestore_models
<br>Put them into the ComfyUI\models\facerestore_models
folder
Experiment and create new faces or blend faces of one person to gain better accuracy and likeness!
Just add the ImpactPack's "Make Image Batch" Node as the input to the ReActor's one and load images you want to blend into one model:
<img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/0.4.2-whatsnew-01.jpg?raw=true" alt="0.4.2-whatsnew-01" width="100%"/>Result example (the new face was created from 4 faces of different actresses):
<img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/0.4.2-whatsnew-02.jpg?raw=true" alt="0.4.2-whatsnew-02" width="75%"/>Basic workflow πΎ
CUDA 12 Support - don't forget to run (Windows) install.bat
or (Linux/MacOS) install.py
for ComfyUI's Python enclosure or try to install ORT-GPU for CU12 manually (https://onnxruntime.ai/docs/install/#install-onnx-runtime-gpu-cuda-12x)
Issue https://github.com/Gourieff/comfyui-reactor-node/issues/173 fix
Separate Node for the Face Restoration postprocessing (FR https://github.com/Gourieff/comfyui-reactor-node/issues/191), can be found inside ReActor's menu (RestoreFace Node)
(Windows) Installation can be done for Python from the System's PATH
Different fixes and improvements
Face Restore Visibility and CodeFormer Weight (Fidelity) options are now available! Don't forget to reload the Node in your existing workflow
ComfyUI\models\reactor\faces
) and load them into ReActor implementing different scenarios and keeping super lightweight face models of the faces you use:image
has a priority.Thanks to everyone who finds bugs, suggests new features and supports this project!
</details>Close (stop) your SD-WebUI/Comfy Server if it's running
(For Windows Users):
Go to the extensions\sd-webui-comfyui\ComfyUI\custom_nodes
Open Console or Terminal and run git clone https://github.com/Gourieff/comfyui-reactor-node
Go to the SD WebUI root folder, open Console or Terminal and run (Windows users).\venv\Scripts\activate
or (Linux/MacOS)venv/bin/activate
python -m pip install -U pip
cd extensions\sd-webui-comfyui\ComfyUI\custom_nodes\comfyui-reactor-node
python install.py
Please, wait until the installation process will be finished
(From the version 0.3.0) Download additional facerestorers models from the link below and put them into the extensions\sd-webui-comfyui\ComfyUI\models\facerestore_models
directory:<br>
https://huggingface.co/datasets/Gourieff/ReActor/tree/main/models/facerestore_models
Run SD WebUI and check console for the message that ReActor Node is running:
<img src="https://github.com/Gourieff/Assets/blob/main/comfyui-reactor-node/uploads/console_status_running.jpg?raw=true" alt="console_status_running" width="759"/>Go to the ComfyUI tab and find there ReActor Node inside the menu ReActor
or by using a search:
ComfyUI\custom_nodes
, open Console and run git clone https://github.com/Gourieff/comfyui-reactor-node
ComfyUI\custom_nodes\comfyui-reactor-node
and run install.bat
As well as one or both of "Sams" models from here - download (if you don't have them) and put into the "ComfyUI\models\sams" directory
5. Run ComfyUI and find there ReActor Nodes inside the menu ReActor
or by using a search
You can find ReActor Nodes inside the menu ReActor
or by using a search (just type "ReActor" in the search field)
List of Nodes:
Connect all required slots and run the query.
input_image
- is an image to be processed (target image, analog of "target image" in the SD WebUI extension);
source_image
- is an image with a face or faces to swap in the input_image
(source image, analog of "source image" in the SD WebUI extension);
face_model
- is the input for the "Load Face Model" Node or another ReActor node to provide a face model file (face embedding) you created earlier via the "Save Face Model" Node;
IMAGE
- is an output with the resulted image;
FACE_MODEL
- is an output providing a source face's model being built during the swapping process;
Since version 0.3.0 ReActor Node has a buil-in face restoration.<br>Just download the models you want (see Installation instruction) and select one of them to restore the resulting face(s) during the faceswap. It will enhance face details and make your result more accurate.
By default ReActor detects faces in images from "large" to "small".<br>You can change this option by adding ReActorFaceSwapOpt node with ReActorOptions.
And if you need to specify faces, you can set indexes for source and input images.
Index of the first detected face is 0.
You can set indexes in the order you need.<br> E.g.: 0,1,2 (for Source); 1,0,2 (for Input).<br>This means: the second Input face (index = 1) will be swapped by the first Source face (index = 0) and so on.
You can specify the gender to detect in images.<br> ReActor will swap a face only if it meets the given condition.
Since version 0.4.0 you can save face models as "safetensors" files (stored in ComfyUI\models\reactor\faces
) and load them into ReActor implementing different scenarios and keeping super lightweight face models of the faces you use.
To make new models appear in the list of the "Load Face Model" Node - just refresh the page of your ComfyUI web application.<br> (I recommend you to use ComfyUI Manager - otherwise you workflow can be lost after you refresh the page if you didn't save it before that).
python_embeded\python.exe -V
.\venv\Scripts\activate
python -m pip install -U pip
python_embeded\python.exe -m pip install -U pip
pip install insightface-0.7.3-cp310-cp310-win_amd64.whl
(for 3.10) or pip install insightface-0.7.3-cp311-cp311-win_amd64.whl
(for 3.11) or pip install insightface-0.7.3-cp312-cp312-win_amd64.whl
(for 3.12)python_embeded\python.exe -m pip install insightface-0.7.3-cp310-cp310-win_amd64.whl
(for 3.10) or python_embeded\python.exe -m pip install insightface-0.7.3-cp311-cp311-win_amd64.whl
(for 3.11) or python_embeded\python.exe -m pip install insightface-0.7.3-cp312-cp312-win_amd64.whl
(for 3.12)This error may occur if there's smth wrong with the model file inswapper_128.onnx
Try to download it manually from here
and put it to the ComfyUI\models\insightface
replacing existing one
This means that input points have been changed with the latest update<br> Remove the current ReActor Node from your workflow and add it again
python_embeded\python.exe -m pip uninstall -y opencv-python opencv-contrib-python opencv-python-headless
python_embeded\python.exe -m pip install opencv-python==4.7.0.72
Download https://github.com/Gourieff/Assets/raw/main/comfyui-reactor-node/future-0.18.3-py3-none-any.whl<br>
Put it to ComfyUI root And run:
python_embeded\python.exe -m pip install future-0.18.3-py3-none-any.whl
Then:
python_embeded\python.exe -m pip install basicsr
git clone
the repository"Try to clone with --depth=1
(last commit only):
git clone --depth=1 https://github.com/Gourieff/comfyui-reactor-node
Then retrieve the rest (if you need):
git fetch --unshallow
Just put .bat or .sh script from this Repo to the ComfyUI\custom_nodes
directory and run it when you need to check for updates
This software is meant to be a productive contribution to the rapidly growing AI-generated media industry. It will help artists with tasks such as animating a custom character or using the character as a model for clothing etc.
The developers of this software are aware of its possible unethical applications and are committed to take preventative measures against them. We will continue to develop this project in the positive direction while adhering to law and ethics.
Users of this software are expected to use this software responsibly while abiding the local law. If face of a real person is being used, users are suggested to get consent from the concerned person and clearly mention that it is a deepfake when posting content online. Developers and Contributors of this software are not responsible for actions of end-users.
By using this extension you are agree not to create any content that:
This software utilizes the pre-trained models buffalo_l
and inswapper_128.onnx
, which are provided by InsightFace. These models are included under the following conditions:
From insighface license: The InsightFaceβs pre-trained models are available for non-commercial research purposes only. This includes both auto-downloading models and manually downloaded models.
Users of this software must strictly adhere to these conditions of use. The developers and maintainers of this software are not responsible for any misuse of InsightFaceβs pre-trained models.
Please note that if you intend to use this software for any commercial purposes, you will need to train your own models or find models that can be used commercially.
inswapper_128.onnx
MD5:a3a155b90354160350efd66fed6b3d80
SHA256:e4a3f08c753cb72d04e10aa0f7dbe3deebbf39567d4ead6dce08e98aa49e16af
1k3d68.onnx
MD5:6fb94fcdb0055e3638bf9158e6a108f4
SHA256:df5c06b8a0c12e422b2ed8947b8869faa4105387f199c477af038aa01f9a45cc
2d106det.onnx
MD5:a3613ef9eb3662b4ef88eb90db1fcf26
SHA256:f001b856447c413801ef5c42091ed0cd516fcd21f2d6b79635b1e733a7109dbf
det_10g.onnx
MD5:4c10eef5c9e168357a16fdd580fa8371
SHA256:5838f7fe053675b1c7a08b633df49e7af5495cee0493c7dcf6697200b85b5b91
genderage.onnx
MD5:81c77ba87ab38163b0dec6b26f8e2af2
SHA256:4fde69b1c810857b88c64a335084f1c3fe8f01246c9a191b48c7bb756d6652fb
w600k_r50.onnx
MD5:80248d427976241cbd1343889ed132b3
SHA256:4c06341c33c2ca1f86781dab0e829f88ad5b64be9fba56e56bc9ebdefc619e43
Please check hashsums if you download these models from unverified (or untrusted) sources
<a name="credits">|file|source|license| |----|------|-------| |buffalo_l.zip | DeepInsight | | | codeformer-v0.1.0.pth | sczhou | | | GFPGANv1.3.pth | TencentARC | | | GFPGANv1.4.pth | TencentARC | | | inswapper_128.onnx | DeepInsight | | | inswapper_128_fp16.onnx | Hillobar | |
BasicSR - @XPixelGroup <br> facexlib - @xinntao <br>
@s0md3v, @henryruhs - the original Roop App <br> @ssitu - the first version of ComfyUI_roop extension
</details> <a name="note">If you encounter any errors when you use ReActor Node - don't rush to open an issue, first try to remove current ReActor node in your workflow and add it again
ReActor Node gets updates from time to time, new functions appear and old node can work with errors or not work at all