Restore Crop Box V4 (Fast)
The fast PyTorch paste-back that makes video detail passes actually tolerable
- background_image
- croped_image
- crop_box
- croped_mask
- image
- mask
Restore Crop Box V4 is the same paste-back job as V3, but written the way video work actually needs it: fully in PyTorch, batching every frame in one vectorized pass instead of looping PIL conversions. The pack claims 10–100× speedup, and the mechanism backs that up - the entire blend happens as tensor math on one batch. For anything longer than a few frames, this is the restore node you actually reach for.
The other practical upgrade is forgiveness. V3 raises if your background and crop batches don't match exactly. V4 handles the two common mismatches gracefully, which matters when you're applying one refined frame to a whole clip.
Inputs and outputs
background_image(IMAGE) - the original frames, your canvas.croped_image(IMAGE) - the processed crop frames. If this is a single frame and the background is a batch, V4 repeats the crop across all frames - the standard "refine one frame, apply to the video" pattern - and logs a warning so you know that's what happened. Any other mismatch gets trimmed to the smaller batch with a warning.crop_box(BOX) - the[x1, y1, x2, y2]box, applied to every frame.feathering(INT, default0, range 0–256) - the paste-mask blur radius. The node's own recommendation is 30–60 for mid-resolution work; drop to 0 for hard composites.device(CPU/GPU, default GPU) - V4 defaults to GPU because the whole operation is tensor-based. On CPU it still runs, just slower.croped_mask(MASK, optional) - your own paste mask. If omitted it uses a full-white mask (everything pastes).
Outputs:
image(IMAGE) - the composited batch.mask(MASK) - the paste mask on the full canvas, showing where the blend happened.
Note there's no invert_mask here - V4 dropped the toggle (that's V3's job). If you need to flip your mask, do it upstream.
How it works
The paste is a weighted blend, not a literal paste. The cropped image (resized to the box dimensions if needed) is mixed into the background region by result = bg * (1 - mask) + crop * mask, with the mask feathered by a batched gaussian. Because everything is batched tensors on one device, a 120-frame clip is one operation instead of 120 PIL round-trips. Results are moved back to CPU at the end so the rest of your graph doesn't choke.
Install
In ComfyUI_Swwan. ComfyUI Manager → search "ComfyUI_Swwan", or:
cd ComfyUI/custom_nodes
git clone https://github.com/aining2022/ComfyUI_Swwan
cd ComfyUI_Swwan
pip install -r requirements.txt
Restart, then Restore Crop Box V4 (Fast) under Swwan/Image. Its output feeds straight into VideoCombine.
The gotchas
The auto-expand of a single crop frame is convenient and also the thing that will confuse you someday. If your upstream was supposed to process every frame but silently only produced one, V4 won't fail - it'll happily stamp that one result across the whole video and warn you. Read the warning. If you need per-frame processing, you have to go through Image Batch to Image List → process → Image List to Image Batch yourself; V4 can't do that for you.
Second, the mismatch handling trims silently-ish. When both batches exist but differ, V4 takes the minimum and warns - frames can disappear from the tail of your video without a hard error. V3 would have refused, which is annoying but safer. For a long render, sanity-check your frame counts.
Third, feathering at 0 is a hard edge. If you see a visible rectangle where the crop was pasted, bump the feather; at default 0 the node pastes as-is, and that's rarely what you want for a seam-free inpaint.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| background_image | IMAGE | — | |
| croped_image | IMAGE | — | |
| crop_box | BOX | — | |
| feathering | INT | 00–256 | — |
| device | COMBO | GPU | 2 options: CPU, GPU |
| croped_maskopt | MASK | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |