Nodes/Orion4D_AutoCachedPreview/Auto Cached Preview (Image + Mask)
ComfyUI Node

Auto Cached Preview (Image + Mask)

Cache an image so post-processing runs in seconds, not minutes

By orion4d·Created 4 months ago·Updated 3 months ago· 4
Auto Cached Preview (Image + Mask)
  • image
  • mask
  • image
  • mask
fallback_to_cachetrue

You finally got the image right - good seed, good prompt, KSampler just burned a minute of your GPU. And now you want to tweak the upscale, or the color grade, or paint over a detail with an inpaint mask. In plain ComfyUI that means re-running the sampler every single time, because everything upstream is still wired in. This node is the fix: it snapshots the image (and its mask) to disk, so you can unplug the sampler entirely and keep the downstream half of your workflow as the only thing that computes.

It's a small idea, and that's its whole appeal. Orion4D's Auto Cached Preview (Image + Mask) sits in the graph as a glorified preview node - until you disconnect its image input. Then it stops previewing and starts replaying the last image it saw, straight from a cache file on disk. Upstream never runs again. People call it the "unplug-to-freeze" workflow: connect, generate, unplug, and from then on only your post-processing nodes execute.

How it actually works

Under the hood it's a lot less magic than the demo looks. Every time the node runs with an image connected, it saves the image and mask tensors as a .pt file (plus a small JSON meta file) in ComfyUI's temp folder under AutoCachedPreview. It also writes a PNG preview - with your full prompt and workflow embedded as PNG Info, so the preview still drags back into ComfyUI and reconstructs your graph.

When image is disconnected and fallback_to_cache is on, it just torch.loads that .pt and feeds it downstream. A custom IS_CHANGED fingerprint (file mtimes and sizes) forces ComfyUI to re-evaluate the node after paste/clear actions, so it never serves you a stale output because the file changed outside the graph.

One thing to internalize: the cache lives in ComfyUI's temp folder, and the pack's __init__.py wipes that folder on every startup. This is a working cache, not storage. Restart ComfyUI and the freeze is gone - the node still works, but you'll need to regenerate and re-disconnect.

The inputs that matter

There are only three, and you set one.

  • fallback_to_cache (BOOLEAN, default True) - the whole behavior switch. With it on, a disconnected image input falls back to the cache. With it off and no image, the node raises an error rather than guessing. Leave it on.
  • image (optional) - wire your KSampler or VAE Decode output here to populate the cache.
  • mask (optional) - a mask tensor. If you leave it out, the node derives one from the image's alpha channel (or emits an empty mask). Handy when you paste in a PNG with transparency and want the transparent region as your inpaint target.

Outputs are image and mask - that's what you wire into your upscaler, color-grading block, or inpaint composite. Two buttons live on the node too: Paste image (drops your system clipboard image straight into the cache, alpha channel becoming the mask) and Clear cache (nukes the files and the preview). Those were literally requested in the node's announcement thread and shipped in v1.1.

Install

No models, no CUDA-version roulette, no requirements.txt drama - this pack depends only on torch, numpy and PIL, which ComfyUI already ships. Install via ComfyUI Manager (search "Orion4D AutoCachedPreview"), or:

cd ComfyUI/custom_nodes
git clone https://github.com/orion4d/Orion4D_AutoCachedPreview

Restart ComfyUI. It shows up under Orion4D_image/preview as "Auto Cached Preview (Image + Mask)".

Where people get burned

  • No cache yet + input disconnected = hard error. If you unplug before ever running it with an image connected, there's nothing to fall back to. Run once, then unplug.
  • Restart wipes the freeze. Remember the temp-folder cleanup. If you're mid-edit and restart, the cache is gone and you're regenerating.
  • Don't confuse it with Impact Pack's Preview Bridge. This gets asked every time the node shows up. Preview Bridge exists so you can pause and hand-paint a mask mid-workflow; this node exists so you can stop recomputing the sampler. Different jobs, and if you're mainly after mask editing, Preview Bridge is the one you want.

It's a quality-of-life node, not a heavy-hitter pack - but if you iterate on post-processing a single image at a time, it quietly saves you hours. Freeze the sampler, tweak in real time, done.

CategoryOrion4D_image-preview

Inputs (3)

NameTypeDefaultDescription
fallback_to_cacheBOOLEANtrue
imageoptIMAGE
maskoptMASK

Outputs (2)

NameTypeDescription
imageIMAGE
maskMASK