Spaces:
Running
Running
daquanzhou
commited on
Commit
•
80669d0
1
Parent(s):
974f81a
demo init
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ import random
|
|
3 |
import sys
|
4 |
from typing import Sequence, Mapping, Any, Union
|
5 |
import torch
|
|
|
6 |
|
7 |
|
8 |
def get_value_at_index(obj: Union[Sequence, Mapping], index: int) -> Any:
|
@@ -400,10 +401,125 @@ class MagicMeController:
|
|
400 |
unique_id=5059112282155244564,
|
401 |
)
|
402 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
403 |
|
404 |
-
def main():
|
405 |
-
import_custom_nodes()
|
406 |
if __name__ == "__main__":
|
407 |
-
|
408 |
-
|
409 |
-
|
|
|
3 |
import sys
|
4 |
from typing import Sequence, Mapping, Any, Union
|
5 |
import torch
|
6 |
+
import gradio as gr
|
7 |
|
8 |
|
9 |
def get_value_at_index(obj: Union[Sequence, Mapping], index: int) -> Any:
|
|
|
401 |
unique_id=5059112282155244564,
|
402 |
)
|
403 |
|
404 |
+
import_custom_nodes()
|
405 |
+
c = MagicMeController()
|
406 |
+
|
407 |
+
|
408 |
+
|
409 |
+
css = """
|
410 |
+
.toolbutton {
|
411 |
+
margin-buttom: 0em 0em 0em 0em;
|
412 |
+
max-width: 2.5em;
|
413 |
+
min-width: 2.5em !important;
|
414 |
+
height: 2.5em;
|
415 |
+
}
|
416 |
+
"""
|
417 |
+
|
418 |
+
|
419 |
+
examples = [
|
420 |
+
# 1-ToonYou
|
421 |
+
[
|
422 |
+
"toonyou_beta3.safetensors",
|
423 |
+
"mm_sd_v14.ckpt",
|
424 |
+
"masterpiece, best quality, 1girl, solo, cherry blossoms, hanami, pink flower, white flower, spring season, wisteria, petals, flower, plum blossoms, outdoors, falling petals, white hair, black eyes",
|
425 |
+
"worst quality, low quality, nsfw, logo",
|
426 |
+
512, 512, "13204175718326964000"
|
427 |
+
],
|
428 |
+
# 2-Lyriel
|
429 |
+
[
|
430 |
+
"lyriel_v16.safetensors",
|
431 |
+
"mm_sd_v15.ckpt",
|
432 |
+
"A forbidden castle high up in the mountains, pixel art, intricate details2, hdr, intricate details, hyperdetailed5, natural skin texture, hyperrealism, soft light, sharp, game art, key visual, surreal",
|
433 |
+
"3d, cartoon, anime, sketches, worst quality, low quality, normal quality, lowres, normal quality, monochrome, grayscale, skin spots, acnes, skin blemishes, bad anatomy, girl, loli, young, large breasts, red eyes, muscular",
|
434 |
+
512, 512, "6681501646976930000"
|
435 |
+
],
|
436 |
+
# 3-RCNZ
|
437 |
+
[
|
438 |
+
"rcnzCartoon3d_v10.safetensors",
|
439 |
+
"mm_sd_v14.ckpt",
|
440 |
+
"Jane Eyre with headphones, natural skin texture,4mm,k textures, soft cinematic light, adobe lightroom, photolab, hdr, intricate, elegant, highly detailed, sharp focus, cinematic look, soothing tones, insane details, intricate details, hyperdetailed, low contrast, soft cinematic light, dim colors, exposure blend, hdr, faded",
|
441 |
+
"deformed, distorted, disfigured, poorly drawn, bad anatomy, wrong anatomy, extra limb, missing limb, floating limbs, mutated hands and fingers, disconnected limbs, mutation, mutated, ugly, disgusting, blurry, amputation",
|
442 |
+
512, 512, "2416282124261060"
|
443 |
+
],
|
444 |
+
# 4-MajicMix
|
445 |
+
[
|
446 |
+
"majicmixRealistic_v5Preview.safetensors",
|
447 |
+
"mm_sd_v14.ckpt",
|
448 |
+
"1girl, offshoulder, light smile, shiny skin best quality, masterpiece, photorealistic",
|
449 |
+
"bad hand, worst quality, low quality, normal quality, lowres, bad anatomy, bad hands, watermark, moles",
|
450 |
+
512, 512, "7132772652786303"
|
451 |
+
],
|
452 |
+
# 5-RealisticVision
|
453 |
+
[
|
454 |
+
"realisticVisionV20_v20.safetensors",
|
455 |
+
"mm_sd_v15.ckpt",
|
456 |
+
"photo of coastline, rocks, storm weather, wind, waves, lightning, 8k uhd, dslr, soft lighting, high quality, film grain, Fujifilm XT3",
|
457 |
+
"blur, haze, deformed iris, deformed pupils, semi-realistic, cgi, 3d, render, sketch, cartoon, drawing, anime, mutated hands and fingers, deformed, distorted, disfigured, poorly drawn, bad anatomy, wrong anatomy, extra limb, missing limb, floating limbs, disconnected limbs, mutation, mutated, ugly, disgusting, amputation",
|
458 |
+
512, 512, "1490157606650685400"
|
459 |
+
]
|
460 |
+
]
|
461 |
+
|
462 |
+
|
463 |
+
def ui():
|
464 |
+
with gr.Blocks(css=css) as demo:
|
465 |
+
gr.Markdown(
|
466 |
+
"""
|
467 |
+
# AnimateDiff: Animate Your Personalized Text-to-Image Diffusion Models without Specific Tuning
|
468 |
+
Yuwei Guo, Ceyuan Yang*, Anyi Rao, Yaohui Wang, Yu Qiao, Dahua Lin, Bo Dai (*Corresponding Author)<br>
|
469 |
+
[Arxiv Report](https://arxiv.org/abs/2307.04725) | [Project Page](https://animatediff.github.io/) | [Github](https://github.com/guoyww/animatediff/)
|
470 |
+
"""
|
471 |
+
)
|
472 |
+
gr.Markdown(
|
473 |
+
"""
|
474 |
+
### Quick Start
|
475 |
+
1. Select desired `Base DreamBooth Model`.
|
476 |
+
2. Select `Motion Module` from `mm_sd_v14.ckpt` and `mm_sd_v15.ckpt`. We recommend trying both of them for the best results.
|
477 |
+
3. Provide `Prompt` and `Negative Prompt` for each model. You are encouraged to refer to each model's webpage on CivitAI to learn how to write prompts for them. Below are the DreamBooth models in this demo. Click to visit their homepage.
|
478 |
+
- [`toonyou_beta3.safetensors`](https://civitai.com/models/30240?modelVersionId=78775)
|
479 |
+
- [`lyriel_v16.safetensors`](https://civitai.com/models/22922/lyriel)
|
480 |
+
- [`rcnzCartoon3d_v10.safetensors`](https://civitai.com/models/66347?modelVersionId=71009)
|
481 |
+
- [`majicmixRealistic_v5Preview.safetensors`](https://civitai.com/models/43331?modelVersionId=79068)
|
482 |
+
- [`realisticVisionV20_v20.safetensors`](https://civitai.com/models/4201?modelVersionId=29460)
|
483 |
+
4. Click `Generate`, wait for ~1 min, and enjoy.
|
484 |
+
"""
|
485 |
+
)
|
486 |
+
with gr.Row():
|
487 |
+
with gr.Column():
|
488 |
+
base_model_dropdown = gr.Dropdown( label="Base DreamBooth Model", choices=c.base_model_list, value=c.base_model_list[0], interactive=True )
|
489 |
+
motion_module_dropdown = gr.Dropdown( label="Motion Module", choices=c.motion_module_list, value=c.motion_module_list[0], interactive=True )
|
490 |
+
|
491 |
+
base_model_dropdown.change(fn=c.update_base_model, inputs=[base_model_dropdown], outputs=[base_model_dropdown])
|
492 |
+
motion_module_dropdown.change(fn=c.update_motion_module, inputs=[motion_module_dropdown], outputs=[motion_module_dropdown])
|
493 |
+
|
494 |
+
prompt_textbox = gr.Textbox( label="Prompt", lines=3 )
|
495 |
+
negative_prompt_textbox = gr.Textbox( label="Negative Prompt", lines=3, value="worst quality, low quality, nsfw, logo")
|
496 |
+
|
497 |
+
with gr.Accordion("Advance", open=False):
|
498 |
+
with gr.Row():
|
499 |
+
width_slider = gr.Slider( label="Width", value=512, minimum=256, maximum=1024, step=64 )
|
500 |
+
height_slider = gr.Slider( label="Height", value=512, minimum=256, maximum=1024, step=64 )
|
501 |
+
with gr.Row():
|
502 |
+
seed_textbox = gr.Textbox( label="Seed", value=-1)
|
503 |
+
seed_button = gr.Button(value="\U0001F3B2", elem_classes="toolbutton")
|
504 |
+
seed_button.click(fn=lambda: gr.Textbox.update(value=random.randint(1, 1e16)), inputs=[], outputs=[seed_textbox])
|
505 |
+
|
506 |
+
generate_button = gr.Button( value="Generate", variant='primary' )
|
507 |
+
|
508 |
+
with gr.Column():
|
509 |
+
result_video = gr.Video( label="Generated Animation", interactive=False )
|
510 |
+
json_config = gr.Json( label="Config", value=None )
|
511 |
+
|
512 |
+
inputs = [base_model_dropdown, motion_module_dropdown, prompt_textbox, negative_prompt_textbox, width_slider, height_slider, seed_textbox]
|
513 |
+
outputs = [result_video, json_config]
|
514 |
+
|
515 |
+
generate_button.click( fn=c.run_once, inputs=inputs, outputs=outputs )
|
516 |
+
|
517 |
+
gr.Examples( fn=c.run_once(), examples=examples, inputs=inputs, outputs=outputs, cache_examples=True )
|
518 |
+
|
519 |
+
return demo
|
520 |
+
|
521 |
|
|
|
|
|
522 |
if __name__ == "__main__":
|
523 |
+
demo = ui()
|
524 |
+
demo.queue(max_size=20)
|
525 |
+
demo.launch(server_port=8860)
|