Tool: Face Blur Node | 人脸模糊节点 (YOLO supported)

Details

Model description

Note: Haar Cascade is less effective for anime styles and better suited for realistic styles. YOLO offers significantly improved accuracy across various styles, including more complex scenarios.

注意:Haar Cascade 动漫风格识别率不高,更适用于真实风格,其识别库的初衷也不是识别动漫。YOLO 在各种风格下(包括更复杂场景)都能提供显著提升的识别精度。

ComfyUI Face Blurring Nodes: Efficient Tools for Lora Training

During Lora training, I frequently need to blur faces in upscaled images derived from raw inputs. This is crucial not only for privacy but, more importantly, to prevent the model from learning specific facial features. However, the constant back-and-forth between ComfyUI and external image editing tools for this task was cumbersome and inefficient.

To address this pain point, I asked Gemini to develop these custom ComfyUI nodes. They leverage CPU (or GPU for YOLO if ultralytics utilizes it) and the OpenCV/YOLO libraries to perform in-ComfyUI face detection and circular gradient blurring, significantly enhancing workflow efficiency.

Features & Usage:

Node Installation: Extract the provided ZIP package directly into your ComfyUI/custom_nodes/ directory, then restart ComfyUI.

  • For "Circular Face Blur (Haar Cascade)": The node will automatically try to load the haarcascade_frontalface_default.xml file (included in the package's data/ subfolder).

  • For "Circular Face Blur (YOLO)": You will need to provide the absolute path to your YOLO model file (e.g., face_yolov8m.pt) in the node's parameters.

Available Nodes:

  1. Circular Face Blur (Haar Cascade)

    • Description: Uses the traditional OpenCV Haar Cascade classifier for face detection. Fast, but less accurate for diverse lighting, angles, and non-realistic styles.

    • Key Parameters:

      • min_face_size: Minimum recognizable face size in pixels.

      • min_neighbors: Strictness (sensitivity) of face detection. Higher values lead to stricter detection and fewer false positives.

      • blur_radius_factor: Radius factor for the circular blur area. Increasing this value expands the blur region.

      • gradient_width_factor: Gradient width factor for the blur edge. Increasing this value creates a smoother transition.

      • expansion_margin_factor: Expansion margin factor for the pre-blur area. Ensures the initial blur region is large enough to contain the full circular blur effect.

  2. Circular Face Blur (YOLO)

    • Description: Employs advanced YOLOv8 models for robust and accurate face detection. Offers significantly better performance across various facial expressions, angles, lighting conditions, and even non-realistic styles. Recommended for higher precision.

    • Key Parameters:

      • yolo_model_path: Required, please use an absolute path, e.g., D:/ComfyUI/models/bbox/face_yolov8m.pt Path to your YOLOv8 face detection model file.

      • min_face_size: Minimum recognizable face/object size in pixels. Detections smaller than this will be ignored.

      • confidence_threshold: Minimum confidence score for a detected face to be blurred. Higher values mean stricter detection.

      • blur_radius_factor: Radius factor for the circular blur area.

      • gradient_width_factor: Gradient width factor for the blur edge.

      • expansion_margin_factor: Expansion margin factor for the pre-blur area.

Environment Dependencies: Please ensure opencv-python, numpy, and ultralytics libraries are installed in your ComfyUI environment (pip install opencv-python numpy ultralytics).


ComfyUI 人脸模糊节点:Lora 训练人脸模糊的得力助手

在 Lora 训练过程中,我经常需要对原始图片 Upscale 处理后的图片进行人脸模糊处理。这不仅是为了保护隐私,更重要的是为了避免模型学习到特定的人脸特征。然而,频繁地在 ComfyUI 和外部图像编辑工具之间切换来完成这项工作,过程十分繁琐且效率低下。

为解决这个痛点,我让 Gemini 帮我设计了这款 ComfyUI 自定义节点。它们利用 CPU(YOLO 版本在支持的情况下也可利用 GPU)和 OpenCV/YOLO 库,直接在 ComfyUI 内部实现人脸检测及圆形渐变模糊,显著提升了工作流效率。

特性及使用:

节点安装: 解压提供的 ZIP 包至 ComfyUI/custom_nodes/ 目录下,然后重启 ComfyUI 即可。

  • 对于 “Circular Face Blur (Haar Cascade)” 节点:会自动尝试加载 haarcascade_frontalface_default.xml 文件(已包含在包的 data/ 子文件夹内)。

  • 对于 “Circular Face Blur (YOLO)” 节点:您需要在节点参数中提供 YOLO 模型文件的绝对路径(例如 face_yolov8m.pt)。

可用节点:

  1. Circular Face Blur (Haar Cascade)

    • 描述: 使用传统的 OpenCV Haar Cascade 分类器进行人脸检测。速度较快,但对于多变的光照、角度和非真实风格的图片识别精度较低。

    • 关键参数:

      • min_face_size: 最小识别人脸的尺寸(像素)。

      • min_neighbors: 人脸检测的严格程度(敏感度)。值越高,检测越严格,误报越少。

      • blur_radius_factor: 模糊圆形区域的半径因子。增大此值可扩大模糊范围。

      • gradient_width_factor: 模糊边缘渐变宽度因子。增大此值可使渐变更平滑。

      • expansion_margin_factor: 模糊预扩展区域因子。确保初始模糊区域足够大,以容纳完整的圆形模糊效果。

  2. Circular Face Blur (YOLO)

    • 描述: 采用先进的 YOLOv8 模型进行更鲁棒、更精准的人脸检测。在各种面部表情、角度、光照条件甚至非真实风格下都能提供显著更好的性能。推荐用于需要更高精度的场景。

    • 关键参数:

      • yolo_model_path: (必填,请使用绝对路径,例如:D:/ComfyUI/models/bbox/face_yolov8m.pt 您的 YOLOv8 人脸检测模型文件路径。

      • confidence_threshold: 检测到人脸的最小置信度。值越高表示检测越严格。

      • min_face_size: 最小识别目标尺寸(像素)。小于此值的检测结果将被忽略。

      • blur_radius_factor: 模糊圆形区域的半径因子。

      • gradient_width_factor: 模糊边缘渐变宽度因子。

      • expansion_margin_factor: 模糊预扩展区域因子。

环境依赖: 请确保您的 ComfyUI 环境中已安装 opencv-pythonnumpyultralytics 库(pip install opencv-python numpy ultralytics)。

Images made by this model

No Images Found.