Spaces:
Running
Running
import streamlit as st | |
import subprocess | |
import os | |
# Title | |
st.title("π₯ WAN 2.1 - 14B AI Text-to-Video Generator") | |
# Input fields | |
prompt = st.text_area("Enter your text prompt:", "A cat in military dress wearing headphones, laughing and walking.") | |
frame_num = st.slider("Number of frames:", min_value=30, max_value=120, value=60, step=10) | |
resolution = st.selectbox("Select resolution:", ["832*480", "1280*720"]) | |
sample_steps = st.slider("Sampling steps:", min_value=10, max_value=50, value=20, step=5) | |
# Button to generate video | |
if st.button("Generate Video"): | |
st.info("Generating video... This may take a few minutes.") | |
# Run WAN 2.1 - 14B Model | |
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}\"" | |
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
stdout, stderr = process.communicate() | |
# Print logs for debugging | |
st.text_area("π Logs", stdout.decode() + stderr.decode()) | |
# 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.") | |