Spaces:
Running
on
Zero
Running
on
Zero
Update generator.py
Browse files- generator.py +8 -14
generator.py
CHANGED
|
@@ -22,18 +22,12 @@ class Generator:
|
|
| 22 |
|
| 23 |
# 3. Generate Prompt
|
| 24 |
if not user_prompt.strip():
|
| 25 |
-
|
| 26 |
-
if face_emb is not None:
|
| 27 |
generated_caption = get_caption(processed_image)
|
| 28 |
final_prompt = f"{Config.STYLE_TRIGGER}, {generated_caption}"
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 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 |
|
|
@@ -53,10 +47,7 @@ class Generator:
|
|
| 53 |
else:
|
| 54 |
print("No face detected: Disabling InstantID.")
|
| 55 |
controlnet_conditioning_scale = [0.0, 0.4, 0.4] # Disable InstantID weight
|
| 56 |
-
#
|
| 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
|
|
@@ -75,6 +66,9 @@ class Generator:
|
|
| 75 |
num_inference_steps=8,
|
| 76 |
guidance_scale=1.5,
|
| 77 |
|
|
|
|
|
|
|
|
|
|
| 78 |
).images[0]
|
| 79 |
|
| 80 |
return result
|
|
|
|
| 22 |
|
| 23 |
# 3. Generate Prompt
|
| 24 |
if not user_prompt.strip():
|
| 25 |
+
try:
|
|
|
|
| 26 |
generated_caption = get_caption(processed_image)
|
| 27 |
final_prompt = f"{Config.STYLE_TRIGGER}, {generated_caption}"
|
| 28 |
+
except Exception as e:
|
| 29 |
+
print(f"Captioning failed: {e}, using default prompt.")
|
| 30 |
+
final_prompt = f"{Config.STYLE_TRIGGER}, a beautiful pixel art image"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
else:
|
| 32 |
final_prompt = f"{Config.STYLE_TRIGGER}, {user_prompt}"
|
| 33 |
|
|
|
|
| 47 |
else:
|
| 48 |
print("No face detected: Disabling InstantID.")
|
| 49 |
controlnet_conditioning_scale = [0.0, 0.4, 0.4] # Disable InstantID weight
|
| 50 |
+
control_guidance_end = [0.5, 0.8, 0.8] # Set end to avoid 0.0 >= 0.0 error
|
|
|
|
|
|
|
|
|
|
| 51 |
self.mh.pipeline.set_ip_adapter_scale(0.0)
|
| 52 |
|
| 53 |
# 6. Run Inference
|
|
|
|
| 66 |
num_inference_steps=8,
|
| 67 |
guidance_scale=1.5,
|
| 68 |
|
| 69 |
+
# --- ADDED ---
|
| 70 |
+
clip_skip=2
|
| 71 |
+
|
| 72 |
).images[0]
|
| 73 |
|
| 74 |
return result
|