Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -3,30 +3,47 @@ import subprocess
|
|
3 |
import os
|
4 |
|
5 |
# Title
|
6 |
-
st.title("π₯ WAN 2.1 - 14B
|
7 |
|
8 |
# Input fields
|
9 |
-
prompt = st.text_area("Enter your text prompt:", "A
|
10 |
frame_num = st.slider("Number of frames:", min_value=30, max_value=120, value=60, step=10)
|
11 |
resolution = st.selectbox("Select resolution:", ["200*200", "1280*720"])
|
12 |
sample_steps = st.slider("Sampling steps:", min_value=10, max_value=50, value=20, step=5)
|
13 |
|
|
|
|
|
|
|
14 |
# Button to generate video
|
15 |
-
if st.button("Generate Video"):
|
16 |
st.info("Generating video... This may take a few minutes.")
|
17 |
-
|
18 |
-
# Run WAN 2.1 - 14B Model
|
19 |
-
command = f"python generate.py --task t2v-14B --size {resolution} --frame_num {frame_num} --sample_steps {sample_steps} --ckpt_dir ./Wan2.1-T2V-14B --offload_model True --prompt \"{prompt}\""
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
|
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
# Check if video was created
|
28 |
if os.path.exists("output.mp4"):
|
29 |
st.video("output.mp4")
|
30 |
st.success("β
Video generated successfully!")
|
31 |
else:
|
32 |
-
st.error("β Video generation failed! Check logs above.")
|
|
|
3 |
import os
|
4 |
|
5 |
# Title
|
6 |
+
st.title("π₯ WAN 2.1 - 14B Text-to-Video Generator")
|
7 |
|
8 |
# Input fields
|
9 |
+
prompt = st.text_area("Enter your text prompt:", "A tiger walking.")
|
10 |
frame_num = st.slider("Number of frames:", min_value=30, max_value=120, value=60, step=10)
|
11 |
resolution = st.selectbox("Select resolution:", ["200*200", "1280*720"])
|
12 |
sample_steps = st.slider("Sampling steps:", min_value=10, max_value=50, value=20, step=5)
|
13 |
|
14 |
+
# Logging output placeholder
|
15 |
+
log_area = st.empty()
|
16 |
+
|
17 |
# Button to generate video
|
18 |
+
if st.button("π Generate Video"):
|
19 |
st.info("Generating video... This may take a few minutes.")
|
|
|
|
|
|
|
20 |
|
21 |
+
# Define the command
|
22 |
+
command = (
|
23 |
+
f"python generate.py --task t2v-14B --size {resolution} "
|
24 |
+
f"--frame_num {frame_num} --sample_steps {sample_steps} "
|
25 |
+
f"--ckpt_dir ./Wan2.1-T2V-14B --offload_model True --prompt \"{prompt}\""
|
26 |
+
)
|
27 |
+
|
28 |
+
# Log command execution
|
29 |
+
log_area.text_area("πΉ Running Command:", command)
|
30 |
|
31 |
+
# Run process and stream output
|
32 |
+
with subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=1, text=True) as process:
|
33 |
+
logs = []
|
34 |
+
for line in process.stdout:
|
35 |
+
logs.append(line)
|
36 |
+
log_area.text_area("π Logs (Real-time)", "".join(logs), height=250)
|
37 |
+
|
38 |
+
# Capture stderr separately
|
39 |
+
stderr_output = process.stderr.read()
|
40 |
+
if stderr_output:
|
41 |
+
logs.append("\nπΊ Error Logs:\n" + stderr_output)
|
42 |
+
log_area.text_area("π Logs (Real-time)", "".join(logs), height=250)
|
43 |
+
|
44 |
# Check if video was created
|
45 |
if os.path.exists("output.mp4"):
|
46 |
st.video("output.mp4")
|
47 |
st.success("β
Video generated successfully!")
|
48 |
else:
|
49 |
+
st.error("β Video generation failed! Check logs above.")
|