Spaces:
Sleeping
Sleeping
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -196,13 +196,19 @@ def format_result(answer: str, spans: List[Tuple[float, float]]) -> str:
|
|
| 196 |
# Inference
|
| 197 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 198 |
|
| 199 |
-
def _estimate_duration(video, question, num_frames=NUM_FRAMES,
|
| 200 |
-
|
|
|
|
|
|
|
| 201 |
try:
|
| 202 |
n = int(num_frames)
|
| 203 |
except (TypeError, ValueError):
|
| 204 |
n = NUM_FRAMES
|
| 205 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
|
| 207 |
|
| 208 |
@spaces.GPU(duration=_estimate_duration)
|
|
|
|
| 196 |
# Inference
|
| 197 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 198 |
|
| 199 |
+
def _estimate_duration(video, question, num_frames=NUM_FRAMES, max_new_tokens=MAX_NEW_TOKENS,
|
| 200 |
+
*args, **kwargs) -> int:
|
| 201 |
+
"""Measured ~5s of GPU time for 48 frames + 1024 tokens on ZeroGPU; scale by
|
| 202 |
+
both budgets and add margin for cold weight streaming."""
|
| 203 |
try:
|
| 204 |
n = int(num_frames)
|
| 205 |
except (TypeError, ValueError):
|
| 206 |
n = NUM_FRAMES
|
| 207 |
+
try:
|
| 208 |
+
m = int(max_new_tokens)
|
| 209 |
+
except (TypeError, ValueError):
|
| 210 |
+
m = MAX_NEW_TOKENS
|
| 211 |
+
return min(240, 20 + int(n * 0.35) + int(m * 0.004))
|
| 212 |
|
| 213 |
|
| 214 |
@spaces.GPU(duration=_estimate_duration)
|