From 945a8aa9632a33b05d50f6a00242a3193e737036 Mon Sep 17 00:00:00 2001 From: asagi4 <130366179+asagi4@users.noreply.github.com> Date: Mon, 1 Jul 2024 13:11:28 +0300 Subject: [PATCH] Resize control if there is a tensor size mismatch Fixes PatchModelAddDownscale when used with controlnets, and possibly some other nodes doing similar things as well. Fixes #3022 --- comfy/ldm/modules/diffusionmodules/openaimodel.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/comfy/ldm/modules/diffusionmodules/openaimodel.py b/comfy/ldm/modules/diffusionmodules/openaimodel.py index ba8fc2c4..31f2df01 100644 --- a/comfy/ldm/modules/diffusionmodules/openaimodel.py +++ b/comfy/ldm/modules/diffusionmodules/openaimodel.py @@ -358,6 +358,8 @@ def apply_control(h, control, name): ctrl = control[name].pop() if ctrl is not None: try: + if ctrl.shape[2] != h.shape[2] or ctrl.shape[3] != h.shape[3]: + ctrl = F.interpolate(ctrl.float(), size=(h.shape[2], h.shape[3]), mode="bicubic", align_corners=False).to(h.dtype) h += ctrl except: logging.warning("warning control could not be applied {} {}".format(h.shape, ctrl.shape))