Visit ComfyUI Online for ready-to-use ComfyUI environment
Automatically detect and crop faces from images with advanced algorithms for precise and uniform results.
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.
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.
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.
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.
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.
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.
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.
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.
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'.
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.
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.
© Copyright 2024 RunComfy. All Rights Reserved.