Spaces:
Sleeping
Sleeping
bann commited on
Commit ·
81ba29d
1
Parent(s): 2d2d6b8
fix(zerogpu): use dynamic *args in get_duration and disable experimental ssr
Browse files
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(
|
| 477 |
-
|
| 478 |
-
|
| 479 |
-
|
| 480 |
-
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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])
|