Nodes/ComfyUI_BEN_ll/LoadRembgByBenModel
ComfyUI Node

LoadRembgByBenModel

The filename picks the model

By lldacing·Created 2 years ago·Updated about a year ago· 4
LoadRembgByBenModel
    • model
    model
    device

    Every BEN node in this pack starts here. You don't drag a .pth file into a widget - you load the model through this node and pass the resulting model object (type BEN) into RembgByBen, RembgByBenAdvanced, or GetMaskByBen.

    Inputs: model, a dropdown of everything in the model folder, and device, with exactly two choices - AUTO and CPU. AUTO sends inference to whatever torch device ComfyUI picked (normally your GPU); CPU is the escape hatch for machines without CUDA or when you want to keep VRAM free for the diffusion half of the workflow. BEN is light enough that CPU is workable, just slower.

    The hidden trick is in the filename, not the dropdown. The loader checks whether the file's name contains BEN2_Base: if it does, it loads the BEN2 architecture; anything else loads BEN v1. So a file called BEN2_Base.pth gets you the newer model, and if you renamed it to BEN_Base.pth to "keep things tidy", you've silently downgraded yourself to v1. Keep the downloaded names as-is.

    That's also why the model list can look wrong: the folder is ComfyUI/models/rembg/ben/. The pack registers a custom model-folder key for it, and folder_paths resolves it, so an extra_model_paths.yaml entry pointing at your own ben folder works too. And nothing auto-downloads - the source contains a download helper, but it's never wired up to run, so you fetch the weights yourself:

    # put these in ComfyUI/models/rembg/ben/
    # BEN:  https://huggingface.co/PramaLLC/BEN/resolve/main/BEN_Base.pth
    # BEN2: https://huggingface.co/PramaLLC/BEN2/resolve/main/BEN2_Base.pth
    

    Two versions to choose from. BEN is PramaLLC's original MIT-licensed segmentation network. BEN2 is the follow-up, which adds a Confidence Guided Matting refiner that re-processes the low-confidence pixels for cleaner edges - generally the better cutout at a bit more compute. Both work in this pack.

    Troubleshooting you'll actually hit: an empty dropdown means the .pth isn't in models/rembg/ben/ (or has the wrong extension - the folder only lists .pth files). The pack failing to load entirely with a module error is usually the dependency thing: pip install -r requirements.txt gives you timm - the real heavy dependency, since the model is Swin-based - plus numpy and packaging, but cv2 is imported at module load even though it's not in that file, so a bare environment may also need pip install opencv-python.

    Install via ComfyUI Manager (search "ComfyUI_BEN_ll") or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/lldacing/ComfyUI_BEN_ll.git
    cd ComfyUI_BEN_ll
    pip install -r requirements.txt
    # restart ComfyUI
    

    Then it's one node, one dropdown, one device toggle, and you're cutting backgrounds.

    Categoryrembg/Ben

    Inputs (2)

    NameTypeDefaultDescription
    modelCOMBO0 options:
    deviceCOMBO2 options: AUTO, CPU

    Outputs (1)

    NameTypeDescription
    modelBEN