Nodes/Frog Node Pack/🐸 SAM Loader
ComfyUI Node

🐸 SAM Loader

Load SAM 1 or SAM 2 checkpoints into ComfyUI β€” and the heavy installs it hides

By RabbitThatIsPinkΒ·Created 3 months agoΒ·Updated 24 days agoΒ· 1
🐸 SAM Loader
    • sam_model
    β—„modelβ–Ύβ–Ί
    β—„versionauto-detectβ–Ί
    β—„sam1_archauto-detectβ–Ί
    β—„deviceautoβ–Ί

    SAM (Segment Anything) is the masking backbone of targeted editing - the model that turns a click, a box, or in newer versions a text phrase into a clean object mask. If your workflow does Florence2+SAM masking, face or region detailing, or anything that needs a precise mask rather than a background removal, you need a SAM model loaded, and 🐸 SAM Loader is the Frog Pack's way in. It loads both SAM 1 and SAM 2 checkpoints from ComfyUI/models/sam/ and hands you a SAM_MODEL you can wire into 🐸 Florence2+SAM Masker or Impact Pack nodes.

    The mechanism is the interesting part, because it's mostly auto-detection done for you. The loader registers models/sam/ as a model folder with ComfyUI, then picks the right loader based on your checkpoint's filename: version auto-detects "SAM 1" vs "SAM 2" by looking for sam2 in the name; sam1_arch auto-detects vit_h / vit_l / vit_b; and for SAM 2 it maps known filename patterns to the right Hydra config. The dropdowns (auto-detect defaults) exist as overrides only if your filename doesn't follow convention. device defaults to auto β†’ CUDA if available, else CPU.

    Here's the thing the README's "WIP - Unstable" tag and the source both want you to know: this node has real dependencies, and they are not installed by the pack. The pack's requirements.txt is deliberately empty - installing Frog Node Pack does not give you SAM support. From the source header:

    • SAM 1 needs pip install segment-anything-hq - and the warning is explicit: do not also install plain segment-anything, they conflict.
    • SAM 2 needs the sam2 package installed from source: git clone https://github.com/facebookresearch/sam2 && cd sam2 && pip install -e .. If SAM 2 config resolution fails at load, the error message points straight at that -e . requirement.

    And the model files themselves are chunky downloads into ComfyUI/models/sam/. The recommended ones: SAM 1 HQ sam_hq_vit_h.pth at ~2.57 GB, or SAM 2 sam2.1_hiera_large.pt at ~898 MB. The SAM 1 HQ variant is called out as the quality pick; plain sam_vit_h_4b8939.pth is described as "lower boundary quality."

    Inputs: model (dropdown of your models/sam/ files), version (auto-detect / SAM 1 / SAM 2), sam1_arch (auto-detect / vit_h / vit_l / vit_b), device (auto / cuda / cpu). Output: sam_model.

    The tooltip on device is a warning in its own right: "SAM models are large; CPU inference is very slow." Don't run SAM on CPU unless you're desperate. And a reality check from the KB's SAM panel: SAM 1 and SAM 2 are Apache 2.0 - that permissiveness is exactly why they remain the default masking backbone even after SAM 3 (which is not Apache) landed. This loader only handles SAM 1 and 2, so if your masker expects a SAM 3 model, this isn't the node.

    Installing it

    Install the pack, then do the SAM-specific work:

    1. Pack: ComfyUI Manager β†’ search Frog Node Pack β†’ install, or cd ComfyUI/custom_nodes && git clone https://github.com/RabbitThatIsPink/FrogNodePack, then restart + hard-refresh.
    2. Python deps for SAM 1: pip install segment-anything-hq
    3. Python deps for SAM 2: git clone https://github.com/facebookresearch/sam2 && cd sam2 && pip install -e .
    4. Checkpoints into ComfyUI/models/sam/ - sam_hq_vit_h.pth (2.57 GB) for SAM 1, sam2.1_hiera_large.pt (898 MB) for SAM 2.

    Common issues

    Almost every failure is one of the three installs above. Load error mentioning "config" or "hydra" β†’ sam2 wasn't installed with -e .. Import error on segment_anything β†’ the SAM 1 package is missing (or you installed both segment-anything and segment-anything-hq, which the source warns conflict). Dropdown showing only "none" β†’ no .pth/.pt file in ComfyUI/models/sam/. And remember the README tags this node WIP - Unstable, so if the load succeeds but downstream masking misbehaves, that's the pack being honest about the feature's maturity - the auto-detection is genuinely filename-dependent, and the override dropdowns are your escape hatch.

    Category🐸 Node Pack

    Inputs (4)

    NameTypeDefaultDescription
    modelCOMBOCheckpoint file from ComfyUI/models/sam/
    versionCOMBOauto-detectauto-detect reads the filename. Override only if the filename doesn't follow the standard naming.
    sam1_archCOMBOauto-detectSAM 1 only. Ignored for SAM 2.
    deviceCOMBOautoauto β†’ CUDA if available, else CPU. SAM models are large; CPU inference is very slow.

    Outputs (1)

    NameTypeDescription
    sam_modelSAM_MODELβ€”