umer1995 commited on
Commit
0bb1778
·
verified ·
1 Parent(s): 5581c9f

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

Browse files
Files changed (1) hide show
  1. app.py +28 -19
app.py CHANGED
@@ -28,9 +28,36 @@ _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)
@@ -53,25 +80,7 @@ def _ensure_videox_on_path() -> None:
53
  str(_VX_CACHE),
54
  ]
55
  )
56
- # Replace heavy models/__init__.py so Flux2 Fun CN imports do not require
57
- # the full audio/video dependency stack.
58
- models_init = _VX_CACHE / "videox_fun" / "models" / "__init__.py"
59
- models_init.write_text(
60
- "from transformers import Mistral3ForConditionalGeneration, PixtralProcessor\n"
61
- "from .flux2_image_processor import Flux2ImageProcessor\n"
62
- "from .flux2_transformer2d import Flux2Transformer2DModel\n"
63
- "from .flux2_transformer2d_control import Flux2ControlTransformer2DModel\n"
64
- "from .flux2_vae import AutoencoderKLFlux2\n"
65
- "__all__ = [\n"
66
- " 'AutoencoderKLFlux2',\n"
67
- " 'Flux2ControlTransformer2DModel',\n"
68
- " 'Flux2ImageProcessor',\n"
69
- " 'Flux2Transformer2DModel',\n"
70
- " 'Mistral3ForConditionalGeneration',\n"
71
- " 'PixtralProcessor',\n"
72
- "]\n",
73
- encoding="utf-8",
74
- )
75
  sys.path.insert(0, str(_VX_CACHE))
76
 
77
 
 
28
  _VX_CACHE = Path.home() / "VideoX-Fun"
29
 
30
 
31
+ def _patch_videox_models_init(root: Path) -> None:
32
+ models_init = root / "videox_fun" / "models" / "__init__.py"
33
+ if not models_init.is_file():
34
+ return
35
+ text = models_init.read_text(encoding="utf-8", errors="replace")
36
+ if "Flux2ControlTransformer2DModel" in text and "fantasytalking" not in text:
37
+ return
38
+ models_init.write_text(
39
+ "from transformers import Mistral3ForConditionalGeneration, PixtralProcessor\n"
40
+ "from .flux2_image_processor import Flux2ImageProcessor\n"
41
+ "from .flux2_transformer2d import Flux2Transformer2DModel\n"
42
+ "from .flux2_transformer2d_control import Flux2ControlTransformer2DModel\n"
43
+ "from .flux2_vae import AutoencoderKLFlux2\n"
44
+ "__all__ = [\n"
45
+ " 'AutoencoderKLFlux2',\n"
46
+ " 'Flux2ControlTransformer2DModel',\n"
47
+ " 'Flux2ImageProcessor',\n"
48
+ " 'Flux2Transformer2DModel',\n"
49
+ " 'Mistral3ForConditionalGeneration',\n"
50
+ " 'PixtralProcessor',\n"
51
+ "]\n",
52
+ encoding="utf-8",
53
+ )
54
+ print("[nfa-fun-cn] patched videox_fun.models.__init__ (Flux2-only)", flush=True)
55
+
56
+
57
  def _ensure_videox_on_path() -> None:
58
  for candidate in (_VX, _VX_CACHE):
59
  if (candidate / "videox_fun" / "models").is_dir():
60
+ _patch_videox_models_init(candidate)
61
  p = str(candidate)
62
  if p not in sys.path:
63
  sys.path.insert(0, p)
 
80
  str(_VX_CACHE),
81
  ]
82
  )
83
+ _patch_videox_models_init(_VX_CACHE)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  sys.path.insert(0, str(_VX_CACHE))
85
 
86