Extensions/ComfyUI-Smart-Face-Crop
ComfyUI Extension

ComfyUI-Smart-Face-Crop

An advanced, zero-dependency AI-powered custom node for ComfyUI. Designed for flawless face cropping, zooming, and padding using a local YuNet-based approach.

By anstashhh·Created about a month ago·Updated about a month ago· 2
anstashhh/ComfyUI-Smart-Face-Crop
Nodes
On cloudLocal install
Stars2
Updatedabout a month ago
Readme

ComfyUI-Smart-Face-Crop

An advanced, zero-dependency AI-powered custom node for ComfyUI. Designed for flawless face cropping, zooming, and padding using a local YuNet-based approach. This tool is an essential utility for creating clean, high-quality datasets for model training, making it perfect for streamlining image preprocessing workflows for LoRA, Dreambooth, or other fine-tuning tasks.

Preview


🌟 Key Features

  • 🧠 Zero External Dependencies: No need for heavy packages like onnxruntime or insightface. Works out of the box with standard Python/OpenCV.
  • 🔒 100% Offline & Secure: Perfect for privacy-focused workflows.
  • 📐 Aspect Ratio Protection: Reads each file individually to maintain perfect facial proportions without stretching.
  • 🔄 4 Processing Modes:
    1. side_face_crop: Perfect 1:1 square crop centered on the face.
    2. pad_to_square: Adds borders (white/black) to square-fit the image.
    3. zoom_face_crop: Tight portrait close-up from crown to chin.
    4. extract_multiple_faces: Detects all faces in a group and outputs each separately.

⚙️ Interface & Parameters

| Parameter | Type | Description | | :--- | :--- | :--- | | io_mode | Selection | single_image (standard node link) or batch_folder (processes folder). | | mode | Selection | Choose from the 4 cropping behaviors. | | target_size | Integer | Resolution of the final output (e.g., 1024). | | pad_color | Selection | white or black (for pad_to_square mode). | | file_type | Selection | Output format (jpg or png) for saved images. | | input_folder | String | Local path for batch input. | | output_folder| String | Local path for batch output. |


🛠️ Installation

  1. Clone this repository into your ComfyUI/custom_nodes directory:
    cd ComfyUI/custom_nodes
    git clone [https://github.com/YOUR_USERNAME/ComfyUI-Smart-Face-Crop.git](https://github.com/YOUR_USERNAME/ComfyUI-Smart-Face-Crop.git)