Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
ideo(output.frames[0], path, fps=10)
|
2 |
+
return path
|
3 |
+
|
4 |
+
|
5 |
+
# Gradio Interface
|
6 |
+
with gr.Blocks(css="style.css") as demo:
|
7 |
+
gr.HTML(
|
8 |
+
"<h1><center>Textual Imagination : A Text To Video Synthesis</center></h1>"
|
9 |
+
)
|
10 |
+
with gr.Group():
|
11 |
+
with gr.Row():
|
12 |
+
prompt = gr.Textbox(
|
13 |
+
label='Prompt'
|
14 |
+
)
|
15 |
+
with gr.Row():
|
16 |
+
select_base = gr.Dropdown(
|
17 |
+
label='Base model',
|
18 |
+
choices=[
|
19 |
+
"Cartoon",
|
20 |
+
"Realistic",
|
21 |
+
"3d",
|
22 |
+
"Anime",
|
23 |
+
],
|
24 |
+
value=base_loaded,
|
25 |
+
interactive=True
|
26 |
+
)
|
27 |
+
select_motion = gr.Dropdown(
|
28 |
+
label='Motion',
|
29 |
+
choices=[
|
30 |
+
("Default", ""),
|
31 |
+
("Zoom in", "guoyww/animatediff-motion-lora-zoom-in"),
|
32 |
+
("Zoom out", "guoyww/animatediff-motion-lora-zoom-out"),
|
33 |
+
("Tilt up", "guoyww/animatediff-motion-lora-tilt-up"),
|
34 |
+
("Tilt down", "guoyww/animatediff-motion-lora-tilt-down"),
|
35 |
+
("Pan left", "guoyww/animatediff-motion-lora-pan-left"),
|
36 |
+
("Pan right", "guoyww/animatediff-motion-lora-pan-right"),
|
37 |
+
("Roll left", "guoyww/animatediff-motion-lora-rolling-anticlockwise"),
|
38 |
+
("Roll right", "guoyww/animatediff-motion-lora-rolling-clockwise"),
|
39 |
+
],
|
40 |
+
value="guoyww/animatediff-motion-lora-zoom-in",
|
41 |
+
interactive=True
|
42 |
+
)
|
43 |
+
select_step = gr.Dropdown(
|
44 |
+
label='Inference steps',
|
45 |
+
choices=[
|
46 |
+
('1-Step', 1),
|
47 |
+
('2-Step', 2),
|
48 |
+
('4-Step', 4),
|
49 |
+
('8-Step', 8),
|
50 |
+
],
|
51 |
+
value=4,
|
52 |
+
interactive=True
|
53 |
+
)
|
54 |
+
select_resolution = gr.Dropdown(
|
55 |
+
label='Resolution',
|
56 |
+
choices=[
|
57 |
+
"Square",
|
58 |
+
"Horizontal",
|
59 |
+
],
|
60 |
+
value="Square",
|
61 |
+
interactive=True
|
62 |
+
)
|
63 |
+
submit = gr.Button(
|
64 |
+
scale=1,
|
65 |
+
variant='primary'
|
66 |
+
)
|
67 |
+
video = gr.Video(
|
68 |
+
label='AnimateDiff-Lightning',
|
69 |
+
autoplay=True,
|
70 |
+
height=512,
|
71 |
+
width=512,
|
72 |
+
elem_id="video_output"
|
73 |
+
)
|
74 |
+
|
75 |
+
gr.on(
|
76 |
+
triggers=[
|
77 |
+
submit.click,
|
78 |
+
prompt.submit
|
79 |
+
],
|
80 |
+
fn=generate_image,
|
81 |
+
inputs=[prompt, select_base, select_motion, select_step, select_resolution],
|
82 |
+
outputs=[video],
|
83 |
+
api_name="instant_video",
|
84 |
+
queue=False
|
85 |
+
)
|
86 |
+
|
87 |
+
demo.queue().launch()
|