Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -11,55 +11,27 @@ if not os.path.exists(WORK_DIR):
|
|
11 |
os.makedirs(WORK_DIR)
|
12 |
subprocess.run(["git", "clone", "--depth", "1", "https://github.com/comfyanonymous/ComfyUI.git", WORK_DIR])
|
13 |
|
14 |
-
# Tải
|
15 |
-
CUSTOM_NODES_DIR = os.path.join(WORK_DIR, "custom_nodes")
|
16 |
-
os.makedirs(CUSTOM_NODES_DIR, exist_ok=True)
|
17 |
-
custom_nodes = [
|
18 |
-
"https://github.com/ltdrdata/ComfyUI-Manager.git",
|
19 |
-
"https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite.git",
|
20 |
-
"https://github.com/FizzleDorf/ComfyUI_FizzNodes.git",
|
21 |
-
"https://github.com/Stability-AI/stability-ComfyUI-nodes.git",
|
22 |
-
"https://github.com/EllangoK/ComfyUI-post-processing-nodes.git",
|
23 |
-
"https://github.com/TinyTerra/ComfyUI_tinyterraNodes.git",
|
24 |
-
"https://github.com/WASasquatch/was-node-suite-comfyui.git",
|
25 |
-
"https://github.com/WASasquatch/PowerNoiseSuite.git",
|
26 |
-
"https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git"
|
27 |
-
]
|
28 |
-
for repo in custom_nodes:
|
29 |
-
repo_name = repo.split("/")[-1].replace(".git", "")
|
30 |
-
target_dir = os.path.join(CUSTOM_NODES_DIR, repo_name)
|
31 |
-
if not os.path.exists(target_dir):
|
32 |
-
subprocess.run(["git", "clone", "--depth", "1", repo, target_dir])
|
33 |
-
|
34 |
-
# Tải mô hình AnimateDiff
|
35 |
-
animate_diff_dir = os.path.join(CUSTOM_NODES_DIR, "ComfyUI-AnimateDiff-Evolved/models")
|
36 |
-
os.makedirs(animate_diff_dir, exist_ok=True)
|
37 |
-
for model in ["mm_sd_v15_v2.ckpt", "mm_sd_v15.ckpt"]:
|
38 |
-
model_path = os.path.join(animate_diff_dir, model)
|
39 |
-
if not os.path.exists(model_path):
|
40 |
-
subprocess.run(["wget", "-c", f"https://huggingface.co/guoyww/animatediff/resolve/main/{model}", "-P", animate_diff_dir])
|
41 |
-
|
42 |
-
# Tải mô hình WAN 2.1 I2V-14B-720P
|
43 |
MODEL_DIR = os.path.join(WORK_DIR, "models")
|
44 |
os.makedirs(MODEL_DIR, exist_ok=True)
|
45 |
|
46 |
-
def download_model(repo_id, filename, subfolder):
|
47 |
-
target_dir = os.path.join(MODEL_DIR,
|
48 |
os.makedirs(target_dir, exist_ok=True)
|
49 |
file_path = os.path.join(target_dir, filename)
|
50 |
if not os.path.exists(file_path):
|
51 |
-
hf_hub_download(repo_id=repo_id, filename=filename, local_dir=target_dir)
|
52 |
print(f"Đã tải {filename} vào {target_dir}")
|
53 |
|
54 |
repo_id = "Comfy-Org/Wan_2.1_ComfyUI_repackaged"
|
55 |
-
download_model(repo_id, "wan2.1_i2v_720p_14B_fp8_e4m3fn.safetensors", "diffusion_models")
|
56 |
-
download_model(repo_id, "wan_2.1_vae.safetensors", "vae")
|
57 |
-
download_model(repo_id, "umt5_xxl_fp8_e4m3fn_scaled.safetensors", "text_encoders")
|
58 |
-
download_model(repo_id, "clip_vision_h.safetensors", "clip_vision")
|
59 |
|
60 |
# Khởi động ComfyUI
|
61 |
def start_comfyui():
|
62 |
-
subprocess.Popen(["python", "main.py", "--port", "7860", "--listen", "0.0.0.0"
|
63 |
time.sleep(5)
|
64 |
|
65 |
start_comfyui()
|
@@ -73,8 +45,7 @@ demo = gr.Interface(
|
|
73 |
fn=lambda x: "Dùng giao diện ComfyUI bên dưới",
|
74 |
inputs=gr.Textbox(label="Thông tin", value="ComfyUI với WAN 2.1 I2V-14B-720P"),
|
75 |
outputs=gr.Textbox(label="Trạng thái"),
|
76 |
-
title="ComfyUI
|
77 |
-
description="Chạy workflow Image-to-Video 720P.",
|
78 |
additional_inputs=[HTML(comfyui_interface)]
|
79 |
)
|
80 |
|
|
|
11 |
os.makedirs(WORK_DIR)
|
12 |
subprocess.run(["git", "clone", "--depth", "1", "https://github.com/comfyanonymous/ComfyUI.git", WORK_DIR])
|
13 |
|
14 |
+
# Tải WAN 2.1 I2V-14B-720P
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
MODEL_DIR = os.path.join(WORK_DIR, "models")
|
16 |
os.makedirs(MODEL_DIR, exist_ok=True)
|
17 |
|
18 |
+
def download_model(repo_id, filename, subfolder, target_subfolder):
|
19 |
+
target_dir = os.path.join(MODEL_DIR, target_subfolder)
|
20 |
os.makedirs(target_dir, exist_ok=True)
|
21 |
file_path = os.path.join(target_dir, filename)
|
22 |
if not os.path.exists(file_path):
|
23 |
+
hf_hub_download(repo_id=repo_id, filename=filename, subfolder=subfolder, local_dir=target_dir)
|
24 |
print(f"Đã tải {filename} vào {target_dir}")
|
25 |
|
26 |
repo_id = "Comfy-Org/Wan_2.1_ComfyUI_repackaged"
|
27 |
+
download_model(repo_id, "wan2.1_i2v_720p_14B_fp8_e4m3fn.safetensors", "split_files/diffusion_models", "diffusion_models")
|
28 |
+
download_model(repo_id, "wan_2.1_vae.safetensors", "split_files/vae", "vae")
|
29 |
+
download_model(repo_id, "umt5_xxl_fp8_e4m3fn_scaled.safetensors", "split_files/text_encoders", "text_encoders")
|
30 |
+
download_model(repo_id, "clip_vision_h.safetensors", "split_files/clip_vision", "clip_vision")
|
31 |
|
32 |
# Khởi động ComfyUI
|
33 |
def start_comfyui():
|
34 |
+
subprocess.Popen(["python", "main.py", "--port", "7860", "--listen", "0.0.0.0"], cwd=WORK_DIR)
|
35 |
time.sleep(5)
|
36 |
|
37 |
start_comfyui()
|
|
|
45 |
fn=lambda x: "Dùng giao diện ComfyUI bên dưới",
|
46 |
inputs=gr.Textbox(label="Thông tin", value="ComfyUI với WAN 2.1 I2V-14B-720P"),
|
47 |
outputs=gr.Textbox(label="Trạng thái"),
|
48 |
+
title="ComfyUI WAN 2.1 I2V",
|
|
|
49 |
additional_inputs=[HTML(comfyui_interface)]
|
50 |
)
|
51 |
|