Spaces:
Running
on
A10G
Running
on
A10G
Update app.py
Browse files
app.py
CHANGED
|
@@ -75,6 +75,9 @@ os.system(f"rm -rf gradio_cached_examples/")
|
|
| 75 |
|
| 76 |
device = "cuda"
|
| 77 |
|
|
|
|
|
|
|
|
|
|
| 78 |
class MagicTimeController:
|
| 79 |
def __init__(self):
|
| 80 |
# config dirs
|
|
@@ -195,7 +198,7 @@ class MagicTimeController:
|
|
| 195 |
).to(device)
|
| 196 |
|
| 197 |
if int(seed_textbox) > 0: seed = int(seed_textbox)
|
| 198 |
-
else: seed = random.randint(1,
|
| 199 |
torch.manual_seed(int(seed))
|
| 200 |
|
| 201 |
assert seed == torch.initial_seed()
|
|
@@ -249,38 +252,38 @@ def ui():
|
|
| 249 |
)
|
| 250 |
with gr.Row():
|
| 251 |
with gr.Column():
|
| 252 |
-
dreambooth_dropdown = gr.Dropdown(
|
| 253 |
-
motion_module_dropdown = gr.Dropdown(
|
| 254 |
|
| 255 |
-
prompt_textbox = gr.Textbox(
|
| 256 |
-
negative_prompt_textbox = gr.Textbox(
|
| 257 |
|
| 258 |
with gr.Accordion("Advance", open=False):
|
| 259 |
with gr.Row():
|
| 260 |
-
width_slider = gr.Slider(
|
| 261 |
-
height_slider = gr.Slider(
|
| 262 |
with gr.Row():
|
| 263 |
-
seed_textbox = gr.Textbox(
|
| 264 |
seed_button = gr.Button(value="\U0001F3B2", elem_classes="toolbutton")
|
| 265 |
-
seed_button.click(fn=
|
| 266 |
|
| 267 |
-
generate_button = gr.Button(
|
| 268 |
|
| 269 |
with gr.Column():
|
| 270 |
-
result_video = gr.Video(
|
| 271 |
-
json_config = gr.Json(
|
| 272 |
|
| 273 |
inputs = [dreambooth_dropdown, motion_module_dropdown, prompt_textbox, negative_prompt_textbox, width_slider, height_slider, seed_textbox]
|
| 274 |
outputs = [result_video, json_config]
|
| 275 |
-
|
| 276 |
-
generate_button.click(
|
| 277 |
-
|
| 278 |
-
gr.Markdown(
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
gr.Examples(
|
| 284 |
|
| 285 |
return demo
|
| 286 |
|
|
|
|
| 75 |
|
| 76 |
device = "cuda"
|
| 77 |
|
| 78 |
+
def random_seed():
|
| 79 |
+
return random.randint(1, 10**16)
|
| 80 |
+
|
| 81 |
class MagicTimeController:
|
| 82 |
def __init__(self):
|
| 83 |
# config dirs
|
|
|
|
| 198 |
).to(device)
|
| 199 |
|
| 200 |
if int(seed_textbox) > 0: seed = int(seed_textbox)
|
| 201 |
+
else: seed = random.randint(1, 10**16)
|
| 202 |
torch.manual_seed(int(seed))
|
| 203 |
|
| 204 |
assert seed == torch.initial_seed()
|
|
|
|
| 252 |
)
|
| 253 |
with gr.Row():
|
| 254 |
with gr.Column():
|
| 255 |
+
dreambooth_dropdown = gr.Dropdown(label="DreamBooth Model", choices=controller.dreambooth_list, value=controller.dreambooth_list[0], interactive=True)
|
| 256 |
+
motion_module_dropdown = gr.Dropdown(label="Motion Module", choices=controller.motion_module_list, value=controller.motion_module_list[0], interactive=True)
|
| 257 |
|
| 258 |
+
prompt_textbox = gr.Textbox(label="Prompt", lines=3)
|
| 259 |
+
negative_prompt_textbox = gr.Textbox(label="Negative Prompt", lines=3, value="worst quality, low quality, nsfw, logo")
|
| 260 |
|
| 261 |
with gr.Accordion("Advance", open=False):
|
| 262 |
with gr.Row():
|
| 263 |
+
width_slider = gr.Slider(label="Width", value=512, minimum=256, maximum=1024, step=64)
|
| 264 |
+
height_slider = gr.Slider(label="Height", value=512, minimum=256, maximum=1024, step=64)
|
| 265 |
with gr.Row():
|
| 266 |
+
seed_textbox = gr.Textbox(label="Seed (-1 means random)", value="-1")
|
| 267 |
seed_button = gr.Button(value="\U0001F3B2", elem_classes="toolbutton")
|
| 268 |
+
seed_button.click(fn=random_seed, inputs=[], outputs=[seed_textbox])
|
| 269 |
|
| 270 |
+
generate_button = gr.Button(value="Generate", variant='primary')
|
| 271 |
|
| 272 |
with gr.Column():
|
| 273 |
+
result_video = gr.Video(label="Generated Animation", interactive=False)
|
| 274 |
+
json_config = gr.Json(label="Config", value={})
|
| 275 |
|
| 276 |
inputs = [dreambooth_dropdown, motion_module_dropdown, prompt_textbox, negative_prompt_textbox, width_slider, height_slider, seed_textbox]
|
| 277 |
outputs = [result_video, json_config]
|
| 278 |
+
|
| 279 |
+
generate_button.click(fn=controller.magictime, inputs=inputs, outputs=outputs)
|
| 280 |
+
|
| 281 |
+
gr.Markdown("""
|
| 282 |
+
<h5 style="text-align:left;">⚠ Warning: Even if you use the same seed and prompt, changing machines may produce different results.
|
| 283 |
+
If you find a better seed and prompt, please submit an issue on GitHub.</h5>
|
| 284 |
+
""")
|
| 285 |
+
|
| 286 |
+
gr.Examples(fn=controller.magictime, examples=examples, inputs=inputs, outputs=outputs, cache_examples=True)
|
| 287 |
|
| 288 |
return demo
|
| 289 |
|