linoyts HF staff commited on
Commit
245673c
1 Parent(s): f0f7887

Update clip_slider_pipeline.py

Browse files
Files changed (1) hide show
  1. clip_slider_pipeline.py +3 -3
clip_slider_pipeline.py CHANGED
@@ -454,13 +454,13 @@ class T5SliderFlux(CLIPSlider):
454
  dtype = self.pipe.text_encoder_2.dtype
455
  prompt_embeds = prompt_embeds.to(dtype=dtype, device=self.device)
456
  print("1", prompt_embeds.shape)
457
- if avg_diff_2nd and normalize_scales:
458
  denominator = abs(scale) + abs(scale_2nd)
459
  scale = scale / denominator
460
  scale_2nd = scale_2nd / denominator
461
  if only_pooler:
462
  prompt_embeds[:, toks.argmax()] = prompt_embeds[:, toks.argmax()] + avg_diff * scale
463
- if avg_diff_2nd:
464
  prompt_embeds[:, toks.argmax()] += avg_diff_2nd * scale_2nd
465
  else:
466
  normed_prompt_embeds = prompt_embeds / prompt_embeds.norm(dim=-1, keepdim=True)
@@ -475,7 +475,7 @@ class T5SliderFlux(CLIPSlider):
475
  prompt_embeds = prompt_embeds + (
476
  weights * avg_diff * scale)
477
  print("2", prompt_embeds.shape)
478
- if avg_diff_2nd:
479
  prompt_embeds += (
480
  weights * avg_diff_2nd * scale_2nd)
481
 
 
454
  dtype = self.pipe.text_encoder_2.dtype
455
  prompt_embeds = prompt_embeds.to(dtype=dtype, device=self.device)
456
  print("1", prompt_embeds.shape)
457
+ if avg_diff_2nd is not None and normalize_scales:
458
  denominator = abs(scale) + abs(scale_2nd)
459
  scale = scale / denominator
460
  scale_2nd = scale_2nd / denominator
461
  if only_pooler:
462
  prompt_embeds[:, toks.argmax()] = prompt_embeds[:, toks.argmax()] + avg_diff * scale
463
+ if avg_diff_2nd is not None:
464
  prompt_embeds[:, toks.argmax()] += avg_diff_2nd * scale_2nd
465
  else:
466
  normed_prompt_embeds = prompt_embeds / prompt_embeds.norm(dim=-1, keepdim=True)
 
475
  prompt_embeds = prompt_embeds + (
476
  weights * avg_diff * scale)
477
  print("2", prompt_embeds.shape)
478
+ if avg_diff_2nd is not None:
479
  prompt_embeds += (
480
  weights * avg_diff_2nd * scale_2nd)
481