amildravid4292 commited on
Commit
41d60da
·
verified ·
1 Parent(s): 52015f1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -11
app.py CHANGED
@@ -426,14 +426,15 @@ def file_upload(file, net):
426
 
427
  help_text1 = """
428
  <b>Instructions</b>:
429
- 1. To get results faster without waiting in queue, you can duplicate into a private space with an A100 GPU.
430
- 2. To begin, you will have to get an identity-encoding model. You can either sample one from *weights2weights* space by clicking `Sample New Model` or by uploading an image and clicking `invert` to invert the identity into a model. You can optionally draw over the head to define a mask in the image for better results. Sampling a model takes around 10 seconds and inversion takes around 2 minutes. After this is done, you can optionally download this model for later use. A model can be uploaded in the \"Uploading a model\" tab in the `Advanced Options`.
431
- 3. After getting a model, an image of the identity will be displayed on the right. You can sample from the model by changing seeds as well as prompts and then clicking `Generate`. Make sure to include \"sks person\" in your prompt to keep the same identity.
432
- 4. The identity in the model can be edited by changing the sliders for various attributes. After clicking `Generate`, you can see how the identity has changed and the effects are maintained across different seeds and prompts.
433
  """
434
  help_text2 = """<b>Tips</b>:
435
- 1. Editing and Identity Generation
436
- * If you are interested in preserving more of the image during identity-editing (i.e., where the same seed and prompt results in the same image with only the identity changed), you can play with the "Injection Step" parameter in the \"Sampling\" tab in the `Advanced Options`. During the first *n* timesteps, the original model's weights will be used, and then the edited weights will be set during the remaining steps. Values closer to 1000 will set the edited weights early, having a more pronounced effect, which may disrupt some semantics and structure of the generated image. Lower values will set the edited weights later, better preserving image context. We notice that around 600-800 tends to produce the best results. Larger values in the range (700-1000) are helpful for more global attribute changes, while smaller (400-700) can be used for more finegrained edits. Although it is not always needed.
 
437
  * You can play around with negative prompts, number of inference steps, and CFG in the \"Sampling\" tab in the `Advanced Options` to affect the ultimate image quality.
438
  * Sometimes the identity will not be perfectly consistent (e.g., there might be small variations of the face) when you use some seeds or prompts. This is a limitation of our method as well as an open-problem in personalized models.
439
  2. Inversion
@@ -469,7 +470,7 @@ with gr.Blocks(css="style.css") as demo:
469
  with gr.Column():
470
  with gr.Row():
471
  with gr.Column():
472
- gr.Markdown(""" ❶ Either a) sample a random identity by clicking `🎲 Sample random identity` **or** b) upload an image (optional - draw a mask over the head) then click `⬆️ Insert identity`""")
473
  input_image = gr.ImageEditor(elem_id="image_upload", type='pil', label="Reference Identity",
474
  width=512, height=512)
475
 
@@ -482,9 +483,9 @@ with gr.Blocks(css="style.css") as demo:
482
 
483
 
484
  with gr.Column():
485
- gr.Markdown("""❷ Generate new images of the identity from the model by entering different seeds and prompts and clicking `Generate`. Edit the encoded identity with the sliders and then visualize the edits with the generate button.""")
486
  gallery = gr.Image(label="Generated Image",height=512, width=512, interactive=False)
487
- submit = gr.Button("Generate")
488
 
489
 
490
  prompt = gr.Textbox(label="Prompt",
@@ -505,7 +506,7 @@ with gr.Blocks(css="style.css") as demo:
505
 
506
 
507
  with gr.Accordion("Advanced Options ⬇️", open=False):
508
- with gr.Tab("Generation"):
509
  with gr.Row():
510
  cfg= gr.Slider(label="CFG", value=3.0, step=0.1, minimum=0, maximum=10, interactive=True)
511
  steps = gr.Slider(label="Inference Steps", value=25, step=1, minimum=0, maximum=100, interactive=True)
@@ -513,7 +514,7 @@ with gr.Blocks(css="style.css") as demo:
513
  negative_prompt = gr.Textbox(label="Negative Prompt", placeholder="low quality, blurry, unfinished, nudity, weapon", value="low quality, blurry, unfinished, nudity, weapon")
514
  injection_step = gr.Slider(label="Injection Step", value=800, step=1, minimum=0, maximum=1000, interactive=True)
515
 
516
- with gr.Tab("Inversion"):
517
  with gr.Row():
518
  lr = gr.Number(value=1e-1, label="Learning Rate", interactive=True)
519
  pcs = gr.Slider(label="# Principal Components", value=10000, step=1, minimum=1, maximum=10000, interactive=True)
 
426
 
427
  help_text1 = """
428
  <b>Instructions</b>:
429
+ 1. To get results faster without waiting for a GPU, you can duplicate into a private space with an A100 GPU.
430
+ 2. To begin, you will have to get an identity-encoding model. You can either sample one from *weights2weights* space by clicking `🎲 Sample new identity` or by uploading an image and clicking `⬆️ Insert identity` to insert the identity into a model. You can optionally draw over the head to define a mask in the image for better results. Sampling a model takes around 10 seconds and inserting an identity takes around 15 seconds per 100 epochs. After this is done, you can optionally download this model for later use. A model can be uploaded in the \"Uploading a model\" tab in the `Advanced Options`.
431
+ 3. After getting a model, an image of the identity will be displayed on the left as a reference. You can sample from the model by changing seeds as well as prompts and then clicking `🖼️ Generate` to generate images in the right column. Make sure to include \"sks person\" in your prompt to keep the same identity.
432
+ 4. The identity in the model can be edited by changing the sliders for various attributes. After clicking `🖼️ Generate`, you can see how the identity has changed and the effects are maintained across different seeds and prompts.
433
  """
434
  help_text2 = """<b>Tips</b>:
435
+ 1. Identity Editing and Generation
436
+ * If you are interested in preserving more of the image during identity-editing (i.e., where the same seed and prompt results in the same image with only the identity changed), you can play with the "Injection Step" parameter in the \"Editing and Generation\" tab in the `Advanced Options`.
437
+ * During the first *n* timesteps, the original model's weights will be used, and then the edited weights will be set during the remaining steps. Values closer to 1000 will set the edited weights early, having a more pronounced effect, which may disrupt some semantics and structure of the generated image. Lower values will set the edited weights later, better preserving image context. We notice that around 600-800 tends to produce the best results. Larger values in the range (700-1000) are helpful for more global attribute changes, while smaller (400-700) can be used for more finegrained edits. Although it is not always needed.
438
  * You can play around with negative prompts, number of inference steps, and CFG in the \"Sampling\" tab in the `Advanced Options` to affect the ultimate image quality.
439
  * Sometimes the identity will not be perfectly consistent (e.g., there might be small variations of the face) when you use some seeds or prompts. This is a limitation of our method as well as an open-problem in personalized models.
440
  2. Inversion
 
470
  with gr.Column():
471
  with gr.Row():
472
  with gr.Column():
473
+ gr.Markdown("""❶ Either a) sample a random identity by clicking `🎲 Sample random identity` **or** b) upload an image (optional - draw a mask over the head) then click `⬆️ Insert identity`""")
474
  input_image = gr.ImageEditor(elem_id="image_upload", type='pil', label="Reference Identity",
475
  width=512, height=512)
476
 
 
483
 
484
 
485
  with gr.Column():
486
+ gr.Markdown("""❷ Generate new images of the identity from the model by entering different seeds and prompts and clicking `🖼️ Generate`. Edit the encoded identity with the sliders and then visualize the edits with the generate button.""")
487
  gallery = gr.Image(label="Generated Image",height=512, width=512, interactive=False)
488
+ submit = gr.Button("🖼️ Generate")
489
 
490
 
491
  prompt = gr.Textbox(label="Prompt",
 
506
 
507
 
508
  with gr.Accordion("Advanced Options ⬇️", open=False):
509
+ with gr.Tab("Editing and Generation"):
510
  with gr.Row():
511
  cfg= gr.Slider(label="CFG", value=3.0, step=0.1, minimum=0, maximum=10, interactive=True)
512
  steps = gr.Slider(label="Inference Steps", value=25, step=1, minimum=0, maximum=100, interactive=True)
 
514
  negative_prompt = gr.Textbox(label="Negative Prompt", placeholder="low quality, blurry, unfinished, nudity, weapon", value="low quality, blurry, unfinished, nudity, weapon")
515
  injection_step = gr.Slider(label="Injection Step", value=800, step=1, minimum=0, maximum=1000, interactive=True)
516
 
517
+ with gr.Tab("Inserting Identity"):
518
  with gr.Row():
519
  lr = gr.Number(value=1e-1, label="Learning Rate", interactive=True)
520
  pcs = gr.Slider(label="# Principal Components", value=10000, step=1, minimum=1, maximum=10000, interactive=True)