SkyCaptain85 commited on
Commit
8b384dd
·
verified ·
1 Parent(s): d91ef83

Update app.py: ZeroGPU keepalive + hardware hint

Browse files
Files changed (1) hide show
  1. app.py +18 -0
app.py CHANGED
@@ -16,6 +16,18 @@ from typing import Any
16
  import gradio as gr
17
  import httpx
18
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  MODEL_ID = "MiniMaxAI/MiniMax-H3"
20
  MODEL_URL = f"https://huggingface.co/{MODEL_ID}"
21
  ASSET = f"https://huggingface.co/{MODEL_ID}/resolve/main/assets"
@@ -340,6 +352,12 @@ def download_file_id(file_id: str, api_key: str, dest: Path) -> Path:
340
  raise gr.Error(f"Could not download file_id={file_id}")
341
 
342
 
 
 
 
 
 
 
343
  def generate_video(
344
  prompt: str,
345
  aspect_ratio: str,
 
16
  import gradio as gr
17
  import httpx
18
 
19
+ try:
20
+ import spaces # HF ZeroGPU runtime
21
+ except Exception: # local run without spaces package
22
+ class _SpacesShim:
23
+ @staticmethod
24
+ def GPU(*_a, **_k):
25
+ def deco(fn):
26
+ return fn
27
+ return deco
28
+
29
+ spaces = _SpacesShim()
30
+
31
  MODEL_ID = "MiniMaxAI/MiniMax-H3"
32
  MODEL_URL = f"https://huggingface.co/{MODEL_ID}"
33
  ASSET = f"https://huggingface.co/{MODEL_ID}/resolve/main/assets"
 
352
  raise gr.Error(f"Could not download file_id={file_id}")
353
 
354
 
355
+ @spaces.GPU(duration=30)
356
+ def _zerogpu_keepalive() -> str:
357
+ """No-op GPU touch so ZeroGPU accepts this API-proxy Space without burning quota on cold paths."""
358
+ return "ok"
359
+
360
+
361
  def generate_video(
362
  prompt: str,
363
  aspect_ratio: str,