From c3f0e312c1f3abef99e1df6dbfdda9834ac991e9 Mon Sep 17 00:00:00 2001 From: James Walker Date: Wed, 30 Aug 2023 18:58:53 +0100 Subject: [PATCH] Make conditioning broadcasting more robust, allows t.shape[0] to be any non-zero value --- comfy/sample.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/comfy/sample.py b/comfy/sample.py index 79ea37e0d..f5b68954d 100644 --- a/comfy/sample.py +++ b/comfy/sample.py @@ -38,8 +38,10 @@ def broadcast_cond(cond, batch, device): copy = [] for p in cond: t = p[0] - if t.shape[0] < batch: - t = torch.cat([t] * batch) + if t.shape[0] != batch: + t_list = [t for _ in range(batch // t.shape[0])] + t_list.append(t[:batch % t.shape[0]]) + t = torch.cat(t_list) t = t.to(device) copy += [[t] + p[1:]] return copy