Skip to content

Commit

Permalink
fix to work with cfg scale=1
Browse files Browse the repository at this point in the history
  • Loading branch information
kohya-ss committed Nov 29, 2023
1 parent 764e333 commit 39bb319
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions sdxl_gen_img.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,8 @@ def __call__(
uncond_embeddings = tes_uncond_embs[0]
for i in range(1, len(tes_text_embs)):
text_embeddings = torch.cat([text_embeddings, tes_text_embs[i]], dim=2) # n,77,2048
uncond_embeddings = torch.cat([uncond_embeddings, tes_uncond_embs[i]], dim=2) # n,77,2048
if do_classifier_free_guidance:
uncond_embeddings = torch.cat([uncond_embeddings, tes_uncond_embs[i]], dim=2) # n,77,2048

if do_classifier_free_guidance:
if negative_scale is None:
Expand Down Expand Up @@ -567,9 +568,11 @@ def __call__(
text_pool = clip_vision_embeddings # replace: same as ComfyUI (?)

c_vector = torch.cat([text_pool, c_vector], dim=1)
uc_vector = torch.cat([uncond_pool, uc_vector], dim=1)

vector_embeddings = torch.cat([uc_vector, c_vector])
if do_classifier_free_guidance:
uc_vector = torch.cat([uncond_pool, uc_vector], dim=1)
vector_embeddings = torch.cat([uc_vector, c_vector])
else:
vector_embeddings = c_vector

# set timesteps
self.scheduler.set_timesteps(num_inference_steps, self.device)
Expand Down

0 comments on commit 39bb319

Please sign in to comment.