ComfyUI-RefineNode
ComfyUI-RefineNode provides a small set of model-agnostic ComfyUI nodes for local repainting, detail repair, product/logo/text refinement, and paste-back compositing.
RefineAnything targets region-specific image refinement: given an input image and a user-specified region (e.g., scribble mask or bounding box), it restores fine-grained details--text, logos, thin structures--while keeping all non-edited pixels unchanged. It supports both reference-based and reference-free refinement.
Installation
Clone this repository into your ComfyUI custom_nodes directory:
cd ComfyUI/custom_nodes
git clone https://github.com/1Kynx/ComfyUI-RefineNode.git
Restart ComfyUI after installation.
Example Workflows
The included example workflows use the Qwen Image Edit model together with the RefineAnything LoRA.
RefineAnything LoRA: limuloo1999/RefineAnything
You can try different options in the Edit Model Reference Method node, but it is best to avoid index_timestep_zero because it can introduce a noticeable color shift.
example_workflows/Reference-based Logo Refinement.json
- Reference-based workflow for refining logos, text, or product details with a clean reference image.
- In reference-based mode, connect the target refinement image to
image1, the reference image toimage2, and the target refinement mask/spatial mask image toimage3.
example_workflows/Reference-free Text Refinement.json
- Reference-free workflow for refining local text details from the target image and mask only.
Node Details
RefineNode Preprocess Mask
Prepares the target image and optional mask before model inference, and creates the info data required for accurate paste-back.
Inputs:
image: The image to refine or use as a reference.mask: Optional mask. If disconnected, the node uses an empty mask and does not raise an error.focus_crop: When enabled, crops around the masked region to reduce unrelated image area before generation.focus_crop_margin: Extra context retained around the mask crop.spatial_prompt_source: Controls thespatial_mask_imageoutput.maskkeeps the original mask shape, whilebboxuses the mask bounding box.combined_mask: When disabled, a multi-maskMASKinput is expanded into separate image-list refinement jobs. This also splits disconnected painted mask islands from a singleLoad Imagemask. When enabled, all masks for each source image are combined into one union mask before preprocessing.
Outputs:
image: Processed model input image.spatial_mask_image: Spatial mask image for image-editing nodes such as Qwen Image Edit Plus.mask: Mask aligned with the outputimage.info: Metadata containing the original image, crop position, mask, and paste-back coordinates. Pass this to downstream paste-back nodes.
Multi-mask behavior:
- With
combined_maskdisabled, one input image plus multiple masks becomes an image list: one refinement job per mask or disconnected painted mask island. - With
combined_maskenabled, multiple masks are merged first and only one refinement job is created per source image.
RefineNode Reference Image Process
Resizes and aligns the target image, reference image, and mask image to exactly the same size. This is useful for multi-image reference workflows and Qwen Image Edit Plus style inputs.
Inputs:
image1: Required. Usually the target refinement image.image2: Optional. Usually the reference image.image3: Optional. In reference-based mode, usually the target refinement mask orspatial_mask_image.info: OptionalREFINENODE_INFOfromRefineNode Preprocess Mask. When connected, the node records its resize, crop, or fill transform soRefineNode Paste Backcan restore the generated image to the correct original position.fit_kontext_size: When enabled, uses the ComfyUI/Flux Kontext-style target size. When disabled, uses an approximately1024 x 1024target area rounded to multiples of 8.resize_method: Shared resize method for all connected images. The default islanczos.crop_mode:cropcenter-crops to the target aspect ratio,disableresizes directly, andfillpreserves aspect ratio then pads with black to the target size.
Outputs:
image1: Processed target refinement image.image2: Processed reference image. If the input is disconnected, this output is a blank placeholder image.image3: Processed mask image or third reference image. If the input is disconnected, this output is a blank placeholder image.info: Updated paste-back metadata.
When image1 or image3 comes from a multi-mask RefineNode Preprocess Mask image list, ComfyUI processes each list item sequentially. A single connected reference image in image2 is reused for all list items.
Reference-based mode reminder:
- Connect the target refinement image to
image1. - Connect the reference image to
image2. - Connect the target refinement mask/spatial mask image to
image3.
RefineNode Paste Back
Composites the generated result back into the original image and returns both the final image and the actual paste mask.
Inputs:
generated_image: Image generated by the model.info: Paste-back metadata fromRefineNode Preprocess MaskorRefineNode Reference Image Process.paste_back_mode:maskpastes using the original mask, whilebboxpastes using the mask bounding box.mask_grow: Expands the paste mask before compositing. Useful for reducing tiny uncovered edges.blend_blur: Blurs and feathers the paste mask to soften seams.
Outputs:
image: Final pasted-back image.paste_mask: Actual mask used for compositing, useful for previewing and debugging the paste area.
When generated_image and info arrive as ComfyUI lists, all generated refinement results that belong to the same original source image are pasted back sequentially into that original image. The node returns one final image and one combined paste mask per source image.
Citation
If you use this repository, please cite:
@article{zhou2026refineanything,
title={RefineAnything: Multimodal Region-Specific Refinement for Perfect Local Details},
author={Zhou, Dewei and Li, You and Yang, Zongxin and Yang, Yi},
journal={arXiv preprint arXiv:2604.06870},
year={2026}
}

