图像人脸马赛克
One node to mosaic every face in a ComfyUI image
- image
- IMAGE
Sometimes you don't need a video pipeline at all - you just need to strip the faces out of a single image before it ships anywhere. This is the still-image half of the yzz_face_mosaic pack: feed it any ComfyUI IMAGE, and it finds every face and pixelates, blurs, or black-boxes each one. If you've ever built the "detect face → mask → blur → composite" graph for a privacy job, this node is that graph collapsed into one box.
In the node menu it's listed as 图像人脸马赛克 (image face mosaic) under YZZ_Face_Mosaic.
How it works
Same engine as the pack's video node: OpenCV's Haar cascade (haarcascade_frontalface_default.xml), the CPU-friendly frontal-face detector that ships inside OpenCV itself. The node takes the incoming tensor, converts it to an OpenCV BGR array, grayscales it, and runs detectMultiScale once. Every bounding box it returns gets the mosaic treatment:
pixelate- shrink the face region then blow it back up with nearest-neighbor for the blocky lookblur- Gaussian blur, strength driven bymosaic_sizeblack_box- paint the rectangle black
The result goes back to a standard IMAGE tensor, so it plugs into Preview Image, Save Image, or anything else downstream. No file I/O, no model downloads - this node is pure CPU and it's effectively instant on a single image.
The inputs that matter
- image - any IMAGE tensor, typically from a Load Image node. A batch works too; the node processes it as-is.
- detection_scale - the cascade's search step. Lower (toward 1.01) means more thorough searching and more misses avoided; 1.1 default is a good speed/accuracy trade-off.
- min_neighbors - how many overlapping detections must agree before a face counts. Raised (say 8–12) it kills false positives on busy backgrounds; lowered it catches faces the detector is unsure about.
- mosaic_size - block size for pixelate, blur radius for blur. 20 is very obvious; 8–12 reads as "deliberately obscured" without looking like a NES glitch.
The only output is IMAGE, which is refreshingly simple - you don't have to chase a file path around, you just keep going in your graph.
Installing it
It ships with the whole pack, so ComfyUI Manager search yzz_face_mosaic is the easy path, or:
cd ComfyUI/custom_nodes
git clone https://github.com/yzzky/yzz_face_mosaic
pip install -r requirements.txt
Restart, and the node appears under YZZ_Face_Mosaic. Requirements are just OpenCV, numpy, and ultralytics (bundled for the YOLO variants elsewhere in the pack) - nothing for this node to download at runtime.
Where it bites
Haar is a frontal-face detector. If your image has people in profile, turned away, in shadow, or far in the background, they'll survive un-mosaicked and that's a real privacy hole - verify the output, don't assume. For anything where faces are angled or small, reach for the pack's UnifiedGPUImageFaceMosaicNode with the retinaface or mtcnn detector instead. And don't expect it to distinguish one person from another - that's the SelectiveImageFaceMosaicNode's job.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| mosaic_size | INT | 205–100 | — |
| detection_scale | FLOAT | 1.101.01–2 | — |
| min_neighbors | INT | 51–20 | — |
| mosaic_type | COMBO | 3 options: pixelate, blur, black_box |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |