malekradwan130 commited on
Commit
1a32dce
·
verified ·
1 Parent(s): 62a3fe1

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +59 -0
app.py ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from model import Model
3
+ import os
4
+
5
+ on_huggingspace = os.environ.get("SPACE_AUTHOR_NAME") == "PAIR"
6
+
7
+ def create_demo(model: Model):
8
+ examples = [
9
+ ["an astronaut waving the arm on the moon"],
10
+ ["a sloth surfing on a wakeboard"],
11
+ ["an astronaut walking on a street"],
12
+ ["a cute cat walking on grass"],
13
+ ["a horse is galloping on a street"],
14
+ ["a gorilla dancing on times square"],
15
+ ]
16
+
17
+ with gr.Blocks() as demo:
18
+ with gr.Row():
19
+ gr.Markdown('## Text2Video-Zero: Video Generation')
20
+ with gr.Row():
21
+ gr.HTML(
22
+ """
23
+ <div style="text-align: left; auto;">
24
+ <h2 style="font-weight: 450; font-size: 1rem; margin: 0rem">
25
+ Description: Simply input <b>any textual prompt</b> 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.
26
+ </h3>
27
+ </div>
28
+ """
29
+ )
30
+
31
+ with gr.Row():
32
+ with gr.Column():
33
+ model_name = gr.Dropdown(
34
+ label="Model",
35
+ choices=get_model_list(),
36
+ value="dreamlike-art/dreamlike-photoreal-2.0",
37
+ )
38
+ prompt = gr.Textbox(label='Prompt')
39
+ run_button = gr.Button(label='Run')
40
+ with gr.Column():
41
+ result = gr.Video(label="Generated Video")
42
+
43
+ inputs = [
44
+ prompt,
45
+ model_name,
46
+ ]
47
+
48
+ gr.Examples(examples=examples,
49
+ inputs=inputs,
50
+ outputs=result,
51
+ fn=model.process_text2video,
52
+ run_on_click=False,
53
+ cache_examples=on_huggingspace,
54
+ )
55
+
56
+ run_button.click(fn=model.process_text2video,
57
+ inputs=inputs,
58
+ outputs=result)
59
+ return demo