primerz commited on
Commit
7f5c816
·
verified ·
1 Parent(s): e1062d1

Update generator.py

Browse files
Files changed (1) hide show
  1. generator.py +2 -17
generator.py CHANGED
@@ -8,6 +8,7 @@ import cv2
8
  from PIL import Image
9
  import torch.nn.functional as F
10
  from torchvision import transforms
 
11
 
12
  from config import (
13
  device, dtype, TRIGGER_WORD, MULTI_SCALE_FACTORS,
@@ -676,7 +677,6 @@ class RetroArtConverter:
676
 
677
  except Exception as e:
678
  print(f"[ERROR] InsightFace detection failed: {e}")
679
- import traceback
680
  traceback.print_exc()
681
  else:
682
  print("[INFO] InsightFace not available (face_app is None)")
@@ -705,7 +705,6 @@ class RetroArtConverter:
705
  print("✗ MediapipeFace found no faces")
706
  except Exception as e:
707
  print(f"[ERROR] MediapipeFace detection failed: {e}")
708
- import traceback
709
  traceback.print_exc()
710
  else:
711
  print("[INFO] MediapipeFaceDetector not available")
@@ -781,7 +780,6 @@ class RetroArtConverter:
781
  print("[OK] Using Compel-encoded prompts")
782
  except Exception as e:
783
  print(f"Compel encoding failed, using standard prompts: {e}")
784
- import traceback
785
  traceback.print_exc()
786
  pipe_kwargs["prompt"] = prompt
787
  pipe_kwargs["negative_prompt"] = negative_prompt
@@ -840,20 +838,7 @@ class RetroArtConverter:
840
 
841
  combined_embeds = torch.cat([original_embeds, face_proj_embeds], dim=1)
842
  pipe_kwargs['prompt_embeds'] = combined_embeds
843
-
844
- # FIX: Also pad negative_prompt_embeds to match the new shape
845
- if 'negative_prompt_embeds' in pipe_kwargs:
846
- negative_embeds = pipe_kwargs['negative_prompt_embeds']
847
- # Create zero padding with same shape as face_proj_embeds
848
- padding = torch.zeros(
849
- (negative_embeds.shape[0], face_proj_embeds.shape[1], negative_embeds.shape[2]),
850
- device=negative_embeds.device,
851
- dtype=negative_embeds.dtype
852
- )
853
- pipe_kwargs['negative_prompt_embeds'] = torch.cat([negative_embeds, padding], dim=1)
854
- print(f" [OK] Negative prompt padded to match: {pipe_kwargs['negative_prompt_embeds'].shape}")
855
-
856
- print(f" [OK] Face embeddings concatenated successfully! Prompt: {combined_embeds.shape}, Negative: {pipe_kwargs['negative_prompt_embeds'].shape}")
857
  else:
858
  print(f" [WARNING] Can't concatenate - no prompt_embeds (use Compel)")
859
 
 
8
  from PIL import Image
9
  import torch.nn.functional as F
10
  from torchvision import transforms
11
+ import traceback
12
 
13
  from config import (
14
  device, dtype, TRIGGER_WORD, MULTI_SCALE_FACTORS,
 
677
 
678
  except Exception as e:
679
  print(f"[ERROR] InsightFace detection failed: {e}")
 
680
  traceback.print_exc()
681
  else:
682
  print("[INFO] InsightFace not available (face_app is None)")
 
705
  print("✗ MediapipeFace found no faces")
706
  except Exception as e:
707
  print(f"[ERROR] MediapipeFace detection failed: {e}")
 
708
  traceback.print_exc()
709
  else:
710
  print("[INFO] MediapipeFaceDetector not available")
 
780
  print("[OK] Using Compel-encoded prompts")
781
  except Exception as e:
782
  print(f"Compel encoding failed, using standard prompts: {e}")
 
783
  traceback.print_exc()
784
  pipe_kwargs["prompt"] = prompt
785
  pipe_kwargs["negative_prompt"] = negative_prompt
 
838
 
839
  combined_embeds = torch.cat([original_embeds, face_proj_embeds], dim=1)
840
  pipe_kwargs['prompt_embeds'] = combined_embeds
841
+ print(f" [OK] Face embeddings concatenated successfully! New shape: {combined_embeds.shape}")
 
 
 
 
 
 
 
 
 
 
 
 
 
842
  else:
843
  print(f" [WARNING] Can't concatenate - no prompt_embeds (use Compel)")
844