multimodalart HF Staff commited on
Commit
2451bc2
Β·
verified Β·
1 Parent(s): f1eb7df

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +9 -3
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, *args, **kwargs) -> int:
200
- """Video length drives the runtime: ~1s per 8 frames plus generation."""
 
 
201
  try:
202
  n = int(num_frames)
203
  except (TypeError, ValueError):
204
  n = NUM_FRAMES
205
- return min(240, 45 + int(n * 1.6))
 
 
 
 
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)