SAM Mask Generator (SAM3 v0.3)
SAM3's text-prompt masks, without the repaint
- image
- mask
- mask_preview
- debug_info
If the Smart Inpainter in this pack is the one-stop detect-and-fix node, this is just the detection half. You feed it an image, type face, and it hands you a mask - no diffusion, no blending, no checkpoint required. You take that mask and do something else with it.
Honestly, that's the more flexible node of the two. Three jobs where it shines:
- Preview before you commit. Run this first to see exactly what SAM3 would select before you burn a full inpaint pass. The
mask_previewoutput is white-on-black, so coverage is visible at a glance. - Drive any other inpaint pipeline. Wire
maskinto whatever mask-based workflow you already trust - a plain inpaint node, Set Latent Noise Mask, or Impact Pack tooling. You get SAM3's text-prompt segmentation feeding a system you know, instead of adopting the whole smart-inpaint stack at once. - Mask math beyond inpainting. Selecting a logo, a scarf, or a background object for compositing. With
invert_maskyou get "everything except the face" in one click, which is a handy trick for keeping a subject untouched while everything else gets edited.
How it works
The mechanism is the same engine as the pack's bigger node: the sam3 Python package turns your prompt into masks, text_threshold filters out low-confidence hits, and if the prompt finds nothing it falls back to a point prompt at the image center. Note it's the trimmed version - it doesn't carry the face_region/custom fallback options the Smart Inpainter has, just center. After that it applies the same cleanup chain: erosion, dilation, gaussian blur, optional invert. No crop, no upscale, no sampling. In and out in a fraction of the time of a repaint pass.
Inputs that matter
prompt- multiline, default"face". This is the whole game: the mask is only as good as the words.text_threshold- default 0.35. Lower it (toward 0.25) to catch smaller or more ambiguous things; raise it if you're getting extra junk in the mask.mask_blur,mask_dilation,mask_erosion- edge cleanup. If the mask has holes, add dilation; if it bleeds past the object, erosion.invert_mask- flips the selection. Off by default.device-auto/cuda/cpu/mps.autois fine unless you specifically want to force CPU or MPS.
The sam_model dropdown and the model-file requirement are identical to the parent node - same list, same models/sam3/ folder, same <no models found> failure mode if the weight is missing.
Three outputs: mask (a proper MASK you wire into any MASK input), mask_preview (the same thing as an IMAGE you can actually look at), and debug_info (a STRING with coverage percentage and any reasons the prompt came up empty).
Installing it
Same pack, same install as its sibling. ComfyUI Manager (search SAM3 Smart Inpainter) or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/majidfida/SAM3_SmartInpainter.git
pip install -r SAM3_SmartInpainter/requirements.txt
The critical dependency is the wrapper that provides the sam3 package - install ComfyUI-Easy-Sam3 (git clone https://github.com/yolain/ComfyUI-Easy-Sam3.git) or ComfyUI-RMBG, then put sam3.pt in ComfyUI/models/sam3/. No wrapper, no mask: you'll get a runtime "sam3 package not found" error.
Gotchas
- Same wrapper dependency as the big node - that's the one install step people skip, and it fails at runtime, not install time.
- It doesn't crash on an empty result. If the prompt finds nothing, you get a zero mask plus an explanation in
debug_infoinstead of a hard failure mid-workflow. That's friendlier than most segmentation nodes, though you should still readdebug_infowhen the mask looks wrong. - There's no repaint here. If you wire this up expecting the image to change, you've got the wrong node for the job - take the
maskand feed it into an inpaint node. Remember the author's caveat from the README: the repo isn't monitored, so treat it as community-shared as-is.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| sam_model | COMBO | 1 options: <no models found> | |
| prompt | STRING | face | — |
| text_thresholdopt | FLOAT | 0.350.05–0.95 | — |
| mask_bluropt | INT | 60–64 | — |
| mask_dilationopt | INT | 40–64 | — |
| mask_erosionopt | INT | 00–32 | — |
| invert_maskopt | BOOLEAN | false | — |
| deviceopt | COMBO | auto | 4 options: auto, cuda, cpu, mps |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |
| mask_preview | IMAGE | — |
| debug_info | STRING | — |