Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -1,52 +1,19 @@
|
|
1 |
-
|
2 |
-
import os
|
3 |
-
import subprocess
|
4 |
-
import time
|
5 |
-
from gradio.components import HTML
|
6 |
-
from huggingface_hub import hf_hub_download
|
7 |
-
|
8 |
-
# Tạo thư mục làm việc
|
9 |
-
WORK_DIR = "/app/ComfyUI"
|
10 |
-
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 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 |
-
#
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
start_comfyui()
|
38 |
-
|
39 |
-
# Nhúng giao diện
|
40 |
-
comfyui_interface = """
|
41 |
-
<iframe src="http://localhost:7860" width="100%" height="600px" style="border:none;"></iframe>
|
42 |
-
"""
|
43 |
-
|
44 |
-
demo = gr.Interface(
|
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 |
-
|
52 |
-
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
1 |
+
# Tải WAN 2.1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
def download_model(repo_id, filename, subfolder, target_subfolder):
|
3 |
target_dir = os.path.join(MODEL_DIR, target_subfolder)
|
4 |
os.makedirs(target_dir, exist_ok=True)
|
5 |
file_path = os.path.join(target_dir, filename)
|
6 |
if not os.path.exists(file_path):
|
7 |
hf_hub_download(repo_id=repo_id, filename=filename, subfolder=subfolder, local_dir=target_dir)
|
|
|
8 |
|
9 |
repo_id = "Comfy-Org/Wan_2.1_ComfyUI_repackaged"
|
10 |
download_model(repo_id, "wan2.1_i2v_720p_14B_fp8_e4m3fn.safetensors", "split_files/diffusion_models", "diffusion_models")
|
|
|
11 |
download_model(repo_id, "umt5_xxl_fp8_e4m3fn_scaled.safetensors", "split_files/text_encoders", "text_encoders")
|
12 |
+
download_model(repo_id, "wan_2.1_vae.safetensors", "split_files/vae", "vae")
|
13 |
download_model(repo_id, "clip_vision_h.safetensors", "split_files/clip_vision", "clip_vision")
|
14 |
+
download_model(repo_id, "image_to_video_wan_720p_example.json", "example%20workflows_Wan2.1", "user/default/workflows")
|
15 |
|
16 |
+
# Tải workflow từ foxtonai
|
17 |
+
workflow_dir = os.path.join(WORK_DIR, "user/default/workflows")
|
18 |
+
os.makedirs(workflow_dir, exist_ok=True)
|
19 |
+
subprocess.run(["wget", "-P", workflow_dir, "https://foxtonai.com/downloads/comfyui-wan-2.1-i2v-modified-workflow.json"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|