Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
97feb6f
1
Parent(s):
2df8b3b
Revert "Use simpler calculation"
Browse filesThis reverts commit 2df8b3be08e433b775ba07173cde88e050a3155d.
app.py
CHANGED
|
@@ -91,7 +91,31 @@ def get_duration(
|
|
| 91 |
progress=None,
|
| 92 |
):
|
| 93 |
"""Calculate dynamic GPU duration based on parameters."""
|
| 94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
|
| 96 |
|
| 97 |
@spaces.GPU(duration=get_duration)
|
|
|
|
| 91 |
progress=None,
|
| 92 |
):
|
| 93 |
"""Calculate dynamic GPU duration based on parameters."""
|
| 94 |
+
BASE_FRAMES_HEIGHT_WIDTH = 81 * 832 * 624
|
| 95 |
+
BASE_STEP_DURATION = 15
|
| 96 |
+
|
| 97 |
+
# Get dimensions from resolution or from first image
|
| 98 |
+
if flf2vid_image_first is not None:
|
| 99 |
+
width, height = flf2vid_image_first.size
|
| 100 |
+
else:
|
| 101 |
+
# Fallback to resolution string mapping
|
| 102 |
+
resolution_map = {
|
| 103 |
+
"720P": (1280, 720),
|
| 104 |
+
"1280x720": (1280, 720),
|
| 105 |
+
"480P": (832, 480),
|
| 106 |
+
"832x480": (832, 480),
|
| 107 |
+
}
|
| 108 |
+
width, height = resolution_map.get(resolution, (1280, 720))
|
| 109 |
+
|
| 110 |
+
# Use frame_num directly (already provided)
|
| 111 |
+
frames = int(frame_num) if frame_num else 81
|
| 112 |
+
|
| 113 |
+
# Calculate duration factor
|
| 114 |
+
factor = frames * width * height / BASE_FRAMES_HEIGHT_WIDTH
|
| 115 |
+
step_duration = BASE_STEP_DURATION * (factor**1.5)
|
| 116 |
+
|
| 117 |
+
# Return total duration in seconds
|
| 118 |
+
return 10 + int(sd_steps) * step_duration
|
| 119 |
|
| 120 |
|
| 121 |
@spaces.GPU(duration=get_duration)
|