amildravid4292 commited on
Commit
5f7c6c7
·
verified ·
1 Parent(s): 2daf493

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -6
app.py CHANGED
@@ -408,11 +408,11 @@ intro = """
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
- gr.Markdown("""1) Either sample a new model, or upload an image (optionally draw a mask over the face) and click `invert`.""")
416
  input_image = gr.Image(source='upload', elem_id="image_upload", tool='sketch', type='pil', label="Upload image and draw to define mask",
417
  width=512, height=512, brush_color='#00FFFF', mask_opacity=0.4)
418
 
@@ -495,14 +495,22 @@ with gr.Blocks(css="style.css") as demo:
495
  help_text1 = """
496
  <b>Instructions</b>:
497
  1. To get results faster without waiting in queue, you can duplicate into a private space with an A100 GPU.
498
- 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 face in the image to obtain 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.
499
  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`.
500
  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.
501
  """
502
  help_text2 = """<b>Tips</b>:
503
- 1. Editing
504
- * Cropping the image so the face takes up a larger portion of the frame."""
505
-
 
 
 
 
 
 
 
 
506
  gr.Markdown(help_text1)
507
  gr.Markdown(help_text2)
508
 
 
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
+ gr.Markdown("""1) Either sample a new model, or upload an image (optionally draw a mask over the head) and click `invert`.""")
416
  input_image = gr.Image(source='upload', elem_id="image_upload", tool='sketch', type='pil', label="Upload image and draw to define mask",
417
  width=512, height=512, brush_color='#00FFFF', mask_opacity=0.4)
418
 
 
495
  help_text1 = """
496
  <b>Instructions</b>:
497
  1. To get results faster without waiting in queue, you can duplicate into a private space with an A100 GPU.
498
+ 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`.
499
  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`.
500
  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.
501
  """
502
  help_text2 = """<b>Tips</b>:
503
+ 1. Editing and Identity Generation
504
+ * 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. Although it is not always needed.
505
+ * 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.
506
+ * 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.
507
+ 2. Inversion
508
+ * To obtain the best results for inversion, upload a high resolution photo of the face with minimal occlusion. It is recommended to draw over the face and hair to define a mask. But inversion should still work generally for non-closeup face shots.
509
+ * For inverting a realistic photo of an identity, typically 800 epochs with lr=1e-1 and 10,000 principal components (PCs) works well. If the resulting generations have artifacted and unrealstic textures, there is probably overfitting and you may want to reduce the number of epochs or learning rate, or play with weight decay. If the generations do not look like the input photo, then you may want to increase the number of epochs.
510
+ * For inverting out-of-distribution identities, such as artistic renditions of people or non-humans (e.g. the ones shown in the paper), it is recommended to use 1000 PCs, lr=1, and train for 800 epochs.
511
+ * Note that if you change the number of PCs, you will probably need to change the learning rate. For less PCs, higher learning rates are typically required."""
512
+
513
+
514
  gr.Markdown(help_text1)
515
  gr.Markdown(help_text2)
516