Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -10,11 +10,6 @@ from huggingface_hub import hf_hub_download
|
|
10 |
from safetensors.torch import load_file
|
11 |
from PIL import Image
|
12 |
|
13 |
-
MORE = """ ## TRY Other Models
|
14 |
-
### JARVIS: Your VOICE Assistant -> https://huggingface.co/spaces/KingNish/JARVIS
|
15 |
-
### Instant Image: 4k images in 5 Second -> https://huggingface.co/spaces/KingNish/Instant-Image
|
16 |
-
"""
|
17 |
-
|
18 |
# Constants
|
19 |
bases = {
|
20 |
"Cartoon": "frankjoshua/toonyou_beta6",
|
@@ -76,32 +71,31 @@ def generate_image(prompt, base="Realistic", motion="", step=8, progress=gr.Prog
|
|
76 |
export_to_video(output.frames[0], path, fps=10)
|
77 |
return path
|
78 |
|
79 |
-
|
80 |
# Gradio Interface
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
with gr.Group():
|
90 |
with gr.Row():
|
91 |
-
prompt = gr.Textbox(
|
92 |
-
label='Prompt'
|
93 |
-
)
|
94 |
with gr.Row():
|
95 |
select_base = gr.Dropdown(
|
96 |
label='Base model',
|
97 |
-
choices=[
|
98 |
-
"Cartoon",
|
99 |
-
"Realistic",
|
100 |
-
"3d",
|
101 |
-
"Anime",
|
102 |
-
],
|
103 |
value=base_loaded,
|
104 |
-
interactive=True
|
|
|
105 |
)
|
106 |
select_motion = gr.Dropdown(
|
107 |
label='Motion',
|
@@ -117,58 +111,38 @@ with gr.Blocks(css="style.css") as demo:
|
|
117 |
("Roll right", "guoyww/animatediff-motion-lora-rolling-clockwise"),
|
118 |
],
|
119 |
value="guoyww/animatediff-motion-lora-zoom-in",
|
120 |
-
interactive=True
|
|
|
121 |
)
|
122 |
select_step = gr.Dropdown(
|
123 |
label='Inference steps',
|
124 |
-
choices=[
|
125 |
-
('1-Step', 1),
|
126 |
-
('2-Step', 2),
|
127 |
-
('4-Step', 4),
|
128 |
-
('8-Step', 8),
|
129 |
-
],
|
130 |
value=4,
|
131 |
-
interactive=True
|
132 |
-
|
133 |
-
submit = gr.Button(
|
134 |
-
scale=1,
|
135 |
-
variant='primary'
|
136 |
)
|
137 |
-
|
138 |
-
|
139 |
-
autoplay=True,
|
140 |
-
height=512,
|
141 |
-
width=512,
|
142 |
-
elem_id="video_output"
|
143 |
-
)
|
144 |
|
145 |
-
prompt.submit(
|
146 |
-
|
147 |
-
inputs=[prompt, select_base, select_motion, select_step],
|
148 |
-
outputs=video,
|
149 |
-
)
|
150 |
-
submit.click(
|
151 |
-
fn=generate_image,
|
152 |
-
inputs=[prompt, select_base, select_motion, select_step],
|
153 |
-
outputs=video,
|
154 |
-
api_name = "instant_video"
|
155 |
-
)
|
156 |
|
157 |
gr.Examples(
|
158 |
examples=[
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
fn=generate_image,
|
169 |
inputs=[prompt],
|
170 |
outputs=video,
|
171 |
cache_examples=True,
|
172 |
-
|
|
|
173 |
|
174 |
-
demo.queue().launch()
|
|
|
10 |
from safetensors.torch import load_file
|
11 |
from PIL import Image
|
12 |
|
|
|
|
|
|
|
|
|
|
|
13 |
# Constants
|
14 |
bases = {
|
15 |
"Cartoon": "frankjoshua/toonyou_beta6",
|
|
|
71 |
export_to_video(output.frames[0], path, fps=10)
|
72 |
return path
|
73 |
|
|
|
74 |
# Gradio Interface
|
75 |
+
css = """
|
76 |
+
body {font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: #f4f4f9; color: #333;}
|
77 |
+
h1 {color: #333; text-align: center; margin-bottom: 20px;}
|
78 |
+
.gradio-container {max-width: 800px; margin: auto; padding: 20px; background: #fff; box-shadow: 0px 0px 20px rgba(0,0,0,0.1); border-radius: 10px;}
|
79 |
+
.gr-input {margin-bottom: 15px;}
|
80 |
+
.gr-button {width: 100%; background-color: #4CAF50; color: white; border: none; padding: 10px 20px; text-align: center; text-decoration: none; display: inline-block; font-size: 16px; border-radius: 5px; cursor: pointer; transition: background-color 0.3s;}
|
81 |
+
.gr-button:hover {background-color: #45a049;}
|
82 |
+
.gr-video {margin-top: 20px;}
|
83 |
+
.gr-examples {margin-top: 30px;}
|
84 |
+
.gr-examples .gr-example {display: inline-block; width: 100%; text-align: center; padding: 10px; background: #eaeaea; border-radius: 5px; margin-bottom: 10px;}
|
85 |
+
"""
|
86 |
+
|
87 |
+
with gr.Blocks(css=css) as demo:
|
88 |
+
gr.HTML("<h1>Instant⚡ Text to Video</h1>")
|
89 |
with gr.Group():
|
90 |
with gr.Row():
|
91 |
+
prompt = gr.Textbox(label='Prompt', elem_id="gr-input", placeholder="Enter text to generate video...")
|
|
|
|
|
92 |
with gr.Row():
|
93 |
select_base = gr.Dropdown(
|
94 |
label='Base model',
|
95 |
+
choices=["Cartoon", "Realistic", "3d", "Anime"],
|
|
|
|
|
|
|
|
|
|
|
96 |
value=base_loaded,
|
97 |
+
interactive=True,
|
98 |
+
elem_id="gr-input"
|
99 |
)
|
100 |
select_motion = gr.Dropdown(
|
101 |
label='Motion',
|
|
|
111 |
("Roll right", "guoyww/animatediff-motion-lora-rolling-clockwise"),
|
112 |
],
|
113 |
value="guoyww/animatediff-motion-lora-zoom-in",
|
114 |
+
interactive=True,
|
115 |
+
elem_id="gr-input"
|
116 |
)
|
117 |
select_step = gr.Dropdown(
|
118 |
label='Inference steps',
|
119 |
+
choices=[('1-Step', 1), ('2-Step', 2), ('4-Step', 4), ('8-Step', 8)],
|
|
|
|
|
|
|
|
|
|
|
120 |
value=4,
|
121 |
+
interactive=True,
|
122 |
+
elem_id="gr-input"
|
|
|
|
|
|
|
123 |
)
|
124 |
+
submit = gr.Button("Generate Video", variant='primary', elem_id="gr-button")
|
125 |
+
video = gr.Video(label='AnimateDiff-Lightning', autoplay=True, height=512, width=512, elem_id="gr-video")
|
|
|
|
|
|
|
|
|
|
|
126 |
|
127 |
+
prompt.submit(fn=generate_image, inputs=[prompt, select_base, select_motion, select_step], outputs=video)
|
128 |
+
submit.click(fn=generate_image, inputs=[prompt, select_base, select_motion, select_step], outputs=video, api_name="instant_video")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
|
130 |
gr.Examples(
|
131 |
examples=[
|
132 |
+
["Focus: Eiffel Tower (Animate: Clouds moving)"],
|
133 |
+
["Focus: Trees In forest (Animate: Lion running)"],
|
134 |
+
["Focus: Astronaut in Space"],
|
135 |
+
["Focus: Group of Birds in sky (Animate: Birds Moving) (Shot From distance)"],
|
136 |
+
["Focus: Statue of liberty (Shot from Drone) (Animate: Drone coming toward statue)"],
|
137 |
+
["Focus: Panda in Forest (Animate: Drinking Tea)"],
|
138 |
+
["Focus: Kids Playing (Season: Winter)"],
|
139 |
+
["Focus: Cars in Street (Season: Rain, Daytime) (Shot from Distance) (Movement: Cars running)"]
|
140 |
+
],
|
141 |
fn=generate_image,
|
142 |
inputs=[prompt],
|
143 |
outputs=video,
|
144 |
cache_examples=True,
|
145 |
+
elem_id="gr-examples"
|
146 |
+
)
|
147 |
|
148 |
+
demo.queue().launch()
|