Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,21 +1,21 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import torch
|
| 3 |
-
from diffusers import
|
| 4 |
from diffusers.utils import export_to_video
|
| 5 |
|
| 6 |
-
# Load the
|
| 7 |
st.write("Loading model... (first run may take a few minutes)")
|
| 8 |
|
| 9 |
-
model_id = "
|
| 10 |
-
pipe =
|
| 11 |
|
| 12 |
-
st.title("
|
| 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,
|
| 19 |
video_frames = result.frames # List of PIL images
|
| 20 |
export_to_video(video_frames, "output.mp4", fps=8)
|
| 21 |
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import torch
|
| 3 |
+
from diffusers import StableVideoDiffusionPipeline
|
| 4 |
from diffusers.utils import export_to_video
|
| 5 |
|
| 6 |
+
# Load the video generation pipeline
|
| 7 |
st.write("Loading model... (first run may take a few minutes)")
|
| 8 |
|
| 9 |
+
model_id = "stabilityai/stable-video-diffusion-img2vid"
|
| 10 |
+
pipe = StableVideoDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
|
| 11 |
|
| 12 |
+
st.title("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, 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 |
|