umer1995 commited on
Commit
d81c4ec
·
verified ·
1 Parent(s): 64fa5e3

Deploy NFA Track R FLUX.2 Fun CN ZeroGPU (real depth CN)

Browse files
Files changed (2) hide show
  1. app.py +37 -1
  2. requirements.txt +12 -2
app.py CHANGED
@@ -10,6 +10,7 @@ VRAM choice (documented):
10
  from __future__ import annotations
11
 
12
  import os
 
13
  import traceback
14
  from pathlib import Path
15
  from typing import Optional
@@ -21,6 +22,42 @@ from huggingface_hub import hf_hub_download, login, snapshot_download
21
  from omegaconf import OmegaConf
22
  from PIL import Image
23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  HF_TOKEN = (
25
  os.environ.get("HF_TOKEN")
26
  or os.environ.get("HUGGINGFACE_HUB_TOKEN")
@@ -57,7 +94,6 @@ MEM_MODE = (
57
  )
58
  ).strip()
59
 
60
- APP_DIR = Path(__file__).resolve().parent
61
  CONFIG_PATH = APP_DIR / "config" / "flux2_control.yaml"
62
  # Prefer HF Mount volumes (no 178GB ephemeral download). Fallback: cache download.
63
  MODEL_DIR = Path(
 
10
  from __future__ import annotations
11
 
12
  import os
13
+ import sys
14
  import traceback
15
  from pathlib import Path
16
  from typing import Optional
 
22
  from omegaconf import OmegaConf
23
  from PIL import Image
24
 
25
+ APP_DIR = Path(__file__).resolve().parent
26
+ # Prefer vendored tree; else clone VideoX-Fun on Space (pip package omits submodules).
27
+ _VX = APP_DIR / "vendor" / "VideoX-Fun"
28
+ _VX_CACHE = Path.home() / "VideoX-Fun"
29
+
30
+
31
+ def _ensure_videox_on_path() -> None:
32
+ for candidate in (_VX, _VX_CACHE):
33
+ if (candidate / "videox_fun" / "models").is_dir():
34
+ p = str(candidate)
35
+ if p not in sys.path:
36
+ sys.path.insert(0, p)
37
+ return
38
+ import subprocess
39
+
40
+ print("[nfa-fun-cn] cloning VideoX-Fun for Fun CN runtime…", flush=True)
41
+ _VX_CACHE.parent.mkdir(parents=True, exist_ok=True)
42
+ if _VX_CACHE.exists():
43
+ import shutil
44
+
45
+ shutil.rmtree(_VX_CACHE, ignore_errors=True)
46
+ subprocess.check_call(
47
+ [
48
+ "git",
49
+ "clone",
50
+ "--depth",
51
+ "1",
52
+ "https://github.com/aigc-apps/VideoX-Fun.git",
53
+ str(_VX_CACHE),
54
+ ]
55
+ )
56
+ sys.path.insert(0, str(_VX_CACHE))
57
+
58
+
59
+ _ensure_videox_on_path()
60
+
61
  HF_TOKEN = (
62
  os.environ.get("HF_TOKEN")
63
  or os.environ.get("HUGGINGFACE_HUB_TOKEN")
 
94
  )
95
  ).strip()
96
 
 
97
  CONFIG_PATH = APP_DIR / "config" / "flux2_control.yaml"
98
  # Prefer HF Mount volumes (no 178GB ephemeral download). Fallback: cache download.
99
  MODEL_DIR = Path(
requirements.txt CHANGED
@@ -13,7 +13,17 @@ spaces
13
  gradio>=5.0.0
14
  huggingface_hub
15
  requests
16
- # Official Fun CN stack (ALIMAMA / VideoX-Fun) — NOT Diffusers soft image=
17
- videox-fun @ git+https://github.com/aigc-apps/VideoX-Fun.git
18
  diffusers>=0.36.0
19
  transformers>=4.46.2
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  gradio>=5.0.0
14
  huggingface_hub
15
  requests
 
 
16
  diffusers>=0.36.0
17
  transformers>=4.46.2
18
+ # VideoX-Fun code is vendored under vendor/VideoX-Fun (pip package misses submodules).
19
+ # Runtime deps from VideoX-Fun pyproject:
20
+ timm
21
+ tomesd
22
+ torchdiffeq
23
+ torchsde
24
+ opencv-python-headless
25
+ imageio
26
+ ftfy
27
+ func_timeout
28
+ albumentations
29
+ scikit-image