From 4e6abcaac718eba81a8d85ae3980600f84864a2d Mon Sep 17 00:00:00 2001 From: Haoming Date: Wed, 24 Dec 2025 17:41:50 +0800 Subject: [PATCH] padding --- backend/diffusion_engine/sdxl.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/backend/diffusion_engine/sdxl.py b/backend/diffusion_engine/sdxl.py index 036faa7a..879855f3 100644 --- a/backend/diffusion_engine/sdxl.py +++ b/backend/diffusion_engine/sdxl.py @@ -91,6 +91,11 @@ class StableDiffusionXL(ForgeDiffusionEngine): cond_l = torch.zeros_like(cond_l) cond_g = torch.zeros_like(cond_g) + # Ensure cond_l and cond_g have the same size + max_len = max(cond_l.shape[1], cond_g.shape[1]) + cond_l = torch.cat([cond_l, cond_l.new_zeros(cond_l.size(0), max_len - cond_l.shape[1], cond_l.size(2))], dim=1) + cond_g = torch.cat([cond_g, cond_g.new_zeros(cond_g.size(0), max_len - cond_g.shape[1], cond_g.size(2))], dim=1) + cond = dict( crossattn=torch.cat([cond_l, cond_g], dim=2), vector=torch.cat([clip_pooled, flat], dim=1),