Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,23 +1,22 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import torch
|
| 3 |
-
from diffusers import
|
| 4 |
from diffusers.utils import export_to_video
|
| 5 |
|
| 6 |
-
# Load the Wan2.1 text-to-video pipeline (1.3B version) with half
|
|
|
|
|
|
|
| 7 |
model_id = "Wan-AI/Wan2.1-T2V-1.3B-Diffusers"
|
| 8 |
-
|
| 9 |
-
vae = AutoencoderKLWan.from_pretrained(model_id, subfolder="vae", torch_dtype=torch.float16)
|
| 10 |
-
pipe = WanPipeline.from_pretrained(model_id, vae=vae, torch_dtype=torch.float16)
|
| 11 |
-
# (By default, the pipeline is on CPU since no .to("cuda") is called)
|
| 12 |
|
| 13 |
st.title("Wan2.1 Text-to-Video Generator")
|
| 14 |
prompt = st.text_input("Enter a text prompt for the video:")
|
| 15 |
frames = st.slider("Number of frames (video length)", min_value=8, max_value=81, value=24)
|
|
|
|
| 16 |
if st.button("Generate Video") and prompt:
|
| 17 |
with st.spinner("Generating video... this may take a while on CPU"):
|
| 18 |
-
# Run the pipeline to generate video frames
|
| 19 |
result = pipe(prompt=prompt, height=480, width=832, num_frames=frames, num_inference_steps=20)
|
| 20 |
-
video_frames = result.frames #
|
| 21 |
-
|
| 22 |
-
|
| 23 |
st.video("output.mp4")
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import torch
|
| 3 |
+
from diffusers import WanPipeline
|
| 4 |
from diffusers.utils import export_to_video
|
| 5 |
|
| 6 |
+
# Load the Wan2.1 text-to-video pipeline (1.3B version) with half-precision weights
|
| 7 |
+
st.write("Loading model... (first run may take a few minutes)")
|
| 8 |
+
|
| 9 |
model_id = "Wan-AI/Wan2.1-T2V-1.3B-Diffusers"
|
| 10 |
+
pipe = WanPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
st.title("Wan2.1 Text-to-Video Generator")
|
| 13 |
prompt = st.text_input("Enter a text prompt for the video:")
|
| 14 |
frames = st.slider("Number of frames (video length)", min_value=8, max_value=81, value=24)
|
| 15 |
+
|
| 16 |
if st.button("Generate Video") and prompt:
|
| 17 |
with st.spinner("Generating video... this may take a while on CPU"):
|
|
|
|
| 18 |
result = pipe(prompt=prompt, height=480, width=832, num_frames=frames, num_inference_steps=20)
|
| 19 |
+
video_frames = result.frames # List of PIL images
|
| 20 |
+
export_to_video(video_frames, "output.mp4", fps=8)
|
| 21 |
+
|
| 22 |
st.video("output.mp4")
|