ComfyUI Instaswap Node
Installation | Usage | Troubleshooting | Disclaimer
A) Download this repository as a zip file and extract files in to comfyui\custom_nodes\ComfyUI-InstaSwap
folder.
B) Go to comfyui\custom_nodes\
folder open a terminal window here and run git clone https://github.com/abdozmantar/ComfyUI-InstaSwap
command.
Go to comfyui\custom_nodes\ComfyUI-InstaSwap
folder and open a terminal window and run python install.py
command. If you using windows you can double click install.bat
alternatively.
Wait patiently installation to finish.
If you are using Windows operating system you have to install C++ build tools for build InsightFace library on your computer. To do this:
Workloads -> Desktop & Mobile
menu select Desktop Development with C++
In order to use face restorer feature you have to download and place face restorer models:
comfyui\custom_nodes\ComfyUI-InstaSwap\models\facerestore_models
directory :
https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/codeformer.pth
https://github.com/TencentARC/GFPGAN/releases/download/v1.3.4/GFPGANv1.4.pthRun the ComfyUI.
Double click anywhere in ComfyUI and search InstaSwap node by typing it or right click anywhere and select Add Node > InstaSwap > InstaSwap Fast Face Swap
node to using it.
InstaFaceSwap node is very easy to use. In order to get a result, you have to connect a couple of mandatory slots.
<img src="https://github.com/abdozmantar/ComfyUI-InstaSwap/blob/main/help/Usage.jpg?raw=true" alt="webui-demo" width="100%"/>(1) input_image
- is your source image/video file that be processed.
<img src="https://github.com/abdozmantar/ComfyUI-InstaSwap/blob/main/help/NodeTypes.jpg?raw=true" alt="webui-demo" width="100%"/>
Image Files :
For processing
single image files you can use Comfy's default Load Image Node
Video Files :
For processing
video files you have to use third-party video helper library. Most known video library for Comfy is VHS Video Helper Suite You have to download and install it. If you use Manager plugin you can install it easly from there :
(2) source_image
- Your input images or videos will swap faces with this source image. You can use a single image file with Comfy's default Load Image Node
<img src="https://github.com/abdozmantar/ComfyUI-InstaSwap/blob/main/help/SourceImage.jpg?raw=true" alt="webui-demo" width="100%"/>
face_model
(Optional) This is an optional node, you can use your previously created face models with saved using the Save Face Model
nodeIMAGE
- this is processed face swap image/video file
<img src="https://github.com/abdozmantar/ComfyUI-InstaSwap/blob/main/help/Output.jpg?raw=true" alt="webui-demo" width="100%"/>
preview
processed image files you can use Comfy's default Preview Image Node
save
processed image files on the disk you can use Comfy's default Save Image Node
preview
processed video file as an image sequence, you can use Comfy's default Preview Image Node
preview
processed video file as a video clip, you can use VHS Video Helper Suite's Video Combine Node
save
processed video file as an image sequence, you can use Comfy's default Save Image Node
save
processed video file as a video clip, you can use VHS Video Helper Suite's Video Combine Node
FACE_MODEL
(Optional) - This output delivers the model of the source face, which is constructed throughout the face swapping procedure. You can use it later as an input face_model
For saving model to disk for later use you can connect and use Save Face Model node
After the face swapping process, the resulting image can sometimes be of low resolution. To prevent this and achieve ultra-high quality results, we can utilize Face Restoration models. We provided detailed information about downloading and correctly placing thesemodels during the Installation phase. If everything is in place, all you need to do is select your desired restorer from the InstaSwap main nodes *(4)
You have the ability to designate a specific gender for detection in images. InstaSwap will only execute a face swap if the detected face fulfills this specified condition
InstaSwap identifies faces within images sequentially, starting from left to right and then from top to bottom. To target specific faces, you have the option to assign indexes to both source and input images. The indexing begins with 0 for the first face detected. You are free to arrange the indexes in your preferred sequence. For example, using 0,1,2 for the Source and 1,0,2 for the Input indicates that the face at index 1 in the Input image (the second face) will swap with the face at index 0 in the Source image (the first face), and so on.
You have the option to save face models as safetensors
files, which are stored in the ComfyUI\models\reactor\faces
directory. These files can be loaded into InstaSwap for various scenarios while maintaining extremely compact models of the faces you work with.
To have newly created models show up in the Load Face Model
Node's list, simply refresh your ComfyUI web application page. It's advisable to use ComfyUI Manager to avoid losing your workflow upon refreshing, especially if you haven't saved your work prior to the refresh.
This likely due to an issue with the inswapper_128.onnx
model file. To resolve this, consider downloading the file manually from the provided this link Once downloaded, replace the existing file in the ComfyUI\models\insightface
directory with the newly downloaded one.
That indicates that the input parameters have been altered in the most recent update. To rectify this, you should remove the existing InstaSwap Node from your workflow and then add it back again.
python_embeded\python.exe -m pip install future-0.18.3-py3-none-any.whl
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/abdozmantar/ComfyUI-InstaSwap
Then retrieve the rest (if you need):
git fetch --unshallow
This software is designed as a constructive tool in the burgeoning field of AI-generated media, aiding artists in tasks like animating custom characters or using them as models for apparel design, among others.
The creators of this software acknowledge the potential for unethical use and are dedicated to implementing measures to prevent such misuse. We are committed to developing this project in a positive direction, ensuring compliance with legal and ethical standards.
Users of this software are expected to employ it responsibly and in accordance with local laws. When using a real person's face, it is advisable to obtain their consent and to clearly label the content as a deepfake when publishing it online. The developers and contributors of this software bear no responsibility for the actions of its users.
By using this extension, you agree not to create content that:
This software employs the pre-trained models 'buffalo_l' and 'inswapper_128.onnx' from InsightFace, subject to the following terms:
Users must strictly comply with these usage conditions. The developers and maintainers of this software are not liable for any misuse of InsightFace’s pre-trained models.
Please be aware that commercial use of this software requires you to train your own models or find commercially permissible models.
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