Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,36 +1,32 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
import torch
|
| 3 |
import subprocess
|
| 4 |
import os
|
| 5 |
|
| 6 |
-
# Check if GPU is available
|
| 7 |
-
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 8 |
-
|
| 9 |
# Title
|
| 10 |
-
st.title("WAN 2.1 -
|
| 11 |
-
|
| 12 |
-
# Model selection
|
| 13 |
-
model_path = "./Wan2.1-T2V-1.3B"
|
| 14 |
|
| 15 |
# Input fields
|
| 16 |
prompt = st.text_area("Enter your text prompt:", "A cat in military dress wearing headphones, laughing and walking.")
|
| 17 |
-
frame_num = st.slider("Number of frames:", min_value=30, max_value=
|
| 18 |
resolution = st.selectbox("Select resolution:", ["832*480", "1280*720"])
|
| 19 |
-
sample_steps = st.slider("Sampling steps:", min_value=10, max_value=50, value=
|
| 20 |
|
| 21 |
# Button to generate video
|
| 22 |
if st.button("Generate Video"):
|
| 23 |
-
st.info("Generating video...
|
| 24 |
|
| 25 |
-
# Run WAN 2.1
|
| 26 |
-
command = f"python generate.py --task t2v-
|
| 27 |
|
| 28 |
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
| 29 |
-
process.
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
-
#
|
| 32 |
if os.path.exists("output.mp4"):
|
| 33 |
st.video("output.mp4")
|
| 34 |
st.success("✅ Video generated successfully!")
|
| 35 |
else:
|
| 36 |
-
st.error("❌ Video generation failed
|
|
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
import subprocess
|
| 3 |
import os
|
| 4 |
|
|
|
|
|
|
|
|
|
|
| 5 |
# Title
|
| 6 |
+
st.title("🎥 WAN 2.1 - 14B AI Text-to-Video Generator")
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
# Input fields
|
| 9 |
prompt = st.text_area("Enter your text prompt:", "A cat in military dress wearing headphones, laughing and 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:", ["832*480", "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 |
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
| 22 |
+
stdout, stderr = process.communicate()
|
| 23 |
+
|
| 24 |
+
# Print logs for debugging
|
| 25 |
+
st.text_area("📜 Logs", stdout.decode() + stderr.decode())
|
| 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.")
|