Spaces:
Running on Zero
Running on Zero
Commit ·
519548d
1
Parent(s): e8421c5
Use per-mode dynamic ZeroGPU duration (30s fast, 60s high-detail)
Browse filesFast mode (1024px) p95 pipeline time is ~14.5s so 30s is safe.
High-Detail mode (2048px) p99 is ~40s so 60s is kept for that path.
Drop mode default params — Gradio always passes it explicitly.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
app.py
CHANGED
|
@@ -332,7 +332,7 @@ with open("templates/app.html") as _f:
|
|
| 332 |
|
| 333 |
# ── Gradio blocks ──────────────────────────────────────────────────────────────
|
| 334 |
|
| 335 |
-
def infer(images_b64_json, prompt, seed, randomize_seed, guidance_scale, steps, mode
|
| 336 |
# CPU-only preprocessing — GPU not yet allocated
|
| 337 |
gc.collect()
|
| 338 |
pil_images = b64_to_pil_list(images_b64_json)
|
|
@@ -341,7 +341,7 @@ def infer(images_b64_json, prompt, seed, randomize_seed, guidance_scale, steps,
|
|
| 341 |
width, height = update_dimensions_on_upload(pil_images[0], max_dim_for_mode(mode))
|
| 342 |
t0 = time.perf_counter()
|
| 343 |
try:
|
| 344 |
-
result_image, seed, duration = _infer_gpu(pil_images, prompt, seed, guidance_scale, steps, width, height)
|
| 345 |
# _spawn_log is called here (main process) so the thread survives after _infer_gpu's
|
| 346 |
# @spaces.GPU subprocess exits — previously the daemon thread was killed on subprocess exit.
|
| 347 |
_spawn_log(pil_images, result_image, prompt, seed, steps, guidance_scale, width, height, duration, True)
|
|
@@ -352,8 +352,8 @@ def infer(images_b64_json, prompt, seed, randomize_seed, guidance_scale, steps,
|
|
| 352 |
raise
|
| 353 |
|
| 354 |
|
| 355 |
-
@spaces.GPU(duration=60)
|
| 356 |
-
def _infer_gpu(pil_images, prompt, seed, guidance_scale, steps, width, height):
|
| 357 |
_cuda_ok = torch.cuda.is_available()
|
| 358 |
timer = _InferTimer(_cuda_ok)
|
| 359 |
t0 = time.perf_counter()
|
|
|
|
| 332 |
|
| 333 |
# ── Gradio blocks ──────────────────────────────────────────────────────────────
|
| 334 |
|
| 335 |
+
def infer(images_b64_json, prompt, seed, randomize_seed, guidance_scale, steps, mode, progress=gr.Progress(track_tqdm=True)):
|
| 336 |
# CPU-only preprocessing — GPU not yet allocated
|
| 337 |
gc.collect()
|
| 338 |
pil_images = b64_to_pil_list(images_b64_json)
|
|
|
|
| 341 |
width, height = update_dimensions_on_upload(pil_images[0], max_dim_for_mode(mode))
|
| 342 |
t0 = time.perf_counter()
|
| 343 |
try:
|
| 344 |
+
result_image, seed, duration = _infer_gpu(pil_images, prompt, seed, guidance_scale, steps, width, height, mode)
|
| 345 |
# _spawn_log is called here (main process) so the thread survives after _infer_gpu's
|
| 346 |
# @spaces.GPU subprocess exits — previously the daemon thread was killed on subprocess exit.
|
| 347 |
_spawn_log(pil_images, result_image, prompt, seed, steps, guidance_scale, width, height, duration, True)
|
|
|
|
| 352 |
raise
|
| 353 |
|
| 354 |
|
| 355 |
+
@spaces.GPU(duration=lambda *a, **kw: 30 if (len(a) > 7 and a[7] == "fast") else 60)
|
| 356 |
+
def _infer_gpu(pil_images, prompt, seed, guidance_scale, steps, width, height, mode):
|
| 357 |
_cuda_ok = torch.cuda.is_available()
|
| 358 |
timer = _InferTimer(_cuda_ok)
|
| 359 |
t0 = time.perf_counter()
|