import gradio as gr
from model import Model
import os
on_huggingspace = os.environ.get("SPACE_AUTHOR_NAME") == "PAIR"
def create_demo(model: Model):
examples = [
["an astronaut waving the arm on the moon"],
["a sloth surfing on a wakeboard"],
["an astronaut walking on a street"],
["a cute cat walking on grass"],
["a horse is galloping on a street"],
["a gorilla dancing on times square"],
]
with gr.Blocks() as demo:
with gr.Row():
gr.Markdown('## Text2Video-Zero: Video Generation')
with gr.Row():
gr.HTML(
"""
Description: Simply input any textual prompt to generate videos right away and unleash your creativity and imagination! You can also select from the examples below. For performance purposes, our current preview release allows to generate up to 16 frames, which can be configured in the Advanced Options.
"""
)
with gr.Row():
with gr.Column():
model_name = gr.Dropdown(
label="Model",
choices=get_model_list(),
value="dreamlike-art/dreamlike-photoreal-2.0",
)
prompt = gr.Textbox(label='Prompt')
run_button = gr.Button(label='Run')
with gr.Column():
result = gr.Video(label="Generated Video")
inputs = [
prompt,
model_name,
]
gr.Examples(examples=examples,
inputs=inputs,
outputs=result,
fn=model.process_text2video,
run_on_click=False,
cache_examples=on_huggingspace,
)
run_button.click(fn=model.process_text2video,
inputs=inputs,
outputs=result)
return demo