bann commited on
Commit
81ba29d
·
1 Parent(s): 2d2d6b8

fix(zerogpu): use dynamic *args in get_duration and disable experimental ssr

Browse files
Files changed (1) hide show
  1. app.py +14 -9
app.py CHANGED
@@ -473,14 +473,19 @@ def _fit_keyframe(image_input, target_width: int, target_height: int) -> Image.I
473
  return img
474
 
475
 
476
- def get_duration(prompt, negative_prompt, input_image, nsfw_base_choice, nsfw_base_strength, canvas, num_frames, fps, steps, *a, **k):
477
- steps = int(steps)
478
- num_frames = int(num_frames)
479
- h, w = CANVASES.get(canvas, (480, 832))
480
- pixels_per_frame = h * w
481
- total_tokens = (pixels_per_frame / 256) * (num_frames / 4)
482
- estimated = int(steps * (total_tokens * 0.00012) + 20)
483
- return max(60, min(MAX_GPU_DURATION, estimated))
 
 
 
 
 
484
 
485
 
486
  @spaces.GPU(duration=get_duration, size=GPU_SIZE)
@@ -1051,4 +1056,4 @@ with gr.Blocks(css=custom_css, title="Wan 2.2 Video Studio") as app:
1051
  )
1052
 
1053
  if __name__ == "__main__":
1054
- app.launch(show_api=False, show_error=True, allowed_paths=[OUTPUT_DIR])
 
473
  return img
474
 
475
 
476
+ def get_duration(*args, **kwargs):
477
+ try:
478
+ # _generate_video_gpu receives: (prompt, negative_prompt, image_input, height, width, num_frames, steps, ...)
479
+ height = kwargs.get("height", args[3] if len(args) > 3 else 480)
480
+ width = kwargs.get("width", args[4] if len(args) > 4 else 832)
481
+ num_frames = kwargs.get("num_frames", args[5] if len(args) > 5 else 81)
482
+ steps = kwargs.get("steps", args[6] if len(args) > 6 else 20)
483
+ pixels_per_frame = int(height) * int(width)
484
+ total_tokens = (pixels_per_frame / 256) * (int(num_frames) / 4)
485
+ estimated = int(int(steps) * (total_tokens * 0.00012) + 20)
486
+ return max(60, min(MAX_GPU_DURATION, estimated))
487
+ except Exception:
488
+ return 180
489
 
490
 
491
  @spaces.GPU(duration=get_duration, size=GPU_SIZE)
 
1056
  )
1057
 
1058
  if __name__ == "__main__":
1059
+ app.launch(ssr=False, show_api=False, show_error=True, allowed_paths=[OUTPUT_DIR])