Bils commited on
Commit
9b1e7e2
·
verified ·
1 Parent(s): 27f348c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -8
app.py CHANGED
@@ -1,8 +1,7 @@
1
- # app.py — ShortiFoley (Video -> Foley)
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 # HF Spaces ZeroGPU & MCP integration
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 = "ShortiFoley automatically generates realistic sound effects and ambience from short video ,Made with ❤️ by bilsimaging.com"
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 (CPU-only; avoid touching CUDA here)
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
- # Separate GPU task to preload model (used by the Load button & API)
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 # ensure added in requirements if you use this endpoint
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 on (great for n8n)
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
  )