ritianyu commited on
Commit
82fa3eb
·
1 Parent(s): 2797b4e
Files changed (1) hide show
  1. app.py +17 -34
app.py CHANGED
@@ -1,7 +1,6 @@
1
  import os
2
  import shutil
3
  import tempfile
4
- import time
5
  import traceback
6
  import uuid
7
  from pathlib import Path
@@ -314,35 +313,22 @@ def run_demo(
314
  )
315
  try:
316
  # --- GPU-only inference (consumes ZeroGPU quota) ---
317
- # Retry on transient "GPU task aborted" errors (common on ZeroGPU)
318
- max_gpu_retries = 2
319
- gpu_result = None
320
- for attempt in range(max_gpu_retries + 1):
321
- try:
322
- gpu_result = run_demo_gpu(
323
- image=image,
324
- depth_file=depth_file,
325
- model_type=model_type,
326
- input_size=input_size,
327
- output_resolution_mode=output_resolution_mode,
328
- upsample_ratio=upsample_ratio,
329
- fx_org=fx_org,
330
- fy_org=fy_org,
331
- cx_org=cx_org,
332
- cy_org=cy_org,
333
- trace_path=trace_path,
334
- )
335
- break # success
336
- except Exception as gpu_exc:
337
- is_aborted = "GPU task aborted" in str(gpu_exc)
338
- if is_aborted and attempt < max_gpu_retries:
339
- Log.warning(
340
- f"[{request_id}] GPU task aborted (attempt {attempt + 1}/{max_gpu_retries + 1}), retrying..."
341
- )
342
- _append_trace(trace_path, f"ui:retry_{attempt + 1}_after_gpu_abort")
343
- time.sleep(2)
344
- continue
345
- raise # not retryable or out of retries
346
  _append_trace(trace_path, "ui:gpu_done, starting cpu postprocess")
347
 
348
  # --- CPU post-processing (no GPU quota consumed) ---
@@ -399,7 +385,7 @@ def run_demo(
399
  "This is a HuggingFace ZeroGPU scheduling issue, not an inference bug.\n"
400
  "Possible causes:\n"
401
  " - GPU quota exhausted (wait for quota to reset)\n"
402
- " - GPU task was preempted/aborted (try again)\n"
403
  " - duration too high for remaining quota"
404
  )
405
  else:
@@ -499,9 +485,6 @@ with gr.Blocks(title="InfiniDepth Demo", theme=gr.themes.Soft(), css=CUSTOM_CSS,
499
 
500
 
501
  run_button.click(
502
- fn=lambda: (None, None, [], "Running..."),
503
- outputs=[depth_output, pcd_viewer, files_output, status],
504
- ).then(
505
  fn=run_demo,
506
  inputs=[
507
  image_input,
 
1
  import os
2
  import shutil
3
  import tempfile
 
4
  import traceback
5
  import uuid
6
  from pathlib import Path
 
313
  )
314
  try:
315
  # --- GPU-only inference (consumes ZeroGPU quota) ---
316
+ # ZeroGPU proxy tokens are bound to the current Gradio request.
317
+ # Retrying a @spaces.GPU call inside the same request can turn a transient
318
+ # "GPU task aborted" into a deterministic "Expired ZeroGPU proxy token".
319
+ gpu_result = run_demo_gpu(
320
+ image=image,
321
+ depth_file=depth_file,
322
+ model_type=model_type,
323
+ input_size=input_size,
324
+ output_resolution_mode=output_resolution_mode,
325
+ upsample_ratio=upsample_ratio,
326
+ fx_org=fx_org,
327
+ fy_org=fy_org,
328
+ cx_org=cx_org,
329
+ cy_org=cy_org,
330
+ trace_path=trace_path,
331
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
332
  _append_trace(trace_path, "ui:gpu_done, starting cpu postprocess")
333
 
334
  # --- CPU post-processing (no GPU quota consumed) ---
 
385
  "This is a HuggingFace ZeroGPU scheduling issue, not an inference bug.\n"
386
  "Possible causes:\n"
387
  " - GPU quota exhausted (wait for quota to reset)\n"
388
+ " - GPU task was preempted/aborted (click the button again)\n"
389
  " - duration too high for remaining quota"
390
  )
391
  else:
 
485
 
486
 
487
  run_button.click(
 
 
 
488
  fn=run_demo,
489
  inputs=[
490
  image_input,