AmirMoris commited on
Commit
0055997
·
1 Parent(s): ff60762

feat: help text

Browse files
Files changed (2) hide show
  1. .idea/workspace.xml +1 -3
  2. app.py +21 -4
.idea/workspace.xml CHANGED
@@ -5,9 +5,7 @@
5
  </component>
6
  <component name="ChangeListManager">
7
  <list default="true" id="d268fe54-cb43-4451-8f43-ce4d20d5699c" name="Changes" comment="">
8
- <change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
9
  <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
10
- <change beforePath="$PROJECT_DIR$/Kaggle_API.py" beforeDir="false" afterPath="$PROJECT_DIR$/Kaggle_API.py" afterDir="false" />
11
  <change beforePath="$PROJECT_DIR$/app.py" beforeDir="false" afterPath="$PROJECT_DIR$/app.py" afterDir="false" />
12
  </list>
13
  <option name="SHOW_DIALOG" value="false" />
@@ -70,7 +68,7 @@
70
  <updated>1713919907805</updated>
71
  <workItem from="1713919910236" duration="1099000" />
72
  <workItem from="1713921043559" duration="495000" />
73
- <workItem from="1714055653743" duration="1152000" />
74
  </task>
75
  <servers />
76
  </component>
 
5
  </component>
6
  <component name="ChangeListManager">
7
  <list default="true" id="d268fe54-cb43-4451-8f43-ce4d20d5699c" name="Changes" comment="">
 
8
  <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
 
9
  <change beforePath="$PROJECT_DIR$/app.py" beforeDir="false" afterPath="$PROJECT_DIR$/app.py" afterDir="false" />
10
  </list>
11
  <option name="SHOW_DIALOG" value="false" />
 
68
  <updated>1713919907805</updated>
69
  <workItem from="1713919910236" duration="1099000" />
70
  <workItem from="1713921043559" duration="495000" />
71
+ <workItem from="1714055653743" duration="1771000" />
72
  </task>
73
  <servers />
74
  </component>
app.py CHANGED
@@ -17,6 +17,21 @@ DEFAULT_VALUES = {
17
  "resolution": 512,
18
  "edited_image": None
19
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  def generate_button_clicked(*args):
22
  # set kaggle-api variables
@@ -73,7 +88,8 @@ def generate_button_clicked(*args):
73
  if not status:
74
  raise gr.Error(img)
75
 
76
- return img
 
77
 
78
  def reset_button_clicked():
79
  return list(DEFAULT_VALUES.values())
@@ -120,6 +136,7 @@ def main():
120
  image_cfg_scale = gr.Number(value=DEFAULT_VALUES["image_cfg_scale"], label=f"Image CFG", interactive=True)
121
  resolution = gr.Number(value=DEFAULT_VALUES["resolution"], label=f"Resolution", interactive=True)
122
 
 
123
 
124
  generate_button.click(
125
  fn=generate_button_clicked,
@@ -134,7 +151,7 @@ def main():
134
  image_cfg_scale,
135
  resolution
136
  ],
137
- outputs=edited_image,
138
  )
139
  reset_button.click(
140
  fn=reset_button_clicked,
@@ -161,9 +178,9 @@ def main():
161
  """,
162
  )
163
 
164
- # Launch Gradio interface
165
 
166
- demo.queue(max_size=1)
 
167
  demo.launch(share=True)
168
 
169
 
 
17
  "resolution": 512,
18
  "edited_image": None
19
  }
20
+ HELP_TEXT = """
21
+ If you're not getting what you want, there may be a few reasons:
22
+ 1. Is the image not changing enough? Your Image CFG weight may be too high. This value dictates how similar the output should be to the input. It's possible your edit requires larger changes from the original image, and your Image CFG weight isn't allowing that. Alternatively, your Text CFG weight may be too low. This value dictates how much to listen to the text instruction. The default Image CFG of 1.5 and Text CFG of 7.5 are a good starting point, but aren't necessarily optimal for each edit. Try:
23
+ * Decreasing the Image CFG weight, or
24
+ * Incerasing the Text CFG weight, or
25
+ 2. Conversely, is the image changing too much, such that the details in the original image aren't preserved? Try:
26
+ * Increasing the Image CFG weight, or
27
+ * Decreasing the Text CFG weight
28
+ 3. Try generating results with different random seeds by setting "Randomize Seed" and running generation multiple times. You can also try setting "Randomize CFG" to sample new Text CFG and Image CFG values each time.
29
+ 4. Rephrasing the instruction sometimes improves results (e.g., "turn him into a dog" vs. "make him a dog" vs. "as a dog").
30
+ 5. Increasing the number of steps sometimes improves results.
31
+ 6. Do faces look weird? The Stable Diffusion autoencoder has a hard time with faces that are small in the image. Try:
32
+ * Cropping the image so the face takes up a larger portion of the frame.
33
+ """
34
+
35
 
36
  def generate_button_clicked(*args):
37
  # set kaggle-api variables
 
88
  if not status:
89
  raise gr.Error(img)
90
 
91
+ return [img, seed, cfgtext, cfgimage]
92
+
93
 
94
  def reset_button_clicked():
95
  return list(DEFAULT_VALUES.values())
 
136
  image_cfg_scale = gr.Number(value=DEFAULT_VALUES["image_cfg_scale"], label=f"Image CFG", interactive=True)
137
  resolution = gr.Number(value=DEFAULT_VALUES["resolution"], label=f"Resolution", interactive=True)
138
 
139
+ gr.Markdown(HELP_TEXT)
140
 
141
  generate_button.click(
142
  fn=generate_button_clicked,
 
151
  image_cfg_scale,
152
  resolution
153
  ],
154
+ outputs=[edited_image, seed, text_cfg_scale, image_cfg_scale],
155
  )
156
  reset_button.click(
157
  fn=reset_button_clicked,
 
178
  """,
179
  )
180
 
 
181
 
182
+ # Launch Gradio interface
183
+ demo.queue(max_size=1, concurrency_count=1)
184
  demo.launch(share=True)
185
 
186