Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,7 @@
|
|
| 1 |
-
#
|
| 2 |
# Created by bilsimaging.com
|
| 3 |
|
| 4 |
import os
|
| 5 |
-
# Prefer safetensors globally (fixes CLAP .bin crash on ZeroGPU)
|
| 6 |
os.environ.setdefault("HF_PREFER_SAFETENSORS", "1")
|
| 7 |
|
| 8 |
import sys
|
|
@@ -20,7 +19,7 @@ import torchaudio
|
|
| 20 |
import gradio as gr
|
| 21 |
from loguru import logger
|
| 22 |
from huggingface_hub import snapshot_download
|
| 23 |
-
import spaces
|
| 24 |
|
| 25 |
|
| 26 |
# -------------------------
|
|
@@ -35,7 +34,7 @@ OUTPUTS_DIR.mkdir(parents=True, exist_ok=True)
|
|
| 35 |
|
| 36 |
SPACE_TITLE = "🎵 ShortiFoley — HunyuanVideo-Foley"
|
| 37 |
SPACE_TAGLINE = "Bring your videos to life with AI-powered Foley"
|
| 38 |
-
WATERMARK_NOTE = "
|
| 39 |
|
| 40 |
# ZeroGPU limit (<=120)
|
| 41 |
GPU_DURATION = int(os.environ.get("GPU_DURATION_SECS", "110"))
|
|
@@ -47,7 +46,7 @@ _device: Optional[torch.device] = None
|
|
| 47 |
|
| 48 |
|
| 49 |
# ------------
|
| 50 |
-
# Small helpers
|
| 51 |
# ------------
|
| 52 |
def _ensure_repo() -> None:
|
| 53 |
"""Shallow-clone Tencent repo with LFS smudge disabled (avoid LFS quota checkout)."""
|
|
@@ -250,7 +249,7 @@ def infer_single_video(
|
|
| 250 |
return outs, f"✅ Generated {len(outs)} result(s). Saved to {OUTPUTS_DIR}/"
|
| 251 |
|
| 252 |
|
| 253 |
-
|
| 254 |
@spaces.GPU(duration=GPU_DURATION)
|
| 255 |
def gpu_load_models() -> str:
|
| 256 |
device = torch.device("cuda:0")
|
|
@@ -436,7 +435,7 @@ def create_ui() -> gr.Blocks:
|
|
| 436 |
# ---- REST + MCP endpoints (inside Blocks) ----
|
| 437 |
def _download_to_tmp(url: str) -> str:
|
| 438 |
try:
|
| 439 |
-
import requests
|
| 440 |
except Exception:
|
| 441 |
raise RuntimeError("Missing dependency 'requests'. Add it to requirements.txt to use URL inputs.")
|
| 442 |
r = requests.get(url, timeout=30)
|
|
@@ -538,5 +537,5 @@ if __name__ == "__main__":
|
|
| 538 |
server_name="0.0.0.0",
|
| 539 |
share=False,
|
| 540 |
show_error=True,
|
| 541 |
-
mcp_server=True, # MCP
|
| 542 |
)
|
|
|
|
| 1 |
+
# ShortiFoley
|
| 2 |
# Created by bilsimaging.com
|
| 3 |
|
| 4 |
import os
|
|
|
|
| 5 |
os.environ.setdefault("HF_PREFER_SAFETENSORS", "1")
|
| 6 |
|
| 7 |
import sys
|
|
|
|
| 19 |
import gradio as gr
|
| 20 |
from loguru import logger
|
| 21 |
from huggingface_hub import snapshot_download
|
| 22 |
+
import spaces
|
| 23 |
|
| 24 |
|
| 25 |
# -------------------------
|
|
|
|
| 34 |
|
| 35 |
SPACE_TITLE = "🎵 ShortiFoley — HunyuanVideo-Foley"
|
| 36 |
SPACE_TAGLINE = "Bring your videos to life with AI-powered Foley"
|
| 37 |
+
WATERMARK_NOTE = "Made with ❤️ by bilsimaging.com"
|
| 38 |
|
| 39 |
# ZeroGPU limit (<=120)
|
| 40 |
GPU_DURATION = int(os.environ.get("GPU_DURATION_SECS", "110"))
|
|
|
|
| 46 |
|
| 47 |
|
| 48 |
# ------------
|
| 49 |
+
# Small helpers
|
| 50 |
# ------------
|
| 51 |
def _ensure_repo() -> None:
|
| 52 |
"""Shallow-clone Tencent repo with LFS smudge disabled (avoid LFS quota checkout)."""
|
|
|
|
| 249 |
return outs, f"✅ Generated {len(outs)} result(s). Saved to {OUTPUTS_DIR}/"
|
| 250 |
|
| 251 |
|
| 252 |
+
|
| 253 |
@spaces.GPU(duration=GPU_DURATION)
|
| 254 |
def gpu_load_models() -> str:
|
| 255 |
device = torch.device("cuda:0")
|
|
|
|
| 435 |
# ---- REST + MCP endpoints (inside Blocks) ----
|
| 436 |
def _download_to_tmp(url: str) -> str:
|
| 437 |
try:
|
| 438 |
+
import requests
|
| 439 |
except Exception:
|
| 440 |
raise RuntimeError("Missing dependency 'requests'. Add it to requirements.txt to use URL inputs.")
|
| 441 |
r = requests.get(url, timeout=30)
|
|
|
|
| 537 |
server_name="0.0.0.0",
|
| 538 |
share=False,
|
| 539 |
show_error=True,
|
| 540 |
+
mcp_server=True, # MCP
|
| 541 |
)
|