Nodes/face_mosaic/统一GPU图像马赛克(可选RetinaFace/YOLO/MTCNN)
ComfyUI Node

统一GPU图像马赛克(可选RetinaFace/YOLO/MTCNN)

The image mosaic with a RetinaFace/YOLO/MTCNN dropdown

By yzzky·Created 12 months ago·Updated 12 months ago· 0
统一GPU图像马赛克(可选RetinaFace/YOLO/MTCNN)
  • image
  • IMAGE
◄detector▾►
◄mosaic_size20►
◄mosaic_type▾►
◄use_gputrue►
◄yolo_model_path►

The pack has three separate image mosaic nodes because it grew organically - one per detector family. This is the one that stops pretending and just gives you the dropdown: RetinaFace, YOLO, or MTCNN, applied to a single image, IMAGE in and IMAGE out. If you're tired of remembering which node uses which backend, this is the one to standardize on. Menu name: 统一GPU图像马赛克(可选RetinaFace/YOLO/MTCNN) under YZZ_Face_Mosaic/GPU.

How it works

Same _build_detector machinery as the unified video node, minus the video:

  • retinaface - InsightFace buffalo_l on ONNX Runtime (CUDA if use_gpu and available). Default, best accuracy.
  • yolo - Ultralytics YOLO, but only if it finds a face-trained weight: yolov8n-face.pt, yolov8s-face.pt, yolov5n-face.pt, or yolov5s-face.pt in your ComfyUI models dir, or whatever yolo_model_path points at. No face weights → no detections.
  • mtcnn - facenet_pytorch MTCNN, light and quick.

Your IMAGE tensor becomes an OpenCV array, the chosen detector finds faces, and each gets pixelate, blur, or black_box. Result returns as an IMAGE tensor for preview/save. There's no ffmpeg step here because there's no file - image out, done.

Inputs

  • image - any IMAGE tensor.
  • detector - the dropdown above.
  • yolo_model_path - only relevant for yolo; blank lets it search the models dir.
  • mosaic_size, mosaic_type, use_gpu - the pack's usual suspects.

Output is a single IMAGE.

Installing it

Pack install is the standard one - ComfyUI Manager → yzz_face_mosaic, or git clone https://github.com/yzzky/yzz_face_mosaic into custom_nodes + pip install -r requirements.txt - but the detector backends are not in requirements.txt:

pip install insightface onnxruntime-gpu    # retinaface
pip install ultralytics                    # yolo (plus face weights!)
pip install facenet-pytorch                # mtcnn

Restart after. First runs download weights (buffalo_l / any yolo face weights you supply).

Where it bites

The dependency-surface warning is the same as the video twin's, just on a single frame: pick a backend you haven't installed and the node returns your image unmosaicked with only a console notice to show for it. And the yolo trap is real - Ultralytics happily auto-downloads the COCO yolov8n.pt, which is a general object detector, not a face detector; a COCO model won't find faces. If you want one image node that just works, set detector to retinaface, install insightface, and forget the dropdown exists.

CategoryYZZ_Face_Mosaic/GPU

Inputs (6)

NameTypeDefaultDescription
imageIMAGE—
detectorCOMBO3 options: retinaface, yolo, mtcnn
mosaic_sizeINT205–100—
mosaic_typeCOMBO3 options: pixelate, blur, black_box
use_gpuBOOLEANtrue—
yolo_model_pathoptSTRING—

Outputs (1)

NameTypeDescription
IMAGEIMAGE—