Commit
•
d816efb
1
Parent(s):
81ac008
Update app.py
Browse files
app.py
CHANGED
@@ -37,6 +37,7 @@ css = """
|
|
37 |
}
|
38 |
"""
|
39 |
|
|
|
40 |
|
41 |
class AnimateController:
|
42 |
def __init__(self):
|
@@ -156,6 +157,7 @@ class AnimateController:
|
|
156 |
@torch.no_grad()
|
157 |
def animate(
|
158 |
self,
|
|
|
159 |
lora_alpha_slider,
|
160 |
spatial_lora_slider,
|
161 |
prompt_textbox,
|
@@ -168,6 +170,10 @@ class AnimateController:
|
|
168 |
cfg_scale_slider,
|
169 |
seed_textbox
|
170 |
):
|
|
|
|
|
|
|
|
|
171 |
|
172 |
if is_xformers_available():
|
173 |
self.unet.enable_xformers_memory_efficient_attention()
|
@@ -247,8 +253,9 @@ def ui():
|
|
247 |
2. Increase the sampling step and cfg and set proper negative prompt if you want more fancy videos.
|
248 |
'''
|
249 |
)
|
250 |
-
with gr.Column(
|
251 |
with gr.Row():
|
|
|
252 |
|
253 |
base_model_dropdown = gr.Dropdown(
|
254 |
label="Select base Dreambooth model (required)",
|
@@ -331,6 +338,7 @@ def ui():
|
|
331 |
generate_button.click(
|
332 |
fn=controller.animate,
|
333 |
inputs=[
|
|
|
334 |
lora_alpha_slider,
|
335 |
spatial_lora_slider,
|
336 |
prompt_textbox,
|
@@ -346,34 +354,6 @@ def ui():
|
|
346 |
outputs=[result_video]
|
347 |
)
|
348 |
|
349 |
-
examples = [
|
350 |
-
[0.8, 0.8, "a boy is holding a rabbit", "bad quality", "LCM", 8, 512, 16, 512, 1.5, 123],
|
351 |
-
[0.8, 0.8, "1girl smiling", "bad quality", "LCM", 4, 512, 16, 512, 1.5, 1233],
|
352 |
-
[0.8, 0.8, "1girl,face,white background,", "bad quality", "LCM", 6, 512, 16, 512, 1.5, 1234],
|
353 |
-
[0.8, 0.8, "clouds in the sky, best quality", "bad quality", "LCM", 4, 512, 16, 512, 1.5, 1234],
|
354 |
-
|
355 |
-
|
356 |
-
]
|
357 |
-
gr.Examples(
|
358 |
-
examples = examples,
|
359 |
-
inputs=[
|
360 |
-
lora_alpha_slider,
|
361 |
-
spatial_lora_slider,
|
362 |
-
prompt_textbox,
|
363 |
-
negative_prompt_textbox,
|
364 |
-
sampler_dropdown,
|
365 |
-
sample_step_slider,
|
366 |
-
width_slider,
|
367 |
-
length_slider,
|
368 |
-
height_slider,
|
369 |
-
cfg_scale_slider,
|
370 |
-
seed_textbox,
|
371 |
-
],
|
372 |
-
outputs=[result_video],
|
373 |
-
fn=controller.animate,
|
374 |
-
cache_examples=True,
|
375 |
-
)
|
376 |
-
|
377 |
return demo
|
378 |
|
379 |
|
@@ -382,5 +362,5 @@ if __name__ == "__main__":
|
|
382 |
demo = ui()
|
383 |
# gr.close_all()
|
384 |
# restart
|
385 |
-
demo.queue(api_open=
|
386 |
demo.launch()
|
|
|
37 |
}
|
38 |
"""
|
39 |
|
40 |
+
SECRET_TOKEN = os.getenv('SECRET_TOKEN', 'default_secret')
|
41 |
|
42 |
class AnimateController:
|
43 |
def __init__(self):
|
|
|
157 |
@torch.no_grad()
|
158 |
def animate(
|
159 |
self,
|
160 |
+
secret_token,
|
161 |
lora_alpha_slider,
|
162 |
spatial_lora_slider,
|
163 |
prompt_textbox,
|
|
|
170 |
cfg_scale_slider,
|
171 |
seed_textbox
|
172 |
):
|
173 |
+
if secret_token != SECRET_TOKEN:
|
174 |
+
raise gr.Error(
|
175 |
+
f'Invalid secret token. Please fork the original space if you want to use it for yourself.')
|
176 |
+
|
177 |
|
178 |
if is_xformers_available():
|
179 |
self.unet.enable_xformers_memory_efficient_attention()
|
|
|
253 |
2. Increase the sampling step and cfg and set proper negative prompt if you want more fancy videos.
|
254 |
'''
|
255 |
)
|
256 |
+
with gr.Column():
|
257 |
with gr.Row():
|
258 |
+
secret_token = gr.Text(label='Secret Token', max_lines=1)
|
259 |
|
260 |
base_model_dropdown = gr.Dropdown(
|
261 |
label="Select base Dreambooth model (required)",
|
|
|
338 |
generate_button.click(
|
339 |
fn=controller.animate,
|
340 |
inputs=[
|
341 |
+
secret_token,
|
342 |
lora_alpha_slider,
|
343 |
spatial_lora_slider,
|
344 |
prompt_textbox,
|
|
|
354 |
outputs=[result_video]
|
355 |
)
|
356 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
357 |
return demo
|
358 |
|
359 |
|
|
|
362 |
demo = ui()
|
363 |
# gr.close_all()
|
364 |
# restart
|
365 |
+
demo.queue(api_open=True)
|
366 |
demo.launch()
|