ComfyUI Node

Save & Reload Image

The PNG round-trip that doubles as a VRAM reset

By teepunkt-esspunkt·Created about a year ago·Updated about a year ago· 1
Save & Reload Image
  • image
  • reloaded_image
temp_folderoutput/temp
filenamebgstrip.png
also_save_permfalse
perm_folderoutput/saved

You're mid-workflow, watching it die on the first run: a heavy background remover like BiRefNet hands a big tensor to the sampler, the model weights load on top, and your 8GB card quietly returns to desktop. Save & Reload Image is a one-trick pony built for exactly that moment. It takes the incoming image, writes it to disk as a PNG, and immediately loads it back - so the pixels survive but the giant GPU tensor that produced them doesn't have to hang around during the sampler pass.

Let's be honest about what this is: it's duct tape, not a memory manager. ComfyUI holds intermediate outputs in cache while a graph runs, which is normally great - it's why a second pass of the same nodes is instant. But it means a preprocessor's output tensor can sit in VRAM at the same moment the sampler wants its weights loaded, and that double-occupancy is what tips a borderline card over. This node inserts a disk round-trip so the reloaded image arrives fresh and cheap, freeing the GPU to hold the model instead. The author built it after repeatedly hitting OOM between preprocessors and samplers, and the fix is exactly that: force the boundary.

A couple of details from the source make the trick work, and one or two might bite you.

The output is CPU, and that's the point. The node converts your tensor to a PIL image, saves the PNG, then loads it back as a fresh float tensor on CPU. Whatever VRAM the upstream output was pinning is released the moment the file hits disk. That's the whole mechanism, and it's why it genuinely lowers peak GPU usage rather than just feeling like it should.

Only the first image of a batch survives. The converter explicitly takes t[0] - if you feed it a batch of four frames, you get one PNG back with batch size 1. Fine for a single bg-removed image feeding a sampler; a trap if you point it at batched or video outputs. Alpha also gets dropped (RGBA → RGB), which is fine for diffusion reference but worth knowing if your upstream cared about transparency.

The inputs are the boring kind. image is what you wire in. temp_folder (default output/temp) and filename (default bgstrip.png) decide where the round-trip file lives - paths are resolved relative to your ComfyUI root and created if missing. also_save_perm is the checkbox that matters if you actually want the file kept, with perm_folder (default output/saved) as its destination. The temp file always overwrites, so it never accumulates junk; flip also_save_perm on only when you want a keeper. The single output, reloaded_image, is an IMAGE that plugs straight into whatever the preprocessor would have fed - usually your VAE encode or a sampler's conditioning path.

Installing it

No dependencies, no model downloads, nothing to torch your environment - this pack is pure Python using only the torch/numpy/Pillow that ComfyUI already ships. The README's two paths both work:

  • ComfyUI Manager → Install from URL and paste https://github.com/teepunkt-esspunkt/ComfyUI-SaveAndReload-Image
  • or the manual route:
cd ComfyUI/custom_nodes
git clone https://github.com/teepunkt-esspunkt/ComfyUI-SaveAndReload-Image.git

Restart ComfyUI and it shows up as Save & Reload Image in the IO category.

Where it helps, and where it doesn't

Use it between a heavy preprocessor and the sampler when first-run OOM strikes and you don't want to permanently downscale or offload. It's also a handy place to park an intermediate you want to reuse by hand later - flip also_save_perm and you've got a copy in output/saved.

But know its limits. The PNG round-trip costs a save + reload on every run and quantizes to 8-bit per channel - visually lossless for almost everything, not a precision pipeline. And if your card OOMs because the model itself doesn't fit, no amount of image reloading fixes that; that's a GGUF/fp8 quantization problem (see the VRAM levers in modidex's troubleshooting notes). Likewise, if you're seeing OOM on a card that should barely fit, try default memory flags before reaching for workarounds - a forced offload you don't need can be slower, not safer.

This is a small, honest utility that fixes one specific, maddening failure mode. Reach for it when peak memory is your problem and it'll quietly do its job; just don't ask it to solve every VRAM woe.

CategoryIO

Inputs (5)

NameTypeDefaultDescription
imageIMAGE
temp_folderSTRINGoutput/temp
filenameSTRINGbgstrip.png
also_save_permBOOLEANfalse
perm_folderSTRINGoutput/saved

Outputs (1)

NameTypeDescription
reloaded_imageIMAGE