Welcome to comfyui_facetools! This extension is designed to enhance your AI art projects by providing advanced face extraction, alignment, and masking capabilities. Whether you're working on portraits, inpainting, or any other face-related tasks, comfyui_facetools offers a suite of tools to make your workflow more efficient and your results more precise.
Key Features:
- Rotation-Aware Face Extraction: Detects and extracts faces from images, even if they are rotated.
- Face Alignment: Aligns faces to a standard orientation for consistent processing.
- Face Masking Options: Provides various masking techniques to isolate faces, including simple bounding boxes, convex hulls, and occlusion-aware masks.
- Face Pasting: Allows you to paste edited faces back into the original image seamlessly.
By using comfyui_facetools, you can solve common problems such as misaligned faces, inconsistent face detection, and difficulties in face inpainting. This extension is particularly useful for AI artists looking to refine their portrait work or any project involving detailed face manipulation.
At its core, comfyui_facetools uses advanced algorithms to detect, extract, and manipulate faces within images. Here's a simplified breakdown of how it works:
- Face Detection: The extension uses models like YOLO (You Only Look Once) to detect faces in an image. This model is efficient and can handle various orientations and sizes of faces.
- Face Extraction and Alignment: Once detected, faces are extracted and aligned to a standard orientation. This step ensures that all faces are processed consistently, which is crucial for tasks like inpainting or applying filters.
- Masking: Different masking techniques are applied to isolate the face from the background. This can be a simple square mask, a convex hull based on the face mesh, or an occlusion-aware mask using BiSeNet.
- Face Pasting: After any modifications, the faces can be pasted back into the original image using a warp matrix, ensuring they fit seamlessly.
AlignFaces Node
- Inputs:
insightface
: Use the Load InsightFace
node from .
image
: The input image containing faces.
threshold
: Minimal confidence score for face detection.
min_size
and max_size
: Define the range of face sizes to detect.
- Outputs:
faces
: Detected faces.
FaceDetails Node
- Inputs:
faces
: Detected faces from the AlignFaces node.
crop_size
: Size of the square cropped face image.
crop_factor
: Enlarges the context around the face.
mask_type
: Type of mask to apply (simple_square, convex_hull, BiSeNet).
- Outputs:
crops
: Cropped face images.
masks
: Masks for each cropped face.
warps
: Warp matrix to paste the face back.
WarpFacesBack Node
- Inputs:
images
: The original image.
face
: The face to be pasted back.
crop
: Cropped face images.
mask
: Masks for the cropped faces.
warp
: Warp matrix.
- Outputs:
- The image with the face pasted back.
OrderedFaceFilter Node
- Works similarly to
ImpactSEGSOrderedfilter
.
GenderFaceFilter Node
- Uses InsightFace gender classifier (note: accuracy may vary).
MergeWarps Node
- Combines multiple warp matrices (requires further testing).
Face Detection Models
- YOLO: Used for detecting faces in various orientations and sizes.
- InsightFace: Provides additional face detection and alignment capabilities.
Masking Models
- BiSeNet: Provides occlusion-aware face segmentation. Download the model .
Recent Updates:
- 2024-06-20: Fixed issue .
- 2024-06-14: YOLO model now uses CUDA if available, improving performance.
- 2024-05-22: Updated GenderFaceFilter node for better accuracy.
- 2024-05-19: Added BiSeNetMask and JonathandinuMask nodes. Note: JonathandinuMask is more accurate but requires more memory.
- 2024-03-10: Switched to using
face_yolov8m
for face detection instead of InsightFace.
Common Issues and Solutions:
- Faces Not Detected:
- Ensure the image quality is good and faces are not too small.
- Adjust the
threshold
, min_size
, and max_size
parameters in the AlignFaces node.
- Out of Memory Errors:
- Reduce the image resolution or the number of faces processed simultaneously.
- Use the BiSeNetMask instead of JonathandinuMask if memory is a concern.
- Warping Issues:
- Ensure the warp matrix is correctly applied. Double-check the inputs to the WarpFacesBack node.
Frequently Asked Questions:
- Q: Can I use this extension for non-face objects?
- A: No, this extension is specifically designed for face detection and manipulation.
- Q: How do I improve the accuracy of face detection?
- A: Use high-quality images and adjust the detection parameters. Ensure CUDA is enabled for better performance.
For more information, tutorials, and community support, check out the following resources:
-
These resources provide additional documentation, example workflows, and a community forum where you can ask questions and share your experiences. Happy creating!