The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.
Fix case where upscale model wouldn't be moved to cpu. (#11633)
comfyanonymous38d049382533
diff --git a/comfy_extras/nodes_upscale_model.py b/comfy_extras/nodes_upscale_model.pyindex 4d62b87be..ed587851c 100644--- a/comfy_extras/nodes_upscale_model.py+++ b/comfy_extras/nodes_upscale_model.py@@ -78,18 +78,20 @@ class ImageUpscaleWithModel(io.ComfyNode):overlap = 32oom = True- while oom:- try:- steps = in_img.shape[0] * comfy.utils.get_tiled_scale_steps(in_img.shape[3], in_img.shape[2], tile_x=tile, tile_y=tile, overlap=overlap)- pbar = comfy.utils.ProgressBar(steps)- s = comfy.utils.tiled_scale(in_img, lambda a: upscale_model(a), tile_x=tile, tile_y=tile, overlap=overlap, upscale_amount=upscale_model.scale, pbar=pbar)- oom = False- except model_management.OOM_EXCEPTION as e:- tile //= 2- if tile < 128:- raise e-- upscale_model.to("cpu")+ try:+ while oom:+ try:+ steps = in_img.shape[0] * comfy.utils.get_tiled_scale_steps(in_img.shape[3], in_img.shape[2], tile_x=tile, tile_y=tile, overlap=overlap)+ pbar = comfy.utils.ProgressBar(steps)+ s = comfy.utils.tiled_scale(in_img, lambda a: upscale_model(a), tile_x=tile, tile_y=tile, overlap=overlap, upscale_amount=upscale_model.scale, pbar=pbar)+ oom = False+ except model_management.OOM_EXCEPTION as e:+ tile //= 2+ if tile < 128:+ raise e+ finally:+ upscale_model.to("cpu")+s = torch.clamp(s.movedim(-3,-1), min=0, max=1.0)return io.NodeOutput(s)