ComfyUI Extension: ComfyUI Face Detection Node
A ComfyUI custom node for face detection and cropping using OpenCV Haar cascades, with full ComfyUI v3 schema support and backward compatibility. Features adjustable detection threshold, minimum face size, padding, and multiple classifier options.
Custom Nodes (0)
README
ComfyUI Face Detection Node
A ComfyUI custom node for face detection and cropping using OpenCV Haar cascades, with full ComfyUI v3 schema support and backward compatibility.
Features
- Face Detection: Uses OpenCV Haar cascade classifiers for robust face detection
- Flexible Cropping: Crop largest face or all detected faces
- Adjustable Parameters: Configurable detection threshold, minimum face size, and padding
- Multiple Classifiers: Choose between default and alternative Haar cascades
- ComfyUI v3 Ready: Full schema support with backward compatibility for v1/v2
- Async Execution: Stateless execution pattern for better performance
Installation
Via ComfyUI Manager (Recommended)
- Open ComfyUI Manager
- Search for "Face Detection Node"
- Click Install
Manual Installation
- Navigate to your ComfyUI custom nodes directory
- Clone this repository:
git clone https://github.com/Limbicnation/ComfyUI_FaceDetectionNode.git cd ComfyUI_FaceDetectionNode pip install -r requirements.txt
Usage
- Add the "Face Detection and Crop" node to your workflow
- Connect an image input
- Adjust parameters:
- Detection Threshold: Confidence threshold (0.1-1.0)
- Min Face Size: Minimum face size in pixels (32-512)
- Padding: Padding around detected faces (0-256)
- Output Mode: "largest_face" or "all_faces"
- Classifier Type: "default" or "alternative"
Parameters
| Parameter | Type | Range | Default | Description | |-----------|------|-------|---------|-------------| | detection_threshold | Float | 0.1-1.0 | 0.8 | Face detection confidence threshold | | min_face_size | Int | 32-512 | 64 | Minimum size for detected faces | | padding | Int | 0-256 | 32 | Padding around detected faces | | output_mode | Combo | - | largest_face | Output mode for detected faces | | classifier_type | Combo | - | default | Haar cascade classifier type |
Compatibility
- ComfyUI v3: Full schema support with async execution
- ComfyUI v1/v2: Backward compatibility via wrapper class
- Auto-detection: Automatically selects appropriate implementation
Requirements
- Python ≥ 3.8
- OpenCV ≥ 4.5.0
- PyTorch ≥ 1.9.0
- NumPy ≥ 1.21.0
- Pillow ≥ 8.0.0
License
MIT License - see LICENSE file for details.