选择性人脸马赛克(指定人物)
Mosaic only the person you name — face recognition in one node
- output_video_path
- processing_info
Every other node in this pack mosaics everyone. That's the wrong answer half the time - you want to obscure the bystander while leaving the speaker visible, or mask the guest but not the host. This node is the pack's smart one: you give it reference photos of the person (or people) to hide, and it only mosaics faces that match, leaving everyone else untouched. It's the "选择性人脸马赛克(指定人物)" entry - selective face mosaic (specified person) - under YZZ_Face_Mosaic/Selective.
How it works
This is real face recognition, not just detection. On init the node builds a recognizer using one of two backends:
- insightface -
FaceAnalysiswithbuffalo_l, the same RetinaFace detection plus the recognition embeddings the face-swap community uses. Heavier, generally better. - facenet - MTCNN for detection plus
InceptionResnetV1pretrained on VGGFace2 for the embeddings. Lighter, respectable.
For each reference image (one file path per line in the reference_images box) it extracts an embedding. Then for every frame it detects faces, embeds each one, and computes cosine similarity against your references. If the score clears similarity_threshold, that face gets mosaicked; if not, it passes through. similarity_threshold runs 0.3–0.9, default 0.6 - lower is more aggressive (mosaics lookalikes and false positives), higher is stricter (can start missing your actual target when lighting shifts).
The inputs that matter
- reference_images - multiline, one path per line. Clear photos of the person's face work best; a couple of angles beat one straight-on shot.
- recognition_backend - insightface for accuracy, facenet for lighter installs.
- similarity_threshold - the only knob that determines who's "the target." Start at 0.6 and adjust up if strangers get masked, down if your person keeps escaping.
- mosaic_size, mosaic_type, output_format, use_gpu - the pack's usual suspects.
Outputs are output_video_path and processing_info. If you leave use_ffmpeg_encode on (default), the video gets re-encoded with ffmpeg - CRF quality via ffmpeg_crf and ffmpeg_preset, audio copied unless you flip copy_audio off. This needs ffmpeg on your PATH; without it, the node logs a notice and keeps the plain OpenCV output.
Installing it - two installs, not one
Beyond the pack itself (ComfyUI Manager → yzz_face_mosaic, or git clone https://github.com/yzzky/yzz_face_mosaic + pip install -r requirements.txt), you must install the recognition backend - it is not in requirements.txt:
pip install insightface onnxruntime-gpu # for the insightface backend
# or
pip install facenet-pytorch # for the facenet backend
InsightFace's first run downloads the buffalo_l weights; facenet's VGGFace2 weights also download on first use. Restart ComfyUI after installing.
Where it bites
Embeddings are sensitive to faces looking very different from your reference (new glasses, dramatic hair, harsh lighting), so keep the threshold modest and include variety in references. And remember: if the recognizer itself isn't installed, the node returns no matches and your video ships with nobody masked - check the console. It's the most useful node in the pack for real-world "hide this one person" work, but it's also the one with the most moving parts.
Inputs (13)
| Name | Type | Default | Description |
|---|---|---|---|
| video_path | STRING | — | |
| reference_images | STRING | — | |
| recognition_backend | COMBO | 2 options: insightface, facenet | |
| similarity_threshold | FLOAT | 0.600.3–0.9 | — |
| 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 | — | |
| 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 | — |