primerz commited on
Commit
c82ccd6
·
verified ·
1 Parent(s): a92aea4

Update generator.py

Browse files
Files changed (1) hide show
  1. generator.py +17 -4
generator.py CHANGED
@@ -22,8 +22,18 @@ class Generator:
22
 
23
  # 3. Generate Prompt
24
  if not user_prompt.strip():
25
- generated_caption = get_caption(processed_image)
26
- final_prompt = f"{Config.STYLE_TRIGGER}, {generated_caption}"
 
 
 
 
 
 
 
 
 
 
27
  else:
28
  final_prompt = f"{Config.STYLE_TRIGGER}, {user_prompt}"
29
 
@@ -42,8 +52,11 @@ class Generator:
42
  self.mh.pipeline.set_ip_adapter_scale(0.9) # Set IP-Adapter (likeness) strength
43
  else:
44
  print("No face detected: Disabling InstantID.")
45
- controlnet_conditioning_scale = [0.0, 0.4, 0.4] # Disable InstantID
46
- control_guidance_end = [0.0, 0.8, 0.8]
 
 
 
47
  self.mh.pipeline.set_ip_adapter_scale(0.0)
48
 
49
  # 6. Run Inference
 
22
 
23
  # 3. Generate Prompt
24
  if not user_prompt.strip():
25
+ # Only get caption if face analysis didn't fail (to avoid double loading)
26
+ if face_emb is not None:
27
+ generated_caption = get_caption(processed_image)
28
+ final_prompt = f"{Config.STYLE_TRIGGER}, {generated_caption}"
29
+ else:
30
+ # If face analysis failed, we might be here, so try captioning
31
+ try:
32
+ generated_caption = get_caption(processed_image)
33
+ final_prompt = f"{Config.STYLE_TRIGGER}, {generated_caption}"
34
+ except Exception as e:
35
+ print(f"Captioning failed: {e}, using default prompt.")
36
+ final_prompt = f"{Config.STYLE_TRIGGER}, a beautiful pixel art image"
37
  else:
38
  final_prompt = f"{Config.STYLE_TRIGGER}, {user_prompt}"
39
 
 
52
  self.mh.pipeline.set_ip_adapter_scale(0.9) # Set IP-Adapter (likeness) strength
53
  else:
54
  print("No face detected: Disabling InstantID.")
55
+ controlnet_conditioning_scale = [0.0, 0.4, 0.4] # Disable InstantID weight
56
+ # --- START FIX ---
57
+ # Set end to 0.5 (matching the 'if' block) to avoid 0.0 >= 0.0 error
58
+ control_guidance_end = [0.5, 0.8, 0.8]
59
+ # --- END FIX ---
60
  self.mh.pipeline.set_ip_adapter_scale(0.0)
61
 
62
  # 6. Run Inference