ComfyUI Node

SAM3 Model Loader

Loading SAM 3

By lihaoyun6·Created 10 months ago·Updated 8 months ago· 21
SAM3 Model Loader
    • sam3_model
    modelfacebook/sam3
    deviceauto
    precisionfp16
    segmentorimage
    text_promptstrue

    The old way to mask "the guy in the red jacket" in ComfyUI was a two-model chain: GroundingDINO detected the box, then SAM refined it into a mask. SAM3 Model Loader is the one-node version of that whole rig. Meta's SAM 3 (November 2025) does promptable concept segmentation - you type a short noun phrase, and it returns a mask for every matching instance in the image in a single pass. This node just loads it. Everything before SAM 3, you had to describe in boxes and clicks; this is the first generation where "a noun phrase" is a complete prompt.

    It's the entry point of lihaoyun6's ComfyUI-SegmentAnything3 pack, from the same author behind ComfyUI-FlashVSR. The node's only output is a sam3_model that wires straight into SAM3 Segmentation, which handles both image and video in the one node depending on how you set the loader. The mask that comes out the other end feeds whatever masks usually feed: inpainting a region, regional prompting, compositing, or the Impact Pack's detailer loop.

    How it works

    The loader picks the right class from HuggingFace Transformers' SAM 3 support based on two of its own inputs. segmentor = "image" loads Sam3Model/Sam3Processor; "video" loads the tracker variants (Sam3TrackerVideoModel). text_prompts = on means the promptable text mode, off means point/box/mask prompting instead - which is also how you get pure click-based selection via the pack's SAM3 Point Collector widget.

    First run downloads the weights automatically to ComfyUI/models/sams/facebook-sam3 (the folder name is the model ID with the slash swapped for a dash), and it pulls from ModelScope, not HuggingFace - that's worth knowing if ModelScope is slow or unreachable in your region; it's the opposite of the usual assumption. The node caches the loaded model on itself, and on reload it shoves the old one to CPU, deletes it, runs gc.collect() and a soft CUDA cache empty, so re-running a workflow doesn't stack three copies of a 473M-parameter model in VRAM. It also patches the video propagation path so ComfyUI's queue widget stays responsive during long frame-by-frame tracking.

    Inputs and outputs that matter

    Five inputs, and you set exactly two:

    • model - a single choice, facebook/sam3. Nothing to do.
    • device - auto picks CUDA if available, else CPU. Leave it.
    • precision - fp16 is the default and right for most people. Drop to fp32 only if you're chasing numerical fidelity and have VRAM to burn; bf16 is the middle ground on Ampere-and-newer cards.
    • segmentor - image or video. Video is where SAM 3 earns its keep (tracking with stable IDs), but it costs more VRAM and time.
    • text_prompts - on for phrase-prompting, off for click/box mode.

    Output: a single sam3_model into SAM3 Segmentation.

    Installing it

    cd ComfyUI/custom_nodes
    git clone https://github.com/lihaoyun6/ComfyUI-SegmentAnything3.git
    python -m pip install -r ComfyUI-SegmentAnything3/requirements.txt
    

    ComfyUI Manager finds it under "ComfyUI-SegmentAnything3". Restart ComfyUI after installing.

    Common issues

    The big one is dependencies. This pack needs transformers >= 5.0.0dev, and its requirements.txt pins a pre-release wheel (transformers==5.0.0rc3) that can stomp on other packs expecting transformers 4.x - the README's warning about uninstalling and reinstalling is aimed at exactly that collision. Check pip show transformers if something else in your install starts failing after this.

    Two more things people hit. The model download is automatic but first-run can look like a hang - it's a ~473M download from ModelScope, so give it a minute and keep the network up (the README says so in so many words). And on the licensing front: SAM 3 ships under Meta's custom SAM Licence, not the Apache 2.0 that SAM and SAM 2 carry - fine for personal work, read it before you ship a product.

    One genuinely nice thing about this pack versus the fat all-in-one SAM 3 nodes: no Triton dependency, which is the Windows-killer that makes the ComfyUI-RMBG SAM 3 integration a pain. This is the standalone alternative people fall back to when the bundled one OOMs.

    CategorySAM3

    Inputs (5)

    NameTypeDefaultDescription
    modelCOMBOfacebook/sam31 options: facebook/sam3
    deviceCOMBOautoDevice to load the weights, default: auto (CUDA if available, else CPU)
    precisionCOMBOfp163 options: fp16, bf16, fp32
    segmentorCOMBOimageChoose between image or video segmentation mode.
    text_promptsBOOLEANtrueUse text prompts instead of conditions for segmentation.

    Outputs (1)

    NameTypeDescription
    sam3_modelsam3_model