Nodes/face_mosaic/优化版视频人脸马赛克
ComfyUI Node

优化版视频人脸马赛克

The 'optimized' video face mosaic — faster, with a side of fiction

By yzzky·Created 12 months ago·Updated 12 months ago· 0
优化版视频人脸马赛克
    • output_video_path
    • processing_info
    ◄video_path►
    ◄mosaic_size20►
    ◄detection_scale1.10►
    ◄min_neighbors5►
    ◄mosaic_type▾►
    ◄output_format▾►
    ◄output_quality80►
    ◄use_gputrue►
    ◄parallel_processingtrue►
    ◄batch_size4►
    ◄optimization_level▾►
    ◄output_path►

    Long video files are where the plain CPU mosaic node starts to hurt - it chews through a 1080p clip one frame at a time on a single thread. This variant is the pack's answer to that: same Haar-cascade detection, but with a thread pool, frame batching, and a GPU path it tries to use. In the menu it's 优化版视频人脸马赛克 (optimized video face mosaic) under YZZ_Face_Mosaic.

    How it works

    The core detector is still OpenCV's Haar cascade, but the plumbing is different. With parallel_processing on, frames are read in batches (up to 1000 in memory to avoid blowing up on long clips) and handed to a ThreadPoolExecutor capped at 8 workers - detection for many frames runs concurrently while the writer stays serialized. batch_size (1–16) sets how many frames go through the pipe per batch.

    optimization_level is the interesting knob, because it rewrites your other settings:

    • fast - forces detection_scale up to at least 1.2 and min_neighbors to at least 3. Fewer detections per frame, faster.
    • accurate - clamps detection_scale down to 1.05 and min_neighbors to 8 max. More thorough, slower.
    • balanced - leaves your values alone.

    So if you set detection_scale to 1.02 and then pick "fast," the node quietly ignores your value. That's worth knowing when you're wondering why faces are getting missed.

    About that GPU toggle

    use_gpu here attempts OpenCV's CUDA-accelerated CascadeClassifier - cv2.cuda. Reality check: stock pip install opencv-python wheels are not built with CUDA, so hasattr(cv2, 'cuda') is False on almost every ComfyUI install and the node just prints a warning and falls back to CPU. It's a genuine capability, but you'd need a CUDA-enabled OpenCV build to ever see it. Don't buy the node for this feature.

    Inputs and outputs

    Same cast as the plain node: video_path, mosaic_size, detection_scale, min_neighbors, mosaic_type, output_format, output_quality, optional output_path - plus use_gpu, parallel_processing, batch_size, optimization_level. Outputs are output_video_path and processing_info (JSON with frames, faces, and processing time/fps). Files land in ComfyUI/output/face_mosaic/.

    Installing it

    Standard pack install: ComfyUI Manager → yzz_face_mosaic, or git clone https://github.com/yzzky/yzz_face_mosaic into custom_nodes + pip install -r requirements.txt, restart. No extra backends needed - this is a pure OpenCV node.

    Where it bites

    "Optimized" is doing a lot of work. The thread pool helps when the bottleneck is per-frame detection, but video write and OpenCV internals are still serialized, so don't expect a 4× speedup - on many machines the plain node and this one land close. The honest win is optimization_level, which trades detection quality for speed without you fiddling three sliders. If your real problem is accuracy (missed faces), this node doesn't fix that - that's what the InsightFace or MTCNN variants are for.

    CategoryYZZ_Face_Mosaic

    Inputs (12)

    NameTypeDefaultDescription
    video_pathSTRING—
    mosaic_sizeINT205–100—
    detection_scaleFLOAT1.101.01–2—
    min_neighborsINT51–20—
    mosaic_typeCOMBO3 options: pixelate, blur, black_box
    output_formatCOMBO3 options: mp4, avi, mov
    output_qualityINT801–100—
    use_gpuBOOLEANtrue—
    parallel_processingBOOLEANtrue—
    batch_sizeINT41–16—
    optimization_levelCOMBO3 options: fast, balanced, accurate
    output_pathSTRING—

    Outputs (2)

    NameTypeDescription
    output_video_pathSTRING—
    processing_infoSTRING—