SAMLoader (Pipe)
Load a SAM segmentation model as a ready-to-use pipe
- sam_pipe
If you do any detail-fixing - FaceDetailer-style detect-crop-refine passes - you know the loop: a detector finds a region, SAM (Segment Anything Model) turns that rough box into a clean mask, and a fresh sampling pass repaints it. easy samLoaderPipe loads the SAM half of that and bundles it, plus its segmentation settings, into a single pipe you hand to Easy-Use's detailer nodes.
This is Easy-Use wrapping the SAMLoader concept from ltdrdata's Impact Pack - the pack that made automatic detail refinement standard practice in ComfyUI. Easy-Use re-exposes it in "pipe" form so the loader and all its knobs travel down one wire instead of cluttering your detailer node.
How it works
SAM takes an image plus a hint (a point, a box, a rough mask) and produces a precise segmentation mask. This node loads the SAM checkpoint and pre-packs the hint strategy and threshold settings into a sam_pipe. Downstream, the detailer feeds it the region a detector found, and SAM tightens it into a mask worth repainting.
The inputs and outputs that matter
Most people set two things and leave the rest:
model_name- the SAM checkpoint (e.g.sam_vit_b_01ec64.pth). This has to be downloaded and present or the dropdown is empty.sam_detection_hint- how SAM is told where to look:center-1,rect-4,mask-area, and so on.center-1(a single center point) is a fine default for tidy single-subject regions.
The finer dials - sam_threshold (default 0.93, how confident a pixel must be to count), sam_dilation (grow/shrink the mask edge), sam_bbox_expansion, device_mode (AUTO / Prefer GPU / CPU) - are there when you need them, but the defaults are sensible. Output is a single sam_pipe (PIPE_LINE); wire it into an Easy-Use detailer.
How to install it
ComfyUI Manager: search ComfyUI-Easy-Use, install, restart. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/yolain/ComfyUI-Easy-Use
then install.bat / pip install -r requirements.txt, restart. You need a SAM model file - download a SAM checkpoint (the ViT-B one is the small, fast default) into ComfyUI's models/sams folder so model_name can find it.
Common issues & troubleshooting
model_name dropdown is empty. No SAM checkpoint installed, or it's in the wrong folder. Put a .pth SAM file in models/sams and restart.
Masks are ragged or grab too much. Nudge sam_threshold up for a tighter, more conservative mask, or use sam_dilation to shrink (negative) or pad (positive) the edge. If SAM keeps segmenting the wrong thing, switch the sam_detection_hint - center-1 assumes the subject is central; mask-area or rect-4 behave differently.
Slow on CPU. device_mode defaults to AUTO; force Prefer GPU if SAM is running on CPU and dragging your detailer pass.
Bigger SAM models are overkill here. ViT-B is plenty for face/hand detailing and much lighter than ViT-H. Unless you're segmenting genuinely tricky scenes, don't pay the memory cost of the huge checkpoints.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| model_name | COMBO | 1 options: sam_vit_b_01ec64.pth | |
| device_mode | COMBO | AUTO | 3 options: AUTO, Prefer GPU, CPU |
| sam_detection_hint | COMBO | 9 options: center-1, horizontal-2, vertical-2, rect-4, diamond-4, mask-area, +3 | |
| sam_dilation | INT | 0-512–512 | — |
| sam_threshold | FLOAT | 0.930–1 | — |
| sam_bbox_expansion | INT | 00–1000 | — |
| sam_mask_hint_threshold | FLOAT | 0.700–1 | — |
| sam_mask_hint_use_negative | COMBO | 3 options: False, Small, Outter |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| sam_pipe | PIPE_LINE | — |