Spaces:
Running
on
Zero
Running
on
Zero
amildravid4292
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -433,70 +433,109 @@ intro = """
|
|
433 |
|
434 |
with gr.Blocks(css="style.css") as demo:
|
435 |
gr.HTML(intro)
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
448 |
|
|
|
|
|
449 |
|
450 |
-
|
451 |
-
|
452 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
453 |
|
454 |
-
prompt1 = gr.Textbox(label="Prompt",
|
455 |
-
info="Make sure to include 'sks person'" ,
|
456 |
-
placeholder="sks person",
|
457 |
-
value="sks person")
|
458 |
-
seed1 = gr.Number(value=5, label="Seed", precision=0, interactive=True)
|
459 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
460 |
|
461 |
-
|
462 |
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
|
470 |
-
|
471 |
-
|
472 |
-
with gr.Accordion("Advanced Options", open=False):
|
473 |
-
cfg1= gr.Slider(label="CFG", value=3.0, step=0.1, minimum=0, maximum=10, interactive=True)
|
474 |
-
steps1 = gr.Slider(label="Inference Steps", value=50, step=1, minimum=0, maximum=100, interactive=True)
|
475 |
-
negative_prompt1 = gr.Textbox(label="Negative Prompt", placeholder="low quality, blurry, unfinished, nudity, weapon", value="low quality, blurry, unfinished, nudity, weapon")
|
476 |
-
injection_step = gr.Slider(label="Injection Step", value=800, step=1, minimum=0, maximum=1000, interactive=True)
|
477 |
-
|
478 |
-
|
479 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
480 |
|
481 |
-
|
482 |
-
|
483 |
|
|
|
|
|
|
|
484 |
|
485 |
-
|
486 |
-
|
|
|
487 |
sample.click(fn=sample_then_run, outputs=[image_slider, file_output])
|
488 |
|
489 |
-
|
490 |
submit1.click(fn=edit_inference, inputs=[ prompt1, negative_prompt1, cfg1, steps1, seed1, injection_step, a1, a2, a3, a4], outputs=image_slider)
|
491 |
file_input.change(fn=file_upload, inputs=file_input, outputs = image_slider)
|
492 |
|
493 |
|
494 |
|
495 |
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
|
501 |
|
502 |
|
|
|
433 |
|
434 |
with gr.Blocks(css="style.css") as demo:
|
435 |
gr.HTML(intro)
|
436 |
+
with gr.Tab("Model Editing"):
|
437 |
+
gr.Markdown("""
|
438 |
+
Click sample (to sample an identity) *or* upload an image & click `invert` to get started ✨
|
439 |
+
> 💡 When inverting, draw a mask over the face for improved results.
|
440 |
+
> To use a model previously downloaded from this demo see `Uplaoding a model` in the `Advanced options`
|
441 |
+
""")
|
442 |
+
with gr.Column():
|
443 |
+
with gr.Row():
|
444 |
+
with gr.Column():
|
445 |
+
sample = gr.Button("🎲 Sample New Model")
|
446 |
+
file_output = gr.File(label="Download Sampled Model", container=True, interactive=False)
|
447 |
+
file_input = gr.File(label="Upload Model", container=True)
|
448 |
+
|
449 |
+
|
450 |
+
# invert_button = gr.Button("⏪ Invert")
|
451 |
+
with gr.Column():
|
452 |
+
image_slider = ImageSlider(position=0.5, type="pil", height=512, width=512)
|
453 |
+
|
454 |
+
prompt1 = gr.Textbox(label="Prompt",
|
455 |
+
info="Make sure to include 'sks person'" ,
|
456 |
+
placeholder="sks person",
|
457 |
+
value="sks person")
|
458 |
+
seed1 = gr.Number(value=5, label="Seed", precision=0, interactive=True)
|
459 |
|
460 |
+
|
461 |
+
|
462 |
|
463 |
+
with gr.Row():
|
464 |
+
a1 = gr.Slider(label="- Young +", value=0, step=0.001, minimum=-1, maximum=1, interactive=True)
|
465 |
+
a2 = gr.Slider(label="- Pointy Nose +", value=0, step=0.001, minimum=-1, maximum=1, interactive=True)
|
466 |
+
with gr.Row():
|
467 |
+
a3 = gr.Slider(label="- Curly Hair +", value=0, step=0.001, minimum=-1, maximum=1, interactive=True)
|
468 |
+
a4 = gr.Slider(label="- Thick Eyebrows +", value=0, step=0.001, minimum=-1, maximum=1, interactive=True)
|
469 |
+
|
470 |
+
|
471 |
+
|
472 |
+
with gr.Accordion("Advanced Options", open=False):
|
473 |
+
cfg1= gr.Slider(label="CFG", value=3.0, step=0.1, minimum=0, maximum=10, interactive=True)
|
474 |
+
steps1 = gr.Slider(label="Inference Steps", value=50, step=1, minimum=0, maximum=100, interactive=True)
|
475 |
+
negative_prompt1 = gr.Textbox(label="Negative Prompt", placeholder="low quality, blurry, unfinished, nudity, weapon", value="low quality, blurry, unfinished, nudity, weapon")
|
476 |
+
injection_step = gr.Slider(label="Injection Step", value=800, step=1, minimum=0, maximum=1000, interactive=True)
|
477 |
+
|
478 |
+
|
479 |
|
|
|
|
|
|
|
|
|
|
|
480 |
|
481 |
+
submit1 = gr.Button("Generate")
|
482 |
+
|
483 |
+
with gr.Tab("Inversion"):
|
484 |
+
with gr.Column():
|
485 |
+
input_image = gr.ImageEditor(elem_id="image_upload", type='pil', label="Upload image and draw to define mask", height=512, width=512, brush=gr.Brush(), layers=False)
|
486 |
+
lr = gr.Number(value=1e-1, label="Learning Rate", interactive=True)
|
487 |
+
pcs = gr.Slider(label="# Principal Components", value=10000, step=1, minimum=1, maximum=10000, interactive=True)
|
488 |
+
epochs = gr.Slider(label="Epochs", value=400, step=1, minimum=1, maximum=2000, interactive=True)
|
489 |
+
weight_decay = gr.Number(value=1e-10, label="Weight Decay", interactive=True)
|
490 |
+
|
491 |
+
with gr.Column():
|
492 |
+
image_slider = ImageSlider(position=0.5, type="pil", height=512, width=512)
|
493 |
+
|
494 |
+
prompt1 = gr.Textbox(label="Prompt",
|
495 |
+
info="Make sure to include 'sks person'" ,
|
496 |
+
placeholder="sks person",
|
497 |
+
value="sks person")
|
498 |
+
seed1 = gr.Number(value=5, label="Seed", precision=0, interactive=True)
|
499 |
+
|
500 |
+
|
501 |
|
|
|
502 |
|
503 |
+
with gr.Row():
|
504 |
+
a1 = gr.Slider(label="- Young +", value=0, step=0.001, minimum=-1, maximum=1, interactive=True)
|
505 |
+
a2 = gr.Slider(label="- Pointy Nose +", value=0, step=0.001, minimum=-1, maximum=1, interactive=True)
|
506 |
+
with gr.Row():
|
507 |
+
a3 = gr.Slider(label="- Curly Hair +", value=0, step=0.001, minimum=-1, maximum=1, interactive=True)
|
508 |
+
a4 = gr.Slider(label="- Thick Eyebrows +", value=0, step=0.001, minimum=-1, maximum=1, interactive=True)
|
509 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
510 |
|
511 |
+
|
512 |
+
with gr.Accordion("Advanced Options", open=False):
|
513 |
+
cfg1= gr.Slider(label="CFG", value=3.0, step=0.1, minimum=0, maximum=10, interactive=True)
|
514 |
+
steps1 = gr.Slider(label="Inference Steps", value=50, step=1, minimum=0, maximum=100, interactive=True)
|
515 |
+
negative_prompt1 = gr.Textbox(label="Negative Prompt", placeholder="low quality, blurry, unfinished, nudity, weapon", value="low quality, blurry, unfinished, nudity, weapon")
|
516 |
+
injection_step = gr.Slider(label="Injection Step", value=800, step=1, minimum=0, maximum=1000, interactive=True)
|
517 |
+
|
518 |
+
|
519 |
+
|
520 |
|
521 |
+
submit2 = gr.Button("Generate")
|
|
|
522 |
|
523 |
+
|
524 |
+
|
525 |
+
|
526 |
|
527 |
+
|
528 |
+
|
529 |
+
|
530 |
sample.click(fn=sample_then_run, outputs=[image_slider, file_output])
|
531 |
|
532 |
+
|
533 |
submit1.click(fn=edit_inference, inputs=[ prompt1, negative_prompt1, cfg1, steps1, seed1, injection_step, a1, a2, a3, a4], outputs=image_slider)
|
534 |
file_input.change(fn=file_upload, inputs=file_input, outputs = image_slider)
|
535 |
|
536 |
|
537 |
|
538 |
|
|
|
|
|
|
|
|
|
539 |
|
540 |
|
541 |
|