Nodes/face_mosaic/GPU视频人脸马赛克
ComfyUI Node

GPU视频人脸马赛克

A face mosaic that actually survives profile shots — if you install the backend

By yzzky·Created 12 months ago·Updated 12 months ago· 0
GPU视频人脸马赛克
    • output_video_path
    • processing_info
    ◄video_path►
    ◄mosaic_size20►
    ◄mosaic_type▾►
    ◄output_format▾►
    ◄use_gputrue►
    ◄output_path►

    The plain FaceMosaicNode in this pack is Haar cascade, which means it'll cheerfully miss your subject the second they turn their head. This is the upgrade: instead of a 2001 detector, it runs InsightFace's RetinaFace (the buffalo_l model set), which is the same detector the whole face-swap ecosystem leans on. It handles angled heads, half-faces and small faces far better, and when you've got a CUDA GPU and the right packages, the detection itself runs on that GPU. In the menu it's GPU视频人脸马赛克 under YZZ_Face_Mosaic/GPU.

    How it works

    The node wraps InsightFace's FaceAnalysis app. On init it builds the model with buffalo_l, picks the ONNX Runtime providers (CUDA if you asked for GPU and torch.cuda.is_available(), otherwise CPU), and downloads the model weights on first run if they're not cached. Then it's the same loop as the CPU node: read a frame, detect faces, apply pixelate / blur / black_box to each bounding box, write out. Note the "GPU" is about detection - the mosaic painting itself is plain OpenCV on the CPU, but that's microseconds next to the detector, so you won't notice.

    Output lands in ComfyUI/output/face_mosaic_gpu/ as output_video_path plus a processing_info JSON (which helpfully includes measured processing fps so you can tell whether the GPU path actually engaged).

    The honest catch

    Here's where people get burned: insightface is not in the pack's requirements.txt. If you install the pack and hit the GPU node, you'll see a console warning that InsightFace isn't installed - and then the detector returns nothing, so the video gets processed with zero faces found. The output is a perfect copy of your input with no mosaic on it. It fails quietly. The fix:

    pip install insightface onnxruntime-gpu   # in your ComfyUI Python env
    

    Then restart. For pure CPU you can get away with pip install insightface onnxruntime instead, but the whole point of this node is the GPU provider. First run downloads the buffalo_l weights (a few hundred MB) so make sure you have internet and a couple of minutes.

    Inputs worth setting

    • video_path - string path; wire it from the pack's VideoUploadNode.
    • use_gpu - default on. It's a real toggle, not decoration: off forces the CPU provider.
    • mosaic_size / mosaic_type - same three styles as the rest of the pack.
    • output_format and optional output_path - as you'd expect.

    There's no detection_scale / min_neighbors here - InsightFace doesn't work that way, which is part of why it's better.

    Installing it

    Pack install is ComfyUI Manager → yzz_face_mosaic, or git clone https://github.com/yzzky/yzz_face_mosaic into custom_nodes, pip install -r requirements.txt, restart. Just remember the extra insightface step above before you judge the node.

    Where it bites

    If the console says 初始化InsightFace失败 or a log about providers, it fell back to nothing - check your onnxruntime install matches your CUDA version. And if you're on a machine with no CUDA at all, this node is just a slower way to run InsightFace on CPU; you'd be better served by the pack's MTCNN option, which is lighter. One node per frame, sequential - for a long clip it'll be slow regardless, because accurate detection costs time.

    CategoryYZZ_Face_Mosaic/GPU

    Inputs (6)

    NameTypeDefaultDescription
    video_pathSTRING—
    mosaic_sizeINT205–100—
    mosaic_typeCOMBO3 options: pixelate, blur, black_box
    output_formatCOMBO3 options: mp4, avi, mov
    use_gpuBOOLEANtrue—
    output_pathoptSTRING—

    Outputs (2)

    NameTypeDescription
    output_video_pathSTRING—
    processing_infoSTRING—