Spaces:
Runtime error
Runtime error
File size: 1,755 Bytes
c472b15 7b36a3f c472b15 b0267fa c472b15 d632df8 c472b15 3c33543 b8de6eb 91cab35 d632df8 c472b15 b047869 3c33543 b8de6eb 3c33543 c472b15 3141b27 a50a2f9 3c33543 2eca5ee 3141b27 3c33543 3141b27 |
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 31 32 33 34 35 36 37 38 39 40 41 |
import gradio as gr
import spaces
import torch
from diffusers import DiffusionPipeline, DPMSolverMultistepScheduler
from diffusers.utils import export_to_video
import cv2
import numpy as np
pipe = DiffusionPipeline.from_pretrained("damo-vilab/text-to-video-ms-1.7b", torch_dtype=torch.float16, variant="fp16")
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
pipe.enable_model_cpu_offload()
pipe.enable_vae_slicing()
@spaces.GPU(duration=250)
def generate(prompt, num_inference_steps, num_frames):
video_frames = pipe(prompt, num_inference_steps=num_inference_steps, num_frames=num_frames).frames[0]
video_path = export_to_video(video_frames, fps=10)
return video_path
prompt = gr.Textbox(label="Enter prompt to generate a video", info="Based on this prompt ai will generate a video")
description="""
π This is **unofficial** demo of Openai's Sora that haven't been released yet.\n
β This space made using [ali-vilab/text-to-video-ms-1.7b](https://huggingface.co/ali-vilab/text-to-video-ms-1.7b)\n
β Estimated generation time is **150 seconds**\n
π Space is running on ZeroGPU, if you want faster generation, duplicate space and choose faster GPU
"""
num_inference_steps=gr.Slider(8, 64, step=8, value=24, label="Num Inference Steps", info="More steps then better quality")
num_frames=gr.Slider(8, 640, step=8, value=200, label="Num of Frames", info="It is duration of video")
interface = gr.Interface(
generate,
inputs=[prompt],
additional_inputs=[num_inference_steps, num_frames],
examples=[["Astronaut riding a horse"], ["Darth vader surfing in waves"]],
outputs="video",
title="Openai Sora (Unofficial)",
description=description,
cache_examples=False,
theme="soft"
).launch()
|