From 536d691a6b767f97c6a4f24efd4ab451e0e5e83f Mon Sep 17 00:00:00 2001 From: Jason Hoku Date: Wed, 4 Nov 2026 00:47:39 -0800 Subject: [PATCH] fix(upscale): keep @torch.inference_mode on seedvr2_upscale (the helper had slipped under the decorator) Co-Authored-By: Claude Fable 5.1 --- image_generation.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/image_generation.py b/image_generation.py index 1f0c925..17ec4c5 100644 --- a/image_generation.py +++ b/image_generation.py @@ -124,6 +124,17 @@ def _apply_model_patch_node(node_id, model, label=None, **kwargs): return model +def pil_to_image_array(pil_image): + """PIL image -> float32 numpy [1, H, W, 3] in [0, 1] (ComfyUI IMAGE layout, BHWC). + + Wrap in torch.from_numpy() for VAE.encode() / node inputs. Same conversion as + seedvr2_upscale() and the Florence2 inline branch use. Pure numpy, no inference. + """ + import numpy as np + arr = np.array(pil_image.convert("RGB")).astype(np.float32) / 255.0 + return arr[None, ...] + + # NOTE: torch.inference_mode() decorator — see module docstring above for why # this is REQUIRED on all out-of-graph inference entry points. Removing it # will reintroduce the same 6× VRAM blowup we fixed in May 2026. @@ -1207,17 +1218,6 @@ def flush_batch_with_remote_vae(pending_batch, remote_vae_worker, existing_data, # to SDXL KSampler. The CurrentNodeContext below sets up V3-API execution but # does NOT include inference_mode — that's our job at the function boundary. @torch.inference_mode() -def pil_to_image_array(pil_image): - """PIL image -> float32 numpy [1, H, W, 3] in [0, 1] (ComfyUI IMAGE layout, BHWC). - - Wrap in torch.from_numpy() for VAE.encode() / node inputs. Same conversion as - seedvr2_upscale() and the Florence2 inline branch use. - """ - import numpy as np - arr = np.array(pil_image.convert("RGB")).astype(np.float32) / 255.0 - return arr[None, ...] - - def seedvr2_upscale(pil_image, seedvr2_config): """ Upscale an image using SeedVR2 diffusion-based upscaler.