Skip to content

Commit b1f358c

Browse files
authored
Merge pull request #235 from germanch90/main
Apply fix for ControlNet conditioning to match changes from ComfyUI lowering VRAM usage
2 parents da254b7 + f980ae7 commit b1f358c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

adv_control/control.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import torch
44
import os
55

6+
import comfy.model_base
67
import comfy.ops
78
import comfy.utils
89
import comfy.model_management
@@ -108,13 +109,13 @@ def sliding_get_control(self, x_noisy: Tensor, t, cond, batched_number, transfor
108109
for c in self.extra_conds:
109110
temp = cond.get(c, None)
110111
if temp is not None:
111-
extra[c] = temp.to(dtype)
112+
extra[c] = comfy.model_base.convert_tensor(temp, dtype, x_noisy.device)
112113

113114
timestep = self.model_sampling_current.timestep(t)
114115
x_noisy = self.model_sampling_current.calculate_input(t, x_noisy)
115116
self.x_noisy_shape = x_noisy.shape
116117

117-
control = self.control_model(x=x_noisy.to(dtype), hint=self.cond_hint, timesteps=timestep.to(dtype), context=context.to(dtype), **extra)
118+
control = self.control_model(x=x_noisy.to(dtype), hint=self.cond_hint, timesteps=timestep.to(dtype), context=comfy.model_management.cast_to_device(context, x_noisy.device, dtype), **extra)
118119
return self.control_merge(control, control_prev, output_dtype=None)
119120

120121
def pre_run_advanced(self, *args, **kwargs):

0 commit comments

Comments
 (0)