ComfyUI Node Runs on cloud

Load BiseNet

The face-segmentation model behind the masks

By ArtBot2023·Created 3 years ago·Updated 2 years ago· 102
Load BiseNet
    • BISENET

    RetinaFace tells you where a face is. BiseNet tells you what parts of that region are face. It's the segmentation model in Character Face Swap - the thing that produces the per-pixel labels (skin, eye, nose, mouth, hair, neck…) that Segment Face, Exclude Facial Feature, and the mask-side of the swap all depend on.

    Load BiseNet is its loader: no inputs, one output, plug it into whichever node needs a BISENET model. If you've used a face-parsing node in the SD1.5 ecosystem before, this is the same BiSeNet from xinntao's facexlib - the standard 19-class face parser (background, skin, left/right brows and eyes, eye glasses, ears, nose, mouth, upper/lower lip, neck, cloth, hair, hat).

    How it works

    On first run it downloads parsing_bisenet.pth from xinntao's facexlib GitHub release into ComfyUI/models/facexlib/ and initializes the model on CUDA. After that, it's cached - one model instance can feed every BiseNet-consuming node in the graph.

    One important detail buried in the pack's code: Segment Face runs the model with a hardcoded .cuda() call. That means this loader, and the segmentation nodes downstream, require a CUDA GPU - this pack is not a CPU-friendly citizen. If you're on an Apple-silicon or CPU-only setup, expect a CUDA error at the segment step rather than a graceful fallback.

    Wiring it

    Single output, named BISENET:

    Both can share one instance; there's no benefit to loading two.

    Installing the pack

    ComfyUI Manager, search Character Face Swap, install, restart. Or:

    cd ComfyUI/custom_nodes/
    git clone https://github.com/ArtBot2023/CharacterFaceSwap.git
    cd CharacterFaceSwap
    python install.py          # on the bundled Windows build: ../../../python_embeded/python install.py
    

    The install.py step pip-installs the bundled facexlib, which provides both BiSeNet and the loading code - without it you'll get No module named 'facexlib'. The weights download themselves on first load, so just give it network access once.

    Common problems

    • CUDA error on first segment - as above, BiSeNet here is CUDA-only. Check nvidia-smi / your ComfyUI launch flags; if you're on CPU or AMD without a CUDA path, this pack's segmentation half won't run as-is.
    • Slow first load: ~100MB weight download plus model init. Normal, one-time.
    • Weird masks in Segment Face: usually not the loader - check include_hair / include_neck and expand there.

    The loader itself is the boring part; the interesting choices - which classes count as "face", how much to expand the mask - live in the nodes you feed it into.

    CategoryCFaceSwap

    Inputs (0)

    No inputs

    Outputs (1)

    NameTypeDescription
    BISENETBISENET