Concatenate Context Window
The v2 composer for IC LoRA windows — this is the one to reach for
- first_image
- second_image
- second_mask
- IMAGE
- MASK
- target_width
- target_height
- x_offset
- y_offset
- total_width
- total_height
ConcatContextWindow is the modern replacement for the pack's older AddMaskForICLora, and it's the one you should build new workflows on. When lrzjason rebuilt this pack in late November 2024, this node came out of that rewrite: the same "compose the two-panel context window" job as its predecessor, but with explicit aspect-ratio control and cleaner handling of the second image and mask.
If you're not up on the genre: an in-context LoRA is trained on FLUX.1 Fill to take a composed image - reference subject on one side, empty patch on the other - and fill the patch with the subject. ConcatContextWindow assembles that composed image. Give it one image and it lays the reference into one panel, fills the other with a solid color, and produces the composed canvas plus the mask that tells the model where to generate.
How it works
first_image is fitted into the reference panel (resize, pad, or center-crop - whichever the target ratio demands), and second_image is optional; give it one and both panels get real content, leave it out and the second panel becomes a solid patch_color block. The panels are then concatenated with hstack (patch_right) or vstack (patch_bottom) per patch_mode. The output MASK is the part that actually matters: zero over the reference panel, one over the patch panel (or your second_mask) - exactly the "generate here, keep the rest" signal FLUX.1 Fill's masked conditioning wants.
The inputs that matter
- patch_mode -
auto(default) picks patch_right vs patch_bottom from your image's orientation. - patch_type -
3:4(default),1:1,9:16. This is the real upgrade over AddMaskForICLora, which can't set the panel ratio. Match it to the LoRA's training aspect. - output_length - 1536 default, silently snapped to a multiple of 64.
- patch_color - the hex filling the empty panel (
#FF0000default). Not cosmetic: IC LoRAs are often trained on a specific patch color, and a mismatch can bleed into the fill. - Optional
second_imageandsecond_maskfor the two-real-images variant.
Outputs
IMAGE and MASK feed straight into the Fill conditioning. Then the bookkeeping: x_offset/y_offset give the top-left of the patch panel inside the composed canvas - that's how a downstream ImageCompositeMasked knows where to paste the generated result back onto the original - and target_width/target_height/total_width/total_height describe the panel and full canvas.
How it sits in a real workflow
In the author's own "context window inpaint" example, this node feeds a Redux reference pass (StyleModelLoader + CLIPVisionEncode + StyleModelApply) plus InpaintModelConditioning into FLUX.1 Fill, and the offsets drive the composite back. That maps cleanly onto why this whole genre exists: FLUX.1 Fill is still the only open checkpoint actually trained for masked inpainting (the KB's inpainting essay hammers this), and these nodes just frame "reference one half, generate the other" in the way Fill is best at.
Installing it
One install gets you the whole pack:
cd ComfyUI/custom_nodes && git clone https://github.com/lrzjason/Comfyui-In-Context-Lora-Utils
then restart. Or ComfyUI Manager → search "Comfyui-In-Context-Lora-Utils". No pip deps in the pyproject - pure numpy/OpenCV - but the surrounding workflow needs FLUX.1 Fill, the T5 + CLIP-GmP encoders, the Flux VAE, Redux + SigLIP (all linked in the README), plus the in-context LoRA itself from Civitai.
Gotchas
Same family traits as the rest of the pack: DEBUG = True prints ===debug=== noise to the console on every run, only the first frame of a batch is processed, and it imports cv2 at module load (a bare ComfyUI env can throw ModuleNotFoundError: cv2 until you pip install opencv-python). And the honest 2026 note: instruction-edit models like Klein and Qwen-Image-Edit now do try-on and outpainting from a sentence, so this genre is aging - but for "reference this subject, generate its counterpart" with a stable identity and real positional control, it's still the cheapest and most predictable route.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| first_image | IMAGE | — | |
| patch_mode | COMBO | auto | 3 options: auto, patch_right, patch_bottom |
| patch_type | COMBO | 3:4 | 3 options: 3:4, 1:1, 9:16 |
| output_length | INT | 1536 | — |
| patch_color | COMBO | #FF0000 | 4 options: #FF0000, #00FF00, #0000FF, #FFFFFF |
| second_imageopt | IMAGE | — | |
| second_maskopt | MASK | — |
Outputs (8)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| MASK | MASK | — |
| target_width | INT | — |
| target_height | INT | — |
| x_offset | INT | — |
| y_offset | INT | — |
| total_width | INT | — |
| total_height | INT | — |