Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import spaces
|
2 |
import os
|
3 |
import tempfile
|
@@ -77,7 +114,8 @@ def auto_load_models() -> str:
|
|
77 |
|
78 |
try:
|
79 |
# 如果模型路径不存在,尝试从HuggingFace下载
|
80 |
-
if not os.path.exists(MODEL_PATH):
|
|
|
81 |
logger.info(f"模型路径 {MODEL_PATH} 不存在,开始从HuggingFace下载...")
|
82 |
download_result = download_model_from_hf(local_dir=MODEL_PATH.rstrip('/'))
|
83 |
if "失败" in download_result:
|
@@ -177,7 +215,12 @@ def infer_single_video(
|
|
177 |
|
178 |
# Merge video and audio
|
179 |
video_output = os.path.join(temp_dir, f"video_with_audio_{i+1}.mp4")
|
|
|
|
|
|
|
180 |
merge_audio_video(audio_output, video_file, video_output)
|
|
|
|
|
181 |
video_outputs.append(video_output)
|
182 |
|
183 |
logger.info(f"Inference completed! Generated {sample_nums} samples.")
|
@@ -854,7 +897,7 @@ if __name__ == "__main__":
|
|
854 |
app.launch(
|
855 |
server_name="0.0.0.0",
|
856 |
# server_port=8080,
|
857 |
-
share=
|
858 |
debug=False,
|
859 |
show_error=True
|
860 |
)
|
|
|
1 |
+
'''
|
2 |
+
import pandas as pd
|
3 |
+
from gradio_client import Client
|
4 |
+
|
5 |
+
# 读取CSV文件
|
6 |
+
df = pd.read_csv("wan_gen_videos_captioned/metadata.csv")
|
7 |
+
|
8 |
+
# 初始化Gradio客户端
|
9 |
+
client = Client("http://localhost:7860")
|
10 |
+
|
11 |
+
# 逐行处理DataFrame
|
12 |
+
for index, row in df.iterrows():
|
13 |
+
try:
|
14 |
+
# 构建文件路径
|
15 |
+
file_path = f"wan_gen_videos_captioned/{row['file_name']}"
|
16 |
+
|
17 |
+
# 调用API
|
18 |
+
result = client.predict(
|
19 |
+
file_path, # 视频文件路径
|
20 |
+
row['prompt'], # 对应的prompt
|
21 |
+
4.5, # CFG Scale
|
22 |
+
50, # Steps
|
23 |
+
1, # Sample Nums
|
24 |
+
fn_index=1
|
25 |
+
)
|
26 |
+
|
27 |
+
# 打印结果
|
28 |
+
print(f"处理成功 - 行 {index}: {result}")
|
29 |
+
|
30 |
+
except Exception as e:
|
31 |
+
# 捕获异常并继续处理下一行
|
32 |
+
print(f"处理失败 - 行 {index}: {str(e)}")
|
33 |
+
continue
|
34 |
+
|
35 |
+
print("所有行处理完成")
|
36 |
+
'''
|
37 |
+
|
38 |
import spaces
|
39 |
import os
|
40 |
import tempfile
|
|
|
114 |
|
115 |
try:
|
116 |
# 如果模型路径不存在,尝试从HuggingFace下载
|
117 |
+
#if not os.path.exists(MODEL_PATH):
|
118 |
+
if True:
|
119 |
logger.info(f"模型路径 {MODEL_PATH} 不存在,开始从HuggingFace下载...")
|
120 |
download_result = download_model_from_hf(local_dir=MODEL_PATH.rstrip('/'))
|
121 |
if "失败" in download_result:
|
|
|
215 |
|
216 |
# Merge video and audio
|
217 |
video_output = os.path.join(temp_dir, f"video_with_audio_{i+1}.mp4")
|
218 |
+
from shutil import copy2
|
219 |
+
import time
|
220 |
+
seconds = int(time.time())
|
221 |
merge_audio_video(audio_output, video_file, video_output)
|
222 |
+
copy2(video_output, os.path.join("." ,str(seconds) + "_" + video_output.split("/")[-1]))
|
223 |
+
|
224 |
video_outputs.append(video_output)
|
225 |
|
226 |
logger.info(f"Inference completed! Generated {sample_nums} samples.")
|
|
|
897 |
app.launch(
|
898 |
server_name="0.0.0.0",
|
899 |
# server_port=8080,
|
900 |
+
share=False,
|
901 |
debug=False,
|
902 |
show_error=True
|
903 |
)
|