The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.
Make ImageUpscaleWithModel node work with intermediate device and dtype. (#13357)
comfyanonymousa2840e75520b
diff --git a/comfy_extras/nodes_upscale_model.py b/comfy_extras/nodes_upscale_model.pyindex db4f9d231..d3ee3f1c1 100644--- a/comfy_extras/nodes_upscale_model.py+++ b/comfy_extras/nodes_upscale_model.py@@ -6,6 +6,7 @@ import comfy.utilsimport folder_pathsfrom typing_extensions import overridefrom comfy_api.latest import ComfyExtension, io+import comfy.model_managementtry:from spandrel_extra_arches import EXTRA_REGISTRY@@ -78,13 +79,15 @@ class ImageUpscaleWithModel(io.ComfyNode):tile = 512overlap = 32+ output_device = comfy.model_management.intermediate_device()+oom = Truetry: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)+ s = comfy.utils.tiled_scale(in_img, lambda a: upscale_model(a.float()), tile_x=tile, tile_y=tile, overlap=overlap, upscale_amount=upscale_model.scale, pbar=pbar, output_device=output_device)oom = Falseexcept Exception as e:model_management.raise_non_oom(e)@@ -94,7 +97,7 @@ class ImageUpscaleWithModel(io.ComfyNode):finally:upscale_model.to("cpu")- s = torch.clamp(s.movedim(-3,-1), min=0, max=1.0)+ s = torch.clamp(s.movedim(-3,-1), min=0, max=1.0).to(comfy.model_management.intermediate_dtype())return io.NodeOutput(s)upscale = execute # TODO: remove