abdozmantar / ComfyUI-InstaSwap

ComfyUI Instaswap Node
GNU General Public License v3.0
48 stars 3 forks source link
logo ![Version](https://img.shields.io/badge/node_version-0.1.4-green?style=for-the-badge&labelColor=darkgreen) [![Commit activity](https://img.shields.io/github/commit-activity/t/abdozmantar/ComfyUI-InstaSwap/main?cacheSeconds=0)](https://github.com/Gourieff/comfyui-reactor-node/commits/main) ![Last commit](https://img.shields.io/github/last-commit/abdozmantar/ComfyUI-InstaSwap/main?cacheSeconds=0) [![Opened issues](https://img.shields.io/github/issues/abdozmantar/ComfyUI-InstaSwap?color=red)](https://github.com/Gourieff/comfyui-reactor-node/issues?cacheSeconds=0) [![Closed issues](https://img.shields.io/github/issues-closed/abdozmantar/ComfyUI-InstaSwap?color=green&cacheSeconds=0)](https://github.com/Gourieff/comfyui-reactor-node/issues?q=is%3Aissue+is%3Aclosed) ![License](https://img.shields.io/github/license/abdozmantar/ComfyUI-InstaSwap) # InstaSwap Face Swap Node for ComfyUI

Fastest Face Swap Extension Node for ComfyUI, Single node and FastTrack: Lightning-Speed Facial Transformation for your projects.

--- [**Installation**](#installation) | [**Usage**](#usage) | [**Troubleshooting**](#troubleshooting) | [**Disclaimer**](#disclaimer) --- ## Demo
demo

Installation

  1. Clone this repository to your ComfyUI custom nodes folder. There is two way :
    • A) Download this repository as a zip file and extract files in to comfyui\custom_nodes\ComfyUI-InstaSwap folder.
  1. 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.

  2. Wait patiently installation to finish.

  3. If you are using Windows operating system you have to install C++ build tools for build InsightFace library on your computer. To do this:

    • Install Visual Studio 2022 Communty version (skip this if you installed already)
    • Install VS C++ Build Tools
    • Open Visual Studio under Workloads -> Desktop & Mobile menu select Desktop Development with C++
  4. In order to use face restorer feature you have to download and place face restorer models:

  5. Run the ComfyUI.

  6. 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.

webui-demo

Usage

InstaFaceSwap node is very easy to use. In order to get a result, you have to connect a couple of mandatory slots.

webui-demo

Inputs

Outputs

Restoration

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)

Gender Detection

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

Face Indexes

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.

Face Models

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.

Troubleshooting

I. If you encounter the error 'AttributeError: ‘NoneType’ object has no attribute ‘get’

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.

II. "instaswap.execute() got an unexpected keyword argument 'reference_image'"

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.

III. "ModuleNotFoundError: No module named 'basicsr'" or "subprocess-exited-with-error" during future-0.18.3 installation

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

Disclaimer

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.

Models Hashes

You can safely use models have these hashes:

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