统一GPU人脸马赛克(可选RetinaFace/YOLO/MTCNN)
One video node, three detectors, and actually decent output quality
- output_video_path
- processing_info
If you only install one video mosaic node from this pack, make it this one. The "unified" GPU node is the pack's flagship: a single box that lets you pick your face detector - RetinaFace, YOLO, or MTCNN - and, crucially, re-encodes the output with ffmpeg so the result is actually small and playable. That last part is rarer than it should be in this pack, because the plain OpenCV mp4v output it writes elsewhere is the kind of file that plays on nothing. Menu name: 统一GPU人脸马赛克(可选RetinaFace/YOLO/MTCNN) under YZZ_Face_Mosaic/GPU.
How it works
The detector dropdown picks which engine _build_detector constructs:
- retinaface - InsightFace's
buffalo_lvia ONNX Runtime; CUDA if available. The default, and the best all-rounder. - yolo - an Ultralytics YOLO model. Note: the weights are not bundled. The code looks for
yolov8n-face.pt,yolov8s-face.pt,yolov5n-face.pt, oryolov5s-face.ptin your ComfyUI models dir, or whatever you put inyolo_model_path. No weights → the detector prints a notice and detects nothing. - mtcnn -
facenet_pytorchMTCNN, the light option.
Detection runs per frame (on GPU when use_gpu and CUDA cooperate), mosaic styles are the pack's usual pixelate / blur / black_box, and frames are written to a temp file. Then the good part: with use_ffmpeg_encode on (default), it shells out to ffmpeg and re-encodes with H.264 - libx264, CRF controlled by ffmpeg_crf (16–32, default 23), speed by ffmpeg_preset (ultrafast → veryslow). copy_audio on muxes the original audio track straight through instead of dropping it. This is why the output is both small and widely playable, and it's the only video node family in the pack that gives you that.
Inputs worth setting
- detector - the engine choice above. retinaface unless you have reasons.
- yolo_model_path - only matters for the yolo detector; leave blank and it searches your models dir.
- use_ffmpeg_encode + ffmpeg_crf + ffmpeg_preset + copy_audio - your quality controls. CRF 23/preset medium is a sane default; drop CRF to 18 if you care about the frame quality.
- video_path, mosaic_size, mosaic_type, output_format, use_gpu, output_path - the pack's usual cast.
Outputs are output_video_path (STRING) and processing_info (JSON, including a ffmpeg_log_tail you can read if the encode fails).
Installing it
Pack: ComfyUI Manager → yzz_face_mosaic, or git clone https://github.com/yzzky/yzz_face_mosaic into custom_nodes + pip install -r requirements.txt. Then the per-detector extras, none of which are in requirements.txt:
pip install insightface onnxruntime-gpu # retinaface
pip install ultralytics # yolo (face weights still needed!)
pip install facenet-pytorch # mtcnn
Plus ffmpeg itself on your PATH for the re-encode step.
Where it bites
This node has the most dependency surface in the pack: pick a detector you haven't installed and it logs a warning and finds zero faces - your video comes back untouched, no error. First runs download weights. If use_ffmpeg_encode is on but ffmpeg is missing, it silently keeps the raw OpenCV output (the log tells you). And remember the yolo path wants face weights, not the generic COCO yolov8n.pt that Ultralytics auto-downloads - a generic model won't produce face boxes.
Inputs (12)
| Name | Type | Default | Description |
|---|---|---|---|
| video_path | STRING | — | |
| detector | COMBO | 3 options: retinaface, yolo, mtcnn | |
| mosaic_size | INT | 205–100 | — |
| mosaic_type | COMBO | 3 options: pixelate, blur, black_box | |
| output_format | COMBO | 3 options: mp4, avi, mov | |
| use_gpu | BOOLEAN | true | — |
| output_pathopt | STRING | — | |
| yolo_model_pathopt | STRING | — | |
| use_ffmpeg_encodeopt | BOOLEAN | true | — |
| ffmpeg_crfopt | INT | 2316–32 | — |
| ffmpeg_presetopt | COMBO | 9 options: ultrafast, superfast, veryfast, faster, fast, medium, +3 | |
| copy_audioopt | BOOLEAN | true | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| output_video_path | STRING | — |
| processing_info | STRING | — |