ComfyUI > Nodes > MW-ComfyUI_PortraitTools > DetectCropFace

ComfyUI Node: DetectCropFace

Class Name

DetectCropFace

Category
🎤MW/MW-PortraitTools
Author
mw (Account age: 2475days)
Extension
MW-ComfyUI_PortraitTools
Latest Updated
2025-06-15
Github Stars
0.02K

How to Install MW-ComfyUI_PortraitTools

Install this extension via the ComfyUI Manager by searching for MW-ComfyUI_PortraitTools
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter MW-ComfyUI_PortraitTools 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
  • 16GB VRAM to 80GB VRAM GPU machines
  • 400+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 200+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

DetectCropFace Description

Facial region extraction with advanced recognition for streamlined face detection and cropping, focusing on primary subject capture.

DetectCropFace:

The DetectCropFace node is designed to identify and extract facial regions from an image, providing a streamlined approach to face detection and cropping. This node leverages advanced facial recognition techniques to accurately locate faces within an image, even when they are at various angles or partially obscured. By focusing on the largest detected face, it ensures that the primary subject is captured, making it particularly useful for portrait photography and applications where the main focus is on a single individual. The node's ability to handle different image sizes and orientations enhances its versatility, allowing you to work with a wide range of images without needing extensive manual adjustments. This functionality is crucial for AI artists who need to prepare images for further processing or analysis, ensuring that the faces are properly aligned and centered for subsequent tasks.

DetectCropFace Input Parameters:

image

The image parameter is the primary input for the DetectCropFace node, representing the image from which faces will be detected and cropped. This parameter accepts an image file, which serves as the source for the face detection process. The quality and resolution of the input image can significantly impact the accuracy of face detection, so it is advisable to use clear and well-lit images for optimal results.

half

The half parameter is a boolean option that determines whether the image processing should be performed in half-precision mode. By default, this is set to False, meaning full precision is used. Enabling half-precision can reduce memory usage and increase processing speed, which is beneficial when working with large images or limited computational resources. However, it may slightly affect the accuracy of the face detection.

horizontal_padding

The horizontal_padding parameter is a float value that specifies the amount of horizontal padding to be added around the detected face. This padding is applied to ensure that the cropped face includes some surrounding context, which can be useful for maintaining the aesthetic balance of the image. The value can be adjusted to control the extent of the padding, allowing for customization based on the specific requirements of your project.

DetectCropFace Output Parameters:

image_tensor

The image_tensor output parameter represents the processed image data in tensor format, which is suitable for further computational tasks or integration with machine learning models. This output contains the cropped and aligned face, ensuring that it is ready for subsequent processing steps. The tensor format is widely used in AI applications, providing a standardized way to handle image data efficiently.

DetectCropFace Usage Tips:

  • Ensure that the input image is of high quality and well-lit to improve the accuracy of face detection.
  • Adjust the horizontal_padding parameter to include more or less background around the detected face, depending on your artistic needs.
  • Consider enabling the half parameter if you are working with large images and need to optimize for speed and memory usage.

DetectCropFace Common Errors and Solutions:

"未检测到人脸"

  • Explanation: This error message indicates that no faces were detected in the input image.
  • Solution: Verify that the input image contains clear and visible faces. Ensure that the image is not too dark or blurry, as this can hinder face detection.

"对齐后未检测到人脸,返回原始图像"

  • Explanation: This message means that after attempting to align the image, no faces were detected.
  • Solution: Check the angle and orientation of the faces in the image. If the faces are at extreme angles, consider adjusting the image manually before processing.

DetectCropFace Related Nodes

Go back to the extension to check out more related nodes.
MW-ComfyUI_PortraitTools
RunComfy
Copyright 2025 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals. RunComfy also provides AI Models, enabling artists to harness the latest AI tools to create incredible art.