ComfyUI Node Runs on cloud

SAM Loader

Load Segment Anything for precise masking

By sipherxyz·Created 3 years ago·Updated 4 months ago· 352
SAM Loader
    • sam_model
    model_name

    This is the "load the model, then go segment things" node for Meta's Segment Anything inside the ArtVenture pack. On its own it does nothing visible - it just reads a SAM checkpoint off disk and hands it downstream. But if you want to mask a specific object in an image, not just chop the whole foreground away from the background, SAM is the right tool and this is how you get it loaded.

    Worth being clear about what SAM is for, because people reach for it when they don't need it. If you just want a clean cutout of the subject - a product, a person, whatever's in front - you want rembg or BiRefNet, not this. SAM is for targeted selection: pick out the red dress, the left hand, one specific object in a busy frame, and feed that mask into inpainting or compositing. Pair it with a text-prompted detector and you can say "the person on the left" and get a precise mask back. That's the workflow SAM earns its keep in. For a plain background knock-out it's overkill.

    How it works

    SAM is a universal segmentation model: give it an image plus a hint (a point, a box, a region) and it returns a pixel-accurate mask of whatever's there. It's genuinely good at edges. The catch is it needs a prompt to know what to segment - which is why the loaded model gets passed to a separate segment/detector node rather than doing anything by itself. This node is step one of two: load here, prompt-and-mask there.

    Inputs and outputs

    There's exactly one input:

    • model_name - a dropdown of the SAM checkpoints it finds on disk. If the menu is empty, that's your first problem: you haven't put a SAM model in the folder yet (more on that below).

    The single output is sam_model (type AV_SAM_MODEL) - the loaded model, which only plugs into ArtVenture's own SAM-based segmentation nodes. It's not interchangeable with SAM loaders from other packs, so keep the whole chain inside ArtVenture.

    Installing it

    The node ships with the ArtVenture pack. Easiest route is ComfyUI Manager: open it, search comfyui-art-venture, install, restart. By hand:

    cd ComfyUI/custom_nodes
    git clone https://github.com/sipherxyz/comfyui-art-venture
    

    Then restart ComfyUI so it picks up the new nodes and installs the pack's Python dependencies.

    The part that trips everyone up: the pack doesn't ship a SAM checkpoint. You download one yourself and drop it into ComfyUI/models/sams/. The standard weights are the ViT-H (biggest, best, slow), ViT-L, or ViT-B (smallest, fastest) checkpoints from Meta's release. Grab one, restart, and it shows up in the model_name dropdown.

    Common issues

    Empty model_name dropdown. No SAM file in models/sams/. Download a checkpoint and restart - ComfyUI only scans model folders at startup.

    It won't connect to another pack's SAM node. Right, it won't. The AV_SAM_MODEL output is ArtVenture-specific by design. If you're mixing packs, keep the loader and the segmenter from the same one.

    VRAM. The ViT-H checkpoint is the heavy one. If you're tight on memory and only need decent masks, ViT-B is a big saving for a small quality hit - the classic SAM speed/quality dial.

    It's slow, and you only wanted a cutout. Then you didn't want SAM. Object-specific masking is what it's built for; for foreground-vs-background, a dedicated background remover is faster and simpler.

    CategoryArtVenture/Segmentation

    Inputs (1)

    NameTypeDefaultDescription
    model_nameCOMBO0 options:

    Outputs (1)

    NameTypeDescription
    sam_modelAV_SAM_MODEL