统一GPU图像马赛克(可选RetinaFace/YOLO/MTCNN)
The image mosaic with a RetinaFace/YOLO/MTCNN dropdown
- image
- IMAGE
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_lon ONNX Runtime (CUDA ifuse_gpuand 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, oryolov5s-face.ptin your ComfyUI models dir, or whateveryolo_model_pathpoints at. No face weights → no detections. - mtcnn -
facenet_pytorchMTCNN, 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.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| detector | COMBO | 3 options: retinaface, yolo, mtcnn | |
| mosaic_size | INT | 205–100 | — |
| mosaic_type | COMBO | 3 options: pixelate, blur, black_box | |
| use_gpu | BOOLEAN | true | — |
| yolo_model_pathopt | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |