Spaces:
Running
Running
| import streamlit as st | |
| import torch | |
| import imageio | |
| import tempfile | |
| from diffusers import DiffusionPipeline | |
| st.set_page_config(page_title="Sora-lite π¬", layout="centered") | |
| st.title("π₯ Sora-lite: Text-to-Video Generator") | |
| st.markdown("Generate mini videos from text prompts using open-source models!") | |
| prompt = st.text_input("Enter a prompt", "a robot dancing on Mars") | |
| if st.button("π¬ Generate Video"): | |
| with st.spinner("Generating video, please wait..."): | |
| pipe = DiffusionPipeline.from_pretrained( | |
| "damo-vilab/text-to-video-ms-1.7b", | |
| torch_dtype=torch.float16, | |
| variant="fp16" | |
| ) | |
| pipe.to("cuda" if torch.cuda.is_available() else "cpu") | |
| result = pipe(prompt) | |
| frames = result.frames | |
| with tempfile.NamedTemporaryFile(suffix=".mp4", delete=False) as tmpfile: | |
| imageio.mimsave(tmpfile.name, frames, fps=8) | |
| st.video(tmpfile.name) | |
| st.success("β Done!") | |