Nodes/ComfyUI-Apt_Preset/Stack_pre_Mark2
ComfyUI Node

Stack_pre_Mark2

Mask Shaping, Growing, and Range Remapping Before You Use It

By cardenluoĀ·Created 2 years agoĀ·Updated 18 days agoĀ· 309
Stack_pre_Mark2
    • mask_stack
    ā—„mask_modefillā–ŗ
    ā—„smoothness0ā–ŗ
    ā—„mask_expand0ā–ŗ
    ā—„mask_min0.00ā–ŗ
    ā—„mask_max1.00ā–ŗ

    A mask straight out of a segmentation model or a manual paint is rarely exactly what you want to feed into an inpaint or compositing step. It's got hard edges, it might be a bit too tight or too loose around the subject, and its values run 0-1 when you actually wanted something clamped to a narrower range. Stack_pre_Mark2 is a preprocessing config for exactly that gap - it doesn't take a mask input itself, it defines a bundle of mask-shaping settings (mask_stack) that a downstream node applies to whatever mask you actually feed it later in the graph.

    What each setting does. mask_mode picks how the mask gets rendered before use: original leaves it alone, fill/fill_block render it as a solid region (block presumably meaning a coarser, blockier fill rather than pixel-precise), outline/outline_block draw just the border, and circle/outline_circle reduce it to a circular approximation - handy when you want a rough "area of interest" marker rather than the mask's true, possibly jagged silhouette. mask_expand grows or shrinks the mask in pixels - negative values erode it inward, positive values dilate it outward, useful for giving an inpaint region a little breathing room so the edit doesn't leave a visible seam right at the original mask boundary. smoothness feathers the edges (0-150) for the same reason. mask_min/mask_max remap the mask's value range - instead of the usual 0 (nothing) to 1 (full strength), you can clamp it to, say, 0.2-0.8, which is a way of capping how strongly a mask can ever apply without needing to touch the mask's actual pixel data.

    Output: mask_stack, typed MASK_STACK2 - a config bundle for the pack's own downstream nodes, not a raw ComfyUI MASK.

    Installing it. Standard pack install: cd ComfyUI/custom_nodes && git clone https://github.com/cardenluo/ComfyUI-Apt_Preset, restart, or search "ComfyUI-Apt_Preset" in ComfyUI Manager. Windows users should double-click install.bat after cloning to pull in the pack's Python dependencies - this node itself needs nothing exotic, but running it once is the safe default for this pack given how many other nodes in it do.

    Troubleshooting. The single most common confusion with a config-only node like this is forgetting it does nothing on its own - if your mask isn't changing downstream, check that the consuming node actually has mask_stack wired in; this node produces no visual output by itself to sanity-check against. If your inpaint edits are bleeding past where you wanted them, mask_expand set positive is the usual suspect - dial it back toward zero or negative. If an edit looks half-strength when you expected full commitment, check mask_max isn't clamped below 1.0 - that's easy to leave at a partial value from experimenting and forget about. And if mask_mode is set to one of the circle/block variants and your careful hand-painted mask suddenly looks like a crude blob, that's expected behavior, not a bug - those modes intentionally discard your mask's real shape in favor of a coarser approximation, so switch back to original if you need the precise silhouette preserved.

    CategoryApt_Preset/stack/😺backup

    Inputs (5)

    NameTypeDefaultDescription
    mask_modeCOMBOfill7 options: original, fill, fill_block, outline, outline_block, circle, +1
    smoothnessINT00–150—
    mask_expandINT0-500–1000—
    mask_minFLOAT0.00-10–1—
    mask_maxFLOAT1.000–10—

    Outputs (1)

    NameTypeDescription
    mask_stackMASK_STACK2—