amildravid4292 commited on
Commit
621123f
·
verified ·
1 Parent(s): af1e565

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -11
app.py CHANGED
@@ -388,9 +388,6 @@ def file_upload(file):
388
 
389
 
390
 
391
-
392
-
393
-
394
  intro = """
395
  <div style="display: flex;align-items: center;justify-content: center">
396
  <h1 style="margin-left: 12px;text-align: center;margin-bottom: 7px;display: inline-block">weights2weights</h1>
@@ -411,16 +408,25 @@ intro = """
411
  with gr.Blocks(css="style.css") as demo:
412
  gr.HTML(intro)
413
 
414
- gr.Markdown("""<div style="text-align: justify;"> Click below to sample an identity-encoding model, or upload an image below and click \"invert\". You can also optionally draw over the face to define a mask. To use model previously downloaded from this demo see \"Uplaoding a model\" in the Advanced options""")
415
  with gr.Column():
416
  with gr.Row():
417
  with gr.Column():
 
 
 
 
 
 
 
418
  input_image = gr.Image(source='upload', elem_id="image_upload", tool='sketch', type='pil', label="Upload image and draw to define mask",
419
  height=512, width=512, brush_color='#00FFFF', mask_opacity=0.6)
420
 
421
  with gr.Row():
422
- sample = gr.Button("🎲 Sample New Model")
423
  invert_button = gr.Button("⬆️ Invert")
 
 
 
424
  with gr.Column():
425
  gallery = gr.Image(label="Image",height=512, width=512, interactive=False)
426
 
@@ -469,24 +475,33 @@ with gr.Blocks(css="style.css") as demo:
469
  gr.Markdown("""<div style="text-align: justify;"> After sampling a new model or inverting, you can download the model below.""")
470
 
471
  with gr.Row():
472
- file_output = gr.File(label="Download Sampled Model", container=True, interactive=False)
473
 
474
 
475
 
476
 
477
 
478
- invert_button.click(fn=run_inversion,
479
  inputs=[input_image, pcs, epochs, weight_decay,lr],
480
- outputs = [gallery, file_output])
481
- sample.click(fn=sample_then_run, outputs=[gallery, file_output])
482
- submit.click(
 
 
 
 
483
  fn=edit_inference, inputs=[prompt, negative_prompt, cfg, steps, seed, injection_step, a1, a2, a3, a4], outputs=[gallery]
484
  )
485
- file_input.change(fn=file_upload, inputs=file_input, outputs = input_image)
 
 
486
 
487
 
488
 
 
 
489
 
 
490
 
491
 
492
 
 
388
 
389
 
390
 
 
 
 
391
  intro = """
392
  <div style="display: flex;align-items: center;justify-content: center">
393
  <h1 style="margin-left: 12px;text-align: center;margin-bottom: 7px;display: inline-block">weights2weights</h1>
 
408
  with gr.Blocks(css="style.css") as demo:
409
  gr.HTML(intro)
410
 
411
+ gr.Markdown("""<div style="text-align: justify;"> In this demo, you can get an identity-encoding model by sampling or inverting. To use a model previously downloaded from this demo see \"Uploading a model\" in the Advanced options. Next, you can generate new samples from it, or edit the identity encoded in the model and generate samples from the edited model. We provide detailed instructions and tips at the bottom of the page.""")
412
  with gr.Column():
413
  with gr.Row():
414
  with gr.Column():
415
+ with gr.Row():
416
+ gr.Markdown("""Click below to sample a new identity-encoding model.""")
417
+
418
+ with gr.Row():
419
+ sample = gr.Button("🎲 Sample New Model")
420
+
421
+ gr.Markdown("""Or upload an image and optionally draw over the face to define a mask. Then click `invert`. """)
422
  input_image = gr.Image(source='upload', elem_id="image_upload", tool='sketch', type='pil', label="Upload image and draw to define mask",
423
  height=512, width=512, brush_color='#00FFFF', mask_opacity=0.6)
424
 
425
  with gr.Row():
 
426
  invert_button = gr.Button("⬆️ Invert")
427
+
428
+
429
+
430
  with gr.Column():
431
  gallery = gr.Image(label="Image",height=512, width=512, interactive=False)
432
 
 
475
  gr.Markdown("""<div style="text-align: justify;"> After sampling a new model or inverting, you can download the model below.""")
476
 
477
  with gr.Row():
478
+ file_output = gr.File(label="Download Sampled/Inverted Model", container=True, interactive=False)
479
 
480
 
481
 
482
 
483
 
484
+ invert_button.click(fn=run_inversion,
485
  inputs=[input_image, pcs, epochs, weight_decay,lr],
486
+ outputs = [gallery, file_output])
487
+
488
+
489
+ sample.click(fn=sample_then_run, outputs=[gallery, file_output])
490
+
491
+
492
+ submit.click(
493
  fn=edit_inference, inputs=[prompt, negative_prompt, cfg, steps, seed, injection_step, a1, a2, a3, a4], outputs=[gallery]
494
  )
495
+ file_input.change(fn=file_upload, inputs=file_input, outputs = input_image)
496
+
497
+
498
 
499
 
500
 
501
+
502
+
503
 
504
+ demo.queue().launch(share=True)
505
 
506
 
507