Spaces:
Paused
Paused
Update app_g.py
Browse files
app_g.py
CHANGED
|
@@ -6,19 +6,59 @@ import sys
|
|
| 6 |
from huggingface_hub import snapshot_download
|
| 7 |
import spaces
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
#
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
if not os.path.exists(DIFFSYNTH_PATH):
|
| 17 |
raise RuntimeError(
|
| 18 |
-
f"'diffsynth' package not found in {
|
| 19 |
f"Ensure PusaV1 is correctly cloned and folder structure is intact."
|
| 20 |
)
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
import gradio as gr
|
| 23 |
import torch
|
| 24 |
import os
|
|
@@ -33,38 +73,7 @@ import tempfile
|
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
-
# Constants
|
| 37 |
-
import os
|
| 38 |
-
from huggingface_hub import snapshot_download
|
| 39 |
-
|
| 40 |
-
# Constants
|
| 41 |
-
MODEL_ZOO_DIR = "./model_zoo"
|
| 42 |
-
PUSA_DIR = os.path.join(MODEL_ZOO_DIR, "PusaV1")
|
| 43 |
-
WAN_SUBFOLDER = "Wan2.1-T2V-14B"
|
| 44 |
-
WAN_MODEL_PATH = os.path.join(PUSA_DIR, WAN_SUBFOLDER)
|
| 45 |
-
LORA_PATH = os.path.join(PUSA_DIR, "pusa_v1.pt")
|
| 46 |
-
|
| 47 |
-
# Ensure model and weights are downloaded
|
| 48 |
-
def ensure_model_downloaded():
|
| 49 |
-
if not os.path.exists(PUSA_DIR):
|
| 50 |
-
print("Downloading RaphaelLiu/PusaV1 to ./model_zoo/PusaV1 ...")
|
| 51 |
-
snapshot_download(
|
| 52 |
-
repo_id="RaphaelLiu/PusaV1",
|
| 53 |
-
local_dir=PUSA_DIR,
|
| 54 |
-
repo_type="model",
|
| 55 |
-
local_dir_use_symlinks=False,
|
| 56 |
-
)
|
| 57 |
-
print("β
PusaV1 downloaded.")
|
| 58 |
|
| 59 |
-
if not os.path.exists(WAN_MODEL_PATH):
|
| 60 |
-
print("Downloading Wan-AI/Wan2.1-T2V-14B to ./model_zoo/PusaV1/Wan2.1-T2V-14B ...")
|
| 61 |
-
snapshot_download(
|
| 62 |
-
repo_id="Wan-AI/Wan2.1-T2V-14B-Diffusers", #"Wan-AI/Wan2.1-T2V-14B",
|
| 63 |
-
local_dir=WAN_MODEL_PATH, # Changed from WAN_DIR to WAN_MODEL_PATH
|
| 64 |
-
repo_type="model",
|
| 65 |
-
local_dir_use_symlinks=False,
|
| 66 |
-
)
|
| 67 |
-
print("β
Wan2.1-T2V-14B downloaded.")
|
| 68 |
|
| 69 |
|
| 70 |
class PusaVideoDemo:
|
|
@@ -74,7 +83,7 @@ class PusaVideoDemo:
|
|
| 74 |
self.multi_frames_pipe = None
|
| 75 |
self.v2v_pipe = None
|
| 76 |
self.t2v_pipe = None
|
| 77 |
-
self.base_dir = "model_zoo/PusaV1/Wan2.1-T2V-14B"
|
| 78 |
self.output_dir = "outputs"
|
| 79 |
os.makedirs(self.output_dir, exist_ok=True)
|
| 80 |
|
|
@@ -946,7 +955,7 @@ def create_demo():
|
|
| 946 |
info="Controls generation quality and consistency"
|
| 947 |
)
|
| 948 |
steps_t2v = gr.Slider(
|
| 949 |
-
minimum=
|
| 950 |
label="Inference Steps"
|
| 951 |
)
|
| 952 |
|
|
|
|
| 6 |
from huggingface_hub import snapshot_download
|
| 7 |
import spaces
|
| 8 |
|
| 9 |
+
import os
|
| 10 |
+
import sys
|
| 11 |
+
from huggingface_hub import snapshot_download
|
| 12 |
+
|
| 13 |
+
# === Setup Paths ===
|
| 14 |
+
PUSA_ROOT = os.path.abspath("./PusaV1")
|
| 15 |
+
MODEL_ZOO_DIR = os.path.join(PUSA_ROOT, "modelzoo")
|
| 16 |
+
WAN_SUBFOLDER = "Wan2.1-T2V-14B"
|
| 17 |
+
WAN_MODEL_PATH = os.path.join(MODEL_ZOO_DIR, WAN_SUBFOLDER)
|
| 18 |
+
LORA_PATH = os.path.join(MODEL_ZOO_DIR, "pusa_v1.pt")
|
| 19 |
|
| 20 |
+
# Add PUSA_ROOT to sys.path so Python can find local modules like diffsynth
|
| 21 |
+
if PUSA_ROOT not in sys.path:
|
| 22 |
+
sys.path.insert(0, PUSA_ROOT)
|
| 23 |
+
|
| 24 |
+
# Validate presence of diffsynth
|
| 25 |
+
DIFFSYNTH_PATH = os.path.join(PUSA_ROOT, "diffsynth")
|
| 26 |
if not os.path.exists(DIFFSYNTH_PATH):
|
| 27 |
raise RuntimeError(
|
| 28 |
+
f"'diffsynth' package not found in {PUSA_ROOT}. "
|
| 29 |
f"Ensure PusaV1 is correctly cloned and folder structure is intact."
|
| 30 |
)
|
| 31 |
|
| 32 |
+
# === Ensure model and weights are downloaded ===
|
| 33 |
+
def ensure_model_downloaded():
|
| 34 |
+
if not os.path.exists(MODEL_ZOO_DIR):
|
| 35 |
+
print("Downloading RaphaelLiu/PusaV1 to ./PusaV1/modelzoo ...")
|
| 36 |
+
snapshot_download(
|
| 37 |
+
repo_id="RaphaelLiu/PusaV1",
|
| 38 |
+
local_dir=MODEL_ZOO_DIR,
|
| 39 |
+
repo_type="model",
|
| 40 |
+
local_dir_use_symlinks=False,
|
| 41 |
+
)
|
| 42 |
+
print("β
PusaV1 base model downloaded.")
|
| 43 |
+
|
| 44 |
+
if not os.path.exists(WAN_MODEL_PATH):
|
| 45 |
+
print("Downloading Wan-AI/Wan2.1-T2V-14B to ./PusaV1/modelzoo/Wan2.1-T2V-14B ...")
|
| 46 |
+
snapshot_download(
|
| 47 |
+
repo_id="Wan-AI/Wan2.1-T2V-14B-Diffusers", # Adjust if necessary
|
| 48 |
+
local_dir=WAN_MODEL_PATH,
|
| 49 |
+
repo_type="model",
|
| 50 |
+
local_dir_use_symlinks=False,
|
| 51 |
+
)
|
| 52 |
+
print("β
Wan2.1-T2V-14B model downloaded.")
|
| 53 |
+
|
| 54 |
+
if not os.path.exists(LORA_PATH):
|
| 55 |
+
raise FileNotFoundError(
|
| 56 |
+
f"Expected LoRA weights 'pusa_v1.pt' not found at {LORA_PATH}. "
|
| 57 |
+
f"Please ensure the file exists or is downloaded manually."
|
| 58 |
+
)
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
|
| 62 |
import gradio as gr
|
| 63 |
import torch
|
| 64 |
import os
|
|
|
|
| 73 |
|
| 74 |
|
| 75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
|
| 78 |
|
| 79 |
class PusaVideoDemo:
|
|
|
|
| 83 |
self.multi_frames_pipe = None
|
| 84 |
self.v2v_pipe = None
|
| 85 |
self.t2v_pipe = None
|
| 86 |
+
self.base_dir = "PusaV1/model_zoo/PusaV1/Wan2.1-T2V-14B"
|
| 87 |
self.output_dir = "outputs"
|
| 88 |
os.makedirs(self.output_dir, exist_ok=True)
|
| 89 |
|
|
|
|
| 955 |
info="Controls generation quality and consistency"
|
| 956 |
)
|
| 957 |
steps_t2v = gr.Slider(
|
| 958 |
+
minimum=1, maximum=50, value=10, step=5,
|
| 959 |
label="Inference Steps"
|
| 960 |
)
|
| 961 |
|