Nodes/ComfyUI-Apt_Preset/chx_Ksampler_Kontext_inpaint
ComfyUI Node

chx_Ksampler_Kontext_inpaint

Crop-and-stitch masked editing for Kontext — deprecated in the pack

By cardenluo·Created 2 years ago·Updated 22 days ago· 309
chx_Ksampler_Kontext_inpaint
  • context
  • image
  • mask
  • mask_stack
  • sample_stack
  • context
  • image
  • cropped_mask
  • cropped_image
◄seed0â–ș
◄prompt_weight0.50â–ș
◄denoise1.00â–ș
◄work_patternksamplerâ–ș
◄mask_samplingtrueâ–ș
◄crop_modeno_scale_cropâ–ș
◄long_side512â–ș
◄expand_width0â–ș
◄expand_height0â–ș
◄out_smoothness2â–ș
◄posâ–ș

Third and last of the Kontext samplers in this pack, and like the other two, it's filed under Apt_Preset's own "đŸš«DeprecatedđŸš«" category. If a saved workflow brought you here, treat that as a sign it was built before the pack's Kontext controller stack moved on - check the current README for what replaced it rather than starting new work on this node.

What it combines

This one is the masked-editing version of the Kontext sampler family - it merges chx_Ksampler_inpaint's crop-sample-stitch approach with Kontext's instruction-based editing. That pairing matters because it's actually the more capable way to run masked edits on an editing model: pointing a modern instruction editor at a whole frame tends to shift unmasked pixels slightly even when you didn't ask it to, because the model reasons about the entire image at once. Cropping to the masked region first, editing just that crop, and stitching the result back is how the wider community gets true "only this region changes" behavior out of editing models like Kontext, rather than accepting whole-frame drift as the cost of using one.

Same license reminder as its two siblings applies here regardless of deprecation status: Kontext's non-commercial license includes an anti-circumvention clause that's been actively enforced against NSFW derivatives. If that's a blocker for your use case, Qwen-Image-Edit is the unrestricted alternative the community moved to.

The inputs and outputs that matter

  • context, image, seed - required.
  • prompt_weight (default 0.5) and denoise (default 1) - instruction strength and how much of the masked region gets regenerated.
  • work_pattern (ksampler default, or only_adjust_mask) - the same cheap-preview mode as the pack's other crop-based inpaint sampler: use only_adjust_mask to dial in your crop and mask settings before committing to a full sampling pass.
  • mask_sampling (boolean, default true) - whether the mask actively constrains sampling, versus being used only for the final composite.
  • crop_mode, long_side (default 512), expand_width, expand_height, out_smoothness (default 2) - the same crop-and-feather controls as chx_Ksampler_inpaint: how the region gets cropped and scaled before editing, how much surrounding context to include, and how soft the seam is on the way back in.
  • Optional mask, pos (instruction text specific to the masked region), plus mask_stack/sample_stack for chaining the pack's other modifier stacks.

Outputs: context, the stitched image, and the intermediate cropped_mask/cropped_image - exposed the same way as the non-Kontext inpaint sampler, in case you want to inspect or further process just the working crop.

Installing it

Through ComfyUI Manager: search ComfyUI-Apt_Preset, install, restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/cardenluo/ComfyUI-Apt_Preset.git

then install.bat on Windows for dependencies, restart. Needs a Flux Kontext checkpoint, same as the other two Kontext samplers - not bundled with the pack.

Common issues

Given the deprecated status, expect rough edges. A node the author has moved past is less likely to get bug fixes if you hit an edge case. If something looks wrong and you can't tell whether it's your settings or the node itself, that's worth weighing before investing more time debugging it versus switching to whatever the pack's current README points at.

Unmasked pixels still shift slightly. If you're seeing this despite the crop-and-stitch approach, check mask_sampling is actually enabled and that your crop (crop_mode, expand_width/expand_height) isn't accidentally including area you meant to protect - a crop that's too generous can let edit drift creep back into pixels you wanted preserved.

Seam visible at the mask edge. Raise out_smoothness - 2 is a light default, and most inpainting-style edits need more feathering than that before the transition disappears.

CategoryApt_Preset/đŸš«Deprecated/đŸš«

Inputs (16)

NameTypeDefaultDescription
contextRUN_CONTEXT—
imageIMAGE—
seedINT00–18446744073709550000—
prompt_weightFLOAT0.500–1—
denoiseFLOAT1.000–1—
work_patternCOMBOksampler2 options: ksampler, only_adjust_mask
mask_samplingBOOLEANtrue—
crop_modeCOMBOno_scale_crop3 options: no_crop, no_scale_crop, scale_crop_image
long_sideINT51216–9999—
expand_widthINT00–2048—
expand_heightINT00–2048—
out_smoothnessINT20–150—
maskoptMASK—
posoptSTRING—
mask_stackoptMASK_STACK2—
sample_stackoptSAMPLE_STACK—

Outputs (4)

NameTypeDescription
contextRUN_CONTEXT—
imageIMAGE—
cropped_maskMASK—
cropped_imageIMAGE—