Nodes/JPS Custom Nodes for ComfyUI/InstantID Mask Prepare Settings (JPS)
ComfyUI Node

InstantID Mask Prepare Settings (JPS)

Getting the mask right before InstantID touches a face

By JPS-GER·Created 3 years ago·Updated 2 years ago· 100
InstantID Mask Prepare Settings (JPS)
    • imageprepare_settings
    mask_type
    resize_to
    resize_type
    offset_width0
    offset_height0
    crop_left0
    crop_right0
    crop_top0
    crop_bottom0
    padding_left0
    padding_right0
    padding_top0
    padding_bottom0
    interpolation
    sharpening0.00

    Before InstantID applies a face onto a generation, something upstream usually needs to decide where that's allowed to happen - a mask constraining the identity injection to a specific region rather than letting it influence the whole frame. This node is the settings hub for building that mask: where it comes from, how it's resized and positioned to match your target canvas, and a bit of cleanup on the way out. Like this pack's other Settings nodes, it doesn't do the mask work itself - pair it with the matching Pipe node and wire the unpacked values into whatever's actually generating and using the mask.

    What it's for, in context

    InstantID is the zero-shot, one-photo face adapter that made "do I even need a character LoRA anymore" a real question back in early 2024 - it reads an InsightFace ArcFace embedding for identity and adds a ControlNet-style module (IdentityNet) that conditions on facial landmarks, which is why it holds a face's geometry across poses better than a plain IP-Adapter FaceID does. It's an SDXL-family tool (works on Illustrious and Pony too, since they're SDXL underneath) with no Flux path - the ecosystem's identity role on Flux went to PuLID instead. Worth knowing up front if you're building this into anything commercial: InstantID's checkpoints are research-only and the InsightFace models underneath are non-commercial, so no amount of permissive licensing on the surrounding code changes that.

    The inputs that matter

    • mask_type - six options: No Mask, Mask Editor, Mask Editor (inverted), or pulling the mask from the Red, Green, or Blue channel of an image. That last trio is a cheap, deliberate trick: paint a mask into one color channel of a reference image in any editor and extract it here, rather than needing ComfyUI's mask editor for every pass.
    • resize_to - Resize to Target, Resize to Source, or Keep Size. Whether the mask gets scaled to match a target canvas, to match the source image's own dimensions, or left alone.
    • resize_type - Crop or Stretch, for how the resize actually happens when the aspect ratios don't match.
    • offset_width / offset_height (-99 to 99) and crop_left / crop_right / crop_top / crop_bottom (0–90) - fine positioning and cropping controls once the base resize choice is made.
    • padding_left / padding_right / padding_top / padding_bottom (0–500) - add blank space around the mask, useful if your target canvas is larger than the source and you need the mask centered within it rather than stretched to fill it.
    • interpolation (lanczos, nearest, bilinear, bicubic, area, nearest-exact) - the resize method. Nearest is usually the safer choice specifically for masks, since blending interpolation methods can introduce soft, gray edge pixels a binary mask shouldn't have.
    • sharpening (0–1, default 0) - a mild sharpen after resize, more relevant to the underlying image than the mask itself.

    Output: imageprepare_settings, typed BASIC_PIPE - JPS's own bundle (a plain tuple under the hood, unrelated to Impact Pack's object of the same type name), meant for a matching Pipe node.

    Installing it

    ComfyUI Manager: search JPS Custom Nodes for ComfyUI. Manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/JPS-GER/ComfyUI_JPS-Nodes.git
    

    Restart ComfyUI, removing any earlier copy of the pack first. This node itself needs no models, but the InstantID workflow it's built for does - an InstantID checkpoint, an InsightFace-based face model, and the ControlNet-shaped IdentityNet weights, none of which come from this pack. Get those from whichever InstantID node pack you're running (the reference implementation is InstantX/InstantID). This specific node is also newer than the pack's published README, so don't expect to find it in that document's list.

    Where people get tripped up

    If your mask isn't lining up with your target image, the fix is almost always resize_to/resize_type before it's the offset or crop values - get the base scaling behavior right first, then nudge with offsets. And remember interpolation choices like lanczos or bicubic can leave soft gray edges on what should be a hard-edged mask; if downstream behavior looks like the mask boundary is "leaking," try nearest instead. Beyond that, this node only prepares data - the actual InstantID application (loading the checkpoint, running IdentityNet, applying the mask) happens in separate nodes elsewhere in your graph.

    CategoryJPS Nodes/Settings

    Inputs (15)

    NameTypeDefaultDescription
    mask_typeCOMBO6 options: No Mask, Mask Editor, Mask Editor (inverted), Red from Image, Green from Image, Blue from Image
    resize_toCOMBO3 options: Resize to Target, Resize to Source, Keep Size
    resize_typeCOMBO2 options: Crop, Stretch
    offset_widthINT0-99–99
    offset_heightINT0-99–99
    crop_leftINT00–90
    crop_rightINT00–90
    crop_topINT00–90
    crop_bottomINT00–90
    padding_leftINT00–500
    padding_rightINT00–500
    padding_topINT00–500
    padding_bottomINT00–500
    interpolationCOMBO6 options: lanczos, nearest, bilinear, bicubic, area, nearest-exact
    sharpeningFLOAT0.000–1

    Outputs (1)

    NameTypeDescription
    imageprepare_settingsBASIC_PIPE