This ComfyUI node library builds upon the work done to train the Arc2Face model by foivospar. It provides a set of nodes for ComfyUI that allow users to extract face embeddings, generate images based on these embeddings, and perform image-to-image transformations.
- Face embedding extraction from images
- Multiple methods for averaging face embeddings
- Image generation based on face embeddings
- Image-to-image transformation with face embeddings
- Image grid generation for easy comparison
-
Clone this repository into your ComfyUI
custom_nodes
directory:cd /path/to/ComfyUI/custom_nodes git clone https://github.com/caleboleary/ComfyUI-Arc2Face.git
-
Install the required dependencies:
pip install -r requirements.txt
or for portable:
python_embeded\python.exe -m pip install -r requirements.txt
-
Download the necessary model files (see the "Model Files" section below).
Trouble installing insightface? reactor has a nice troubleshooting step
To use this node library, you need to download the following files and place them in your ComfyUI models folder with the structure shown below:
-
From camenduru/Arc2Face on Hugging Face, download:
scrfd_10g_bnkps.onnx
arcface.onnx
-
From FoivosPar/Arc2Face on Hugging Face, download:
arc2face/config.json
arc2face/diffusion_pytorch_model.safetensors
encoder/config.json
encoder/pytorch_model.bin
Place these files in your ComfyUI models folder with the following structure:
ComfyUI/
└── models/
├── antelopev2/
│ ├── scrfd_10g_bnkps.onnx
│ └── arcface.onnx
└── arc2face_checkpoints/
├── config.json
├── diffusion_pytorch_model.safetensors
└── encoder/
├── config.json
└── pytorch_model.bin
Ensure that you maintain this exact directory structure for the node library to function correctly.
After installation and downloading the model files, you'll find the following nodes available in ComfyUI:
- Arc2Face Face Extractor
- Extracts all faces from a single input image (have tested as many as 64), averages them using the selected averaging scheme, and outputs the embedding the generators expect. Use the grid generator below for easy directory load.
- Arc2Face UNet Loader
- load the arc2face model itself
- Arc2Face Encoder Loader
- load the encoder model
- Arc2Face Generator
- take in embedding and output images
- Arc2Face Img2Img Generator
- take in embedding, init image, and denoise and perform img2img
- Arc2Face Image Grid Generator
- take in directory path, load all images, append them into 1 single large grid image to easily pass to face extractor
You can use these nodes to create workflows for face-based image generation and transformation in ComfyUI.
find the json workflows for these in the examples folder.
- The model works best near 512x512 - if you have to do smaller/bigger I recommend scaling near this size and then up/downscaling afterwards to your desired size.
- Averaging methods if passing multiple faces mess with how the facial embeds are combined. In my experience median is best for a few inputs, and ensemble can be good for many.
- n_outliers on the face extractor node removes the n faces farthest from the cluster. This can be useful if you know there are some background faces being caught that aren't your character, as their face should be quite different than most.
- I didn't create an inpainting node, but you can effectively inpaint the face automatically with some Face Analysis nodes, see Latent Vision's video
- It'd be nice to support the controlnet that is trained on this, but the required preprocessor looks difficult to install/work with - I may work on that eventually or test to see if easier preprocessors can be made to work with the controlnet. If anyone is so inclined feel free to open a PR.
- would like to make the loader nodes download the files if they don't exist
- could probably collapse the 2 generators into 1, where you pass empty and 100 denoise for non img2img
- I can add a positive prompt, but in my testing, any positive prompt at all ruined outputs, as this is heavily finetuned on face embeddings only
By using this node, you agree to:
- Legal & Ethical Use: Comply with all applicable laws and use this technology ethically.
- Consent: Obtain consent from individuals before using their likeness.
- No Harmful Content: Refrain from creating deepfakes, pornography, or content that harasses or defames others.
- Transparency: Disclose when content has been altered using this technology.
- Intellectual Property: Respect copyrights and other IP rights.
- No Impersonation: Don't use for fraudulent impersonation.
Note: This node is provided "as is" without warranties. The creator is not liable for misuse or any consequences arising from its use.
By using this node, you acknowledge and agree to these terms. Use responsibly.
Contributions are welcome! Please feel free to submit a Pull Request.