ComfyUI  >  Nodes  >  ComfyUI-AutoCropFaces >  Auto Crop Faces

ComfyUI Node: Auto Crop Faces

Class Name

AutoCropFaces

Category
Faces
Author
Sida Liu (Account age: 3236 days)
Extension
ComfyUI-AutoCropFaces
Latest Updated
7/23/2024
Github Stars
0.0K

How to Install ComfyUI-AutoCropFaces

Install this extension via the ComfyUI Manager by searching for  ComfyUI-AutoCropFaces
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter ComfyUI-AutoCropFaces in the search bar
After installation, click the  Restart button to restart ComfyUI. Then, manually refresh your browser to clear the cache and access the updated list of nodes.

Visit ComfyUI Online for ready-to-use ComfyUI environment

  • Free trial available
  • High-speed GPU machines
  • 200+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 50+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

Auto Crop Faces Description

Automatically detect and crop faces from images with advanced algorithms for precise and uniform results.

Auto Crop Faces:

The AutoCropFaces node is designed to automatically detect and crop faces from images, making it an essential tool for AI artists who work with facial imagery. This node leverages advanced face detection algorithms to identify faces within an image and then crops them to a specified aspect ratio, ensuring that the faces are centered and scaled appropriately. The primary benefit of using AutoCropFaces is its ability to handle multiple faces within a single image, providing consistent and high-quality cropped outputs. This node is particularly useful for tasks such as creating datasets for training facial recognition models, generating profile pictures, or any other application where precise and uniform face cropping is required.

Auto Crop Faces Input Parameters:

image

The image parameter is the input image or batch of images from which faces will be detected and cropped. This parameter is essential as it provides the raw data that the node will process. The image should be in a format that the node can interpret, typically a tensor with dimensions representing batch size, channels, height, and width.

number_of_faces

The number_of_faces parameter specifies the number of faces to be cropped from the image. This parameter controls how many faces the node will attempt to detect and crop, ensuring that the output meets the user's requirements. The minimum value is 1, and there is no strict maximum, but it should be set based on the expected number of faces in the image.

start_index

The start_index parameter determines the starting point for selecting faces from the detected faces list. This parameter is useful for cases where you want to select a specific subset of faces from the detected faces. The value should be a non-negative integer, and it will be wrapped around if it exceeds the number of detected faces.

max_faces_per_image

The max_faces_per_image parameter sets the maximum number of faces to be detected and cropped from each image. This parameter helps in controlling the processing load and ensures that only a manageable number of faces are processed per image. The minimum value is 1, and the maximum value depends on the specific use case and computational resources.

scale_factor

The scale_factor parameter adjusts the size of the cropped face relative to the detected face bounding box. A value greater than 1 will enlarge the cropped area, while a value less than 1 will reduce it. This parameter allows for fine-tuning the cropping to include more or less of the surrounding area around the face. Typical values range from 0.5 to 2.0.

shift_factor

The shift_factor parameter controls the vertical shift of the cropped face within the bounding box. A positive value shifts the crop downwards, while a negative value shifts it upwards. This parameter is useful for adjusting the crop to better center the face or include more of the upper or lower part of the face. Values typically range from -0.5 to 0.5.

aspect_ratio

The aspect_ratio parameter defines the width-to-height ratio of the cropped face. This parameter ensures that the cropped faces have a consistent aspect ratio, which is important for applications requiring uniform image dimensions. The aspect ratio is specified as a string in the format "width:height", such as "1:1" for a square crop or "4:3" for a rectangular crop.

method

The method parameter specifies the interpolation method used for resizing the cropped faces. Common methods include 'lanczos', 'bilinear', and 'nearest'. This parameter affects the quality of the resized images, with 'lanczos' typically providing the best quality at the cost of higher computational load. The default value is 'lanczos'.

Auto Crop Faces Output Parameters:

face

The face parameter is the output image or batch of images containing the cropped faces. This output provides the processed images where each face has been detected, cropped, and resized according to the specified parameters. The output is typically a tensor with dimensions representing batch size, channels, height, and width.

CROP_DATA

The CROP_DATA parameter contains the crop coordinates and other relevant information for each detected face. This output provides the details of the cropping process, including the original and adjusted bounding box coordinates. This information is useful for further processing or analysis of the cropped faces.

Auto Crop Faces Usage Tips:

  • To ensure the best results, use high-resolution images as input to improve the accuracy of face detection and cropping.
  • Adjust the scale_factor and shift_factor parameters to fine-tune the cropping area around the faces, especially if the faces are not perfectly centered.
  • Use the aspect_ratio parameter to maintain a consistent aspect ratio for all cropped faces, which is particularly useful for creating uniform datasets.
  • Experiment with different interpolation methods (method parameter) to find the best balance between image quality and processing speed for your specific use case.

Auto Crop Faces Common Errors and Solutions:

"No faces detected in the image."

  • Explanation: This error occurs when the node is unable to detect any faces in the input image.
  • Solution: Ensure that the input image contains clear and visible faces. Increase the resolution of the image or adjust the max_faces_per_image parameter to allow for more detections.

"Invalid aspect ratio format."

  • Explanation: This error occurs when the aspect_ratio parameter is not in the correct "width:height" format.
  • Solution: Ensure that the aspect_ratio parameter is specified as a string in the correct format, such as "1:1" or "4:3".

"Start index out of range."

  • Explanation: This error occurs when the start_index parameter exceeds the number of detected faces.
  • Solution: Ensure that the start_index parameter is within the range of the number of detected faces. If necessary, reduce the start_index value or increase the number_of_faces parameter.

"Interpolation method not supported."

  • Explanation: This error occurs when the specified method parameter is not recognized.
  • Solution: Ensure that the method parameter is set to a supported interpolation method, such as 'lanczos', 'bilinear', or 'nearest'.

Auto Crop Faces Related Nodes

Go back to the extension to check out more related nodes.
ComfyUI-AutoCropFaces
RunComfy

© Copyright 2024 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals.