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