Spaces:
Running on Zero
Running on Zero
Make clip_skip best-effort (retry without it on version incompat)
Browse files- pipeline_manager.py +14 -4
pipeline_manager.py
CHANGED
|
@@ -255,6 +255,18 @@ def _face_embeds(image):
|
|
| 255 |
# ---------------------------------------------------------------------------
|
| 256 |
# Generation
|
| 257 |
# ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 258 |
def run_generation(cfg, mode, prompt, negative_prompt, ref_image,
|
| 259 |
steps, guidance, denoise, ip_scale, width, height, seed):
|
| 260 |
"""Run one generation. MUST be called inside a @spaces.GPU context."""
|
|
@@ -309,8 +321,7 @@ def run_generation(cfg, mode, prompt, negative_prompt, ref_image,
|
|
| 309 |
call.pop("width"); call.pop("height")
|
| 310 |
call["image"] = ref_image.convert("RGB")
|
| 311 |
call["strength"] = float(denoise)
|
| 312 |
-
|
| 313 |
-
return out
|
| 314 |
|
| 315 |
elif mode == "ip_adapter":
|
| 316 |
if ref_image is None:
|
|
@@ -327,5 +338,4 @@ def run_generation(cfg, mode, prompt, negative_prompt, ref_image,
|
|
| 327 |
embeds = _face_embeds(ref_image).to(DEVICE)
|
| 328 |
call["ip_adapter_image_embeds"] = [embeds]
|
| 329 |
|
| 330 |
-
|
| 331 |
-
return out
|
|
|
|
| 255 |
# ---------------------------------------------------------------------------
|
| 256 |
# Generation
|
| 257 |
# ---------------------------------------------------------------------------
|
| 258 |
+
def _safe_call(pipe_obj, call):
|
| 259 |
+
"""Run the pipeline; if clip_skip trips a version incompatibility, retry without it."""
|
| 260 |
+
try:
|
| 261 |
+
return pipe_obj(**call).images[0]
|
| 262 |
+
except (AttributeError, TypeError) as e:
|
| 263 |
+
if "clip_skip" in call:
|
| 264 |
+
print(f"[clip_skip] disabled for this run due to: {e}")
|
| 265 |
+
call.pop("clip_skip", None)
|
| 266 |
+
return pipe_obj(**call).images[0]
|
| 267 |
+
raise
|
| 268 |
+
|
| 269 |
+
|
| 270 |
def run_generation(cfg, mode, prompt, negative_prompt, ref_image,
|
| 271 |
steps, guidance, denoise, ip_scale, width, height, seed):
|
| 272 |
"""Run one generation. MUST be called inside a @spaces.GPU context."""
|
|
|
|
| 321 |
call.pop("width"); call.pop("height")
|
| 322 |
call["image"] = ref_image.convert("RGB")
|
| 323 |
call["strength"] = float(denoise)
|
| 324 |
+
return _safe_call(i2i, call)
|
|
|
|
| 325 |
|
| 326 |
elif mode == "ip_adapter":
|
| 327 |
if ref_image is None:
|
|
|
|
| 338 |
embeds = _face_embeds(ref_image).to(DEVICE)
|
| 339 |
call["ip_adapter_image_embeds"] = [embeds]
|
| 340 |
|
| 341 |
+
return _safe_call(pipe, call)
|
|
|