From ddec938cde47cc229732b3846c7fa4cdd1f48d48 Mon Sep 17 00:00:00 2001 From: MagicBear Date: Fri, 4 Jul 2025 02:34:01 +0800 Subject: [PATCH] fix(comfy_extras): Fix OOM Tile --- comfy_extras/nodes_upscale_model.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/comfy_extras/nodes_upscale_model.py b/comfy_extras/nodes_upscale_model.py index d17da8514..199c83d33 100644 --- a/comfy_extras/nodes_upscale_model.py +++ b/comfy_extras/nodes_upscale_model.py @@ -87,14 +87,18 @@ class ImageUpscaleWithModel: pbar = comfy.utils.ProgressBar(steps) s = comfy.utils.tiled_scale(in_img, parallel_model, tile_x=tile, tile_y=tile, overlap=overlap, upscale_amount=upscale_model.scale, pbar=pbar, output_device=device) oom = False + except torch.OutOfMemoryError as e: + tile //= 2 + if tile < 128: + raise e except model_management.OOM_EXCEPTION as e: tile //= 2 if tile < 128: raise e upscale_model.to("cpu") - s = torch.clamp(s.movedim(-3,-1), min=0, max=1.0) s.to("cpu") + s = torch.clamp(s.movedim(-3,-1), min=0, max=1.0) return (s,) NODE_CLASS_MAPPINGS = {