Spaces:
Running
Running
File size: 906 Bytes
9ef21f1 9e806af 9ef21f1 9e806af 9ef21f1 9e806af 9ef21f1 9e806af fe80cd3 9e806af ddcf2d4 9e806af ddcf2d4 9e806af f81fa21 9e806af f81fa21 9e806af f81fa21 fe80cd3 9e806af ddcf2d4 f81fa21 fe80cd3 9e806af ddcf2d4 |
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 |
import streamlit as st
from diffusers import DiffusionPipeline
import torch
from moviepy.editor import *
import numpy as np
import tempfile, os
st.title("🚀 Text-to-Video (Zeroscope)")
@st.cache_resource
def load_model():
pipe = DiffusionPipeline.from_pretrained(
"cerspense/zeroscope_v2_576w",
torch_dtype=torch.float32
)
pipe.to("cpu")
return pipe
pipe = load_model()
prompt = st.text_area("Enter prompt (short & descriptive):", max_chars=50)
if st.button("Generate Video"):
if prompt:
with st.spinner("Generating... (may take a few mins on CPU)"):
video_frames = pipe(prompt, num_frames=8, height=320, width=576).frames
video_filename = tempfile.mktemp(".mp4")
clips = [ImageClip(np.array(frame)).set_duration(0.3) for frame in video_frames]
final_clip = concatenate_videoclips(clips, method="compose") |