Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import os
|
| 2 |
os.environ.setdefault("GRADIO_USE_CDN", "true")
|
| 3 |
import sys
|
|
|
|
| 4 |
import subprocess
|
| 5 |
from pathlib import Path
|
| 6 |
from typing import Tuple, Optional
|
|
@@ -17,6 +18,16 @@ WEIGHTS_FILE = "model.safetensors" # from the HF model repo
|
|
| 17 |
CACHE_DIR = SPACE_ROOT / "weights"
|
| 18 |
CACHE_DIR.mkdir(parents=True, exist_ok=True)
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
# ---------- 1) Pull weights from HF Hub ----------
|
| 21 |
def get_weights_path() -> Path:
|
| 22 |
weights_path = hf_hub_download(
|
|
|
|
| 1 |
import os
|
| 2 |
os.environ.setdefault("GRADIO_USE_CDN", "true")
|
| 3 |
import sys
|
| 4 |
+
import spaces
|
| 5 |
import subprocess
|
| 6 |
from pathlib import Path
|
| 7 |
from typing import Tuple, Optional
|
|
|
|
| 18 |
CACHE_DIR = SPACE_ROOT / "weights"
|
| 19 |
CACHE_DIR.mkdir(parents=True, exist_ok=True)
|
| 20 |
|
| 21 |
+
# --- ZeroGPU compatibility (no behavior change) ---
|
| 22 |
+
USE_ZEROGPU = os.getenv("SPACE_RUNTIME", "").lower() == "zerogpu"
|
| 23 |
+
if USE_ZEROGPU:
|
| 24 |
+
import spaces
|
| 25 |
+
|
| 26 |
+
@spaces.GPU(duration=60)
|
| 27 |
+
def _zgpu_dummy():
|
| 28 |
+
# Minimal GPU-annotated function so ZeroGPU runtime is satisfied.
|
| 29 |
+
# We never call this; actual inference stays CPU unless you choose otherwise.
|
| 30 |
+
return "ok"
|
| 31 |
# ---------- 1) Pull weights from HF Hub ----------
|
| 32 |
def get_weights_path() -> Path:
|
| 33 |
weights_path = hf_hub_download(
|