Alexander Bagus commited on
Commit
6936a77
·
1 Parent(s): 507a133
Files changed (3) hide show
  1. app.py +6 -18
  2. examples/0_examples.json +7 -6
  3. static/header.html +1 -1
app.py CHANGED
@@ -91,21 +91,9 @@ def generate_lora(
91
  ulid = str(ULID()).lower()[:12]
92
  print(f"ulid: {ulid}")
93
 
94
- # print("before: ", input_images)
95
- # input_images = [item[0] for item in input_images]
96
  input_images = [Image.open(filepath) for filepath, _ in input_images]
97
- # print("after: ", input_images)
98
  if not input_images:
99
  print("images are empty.")
100
- # Load images
101
- # images = [
102
- # Image.open("examples/style/1/0.jpg"),
103
- # Image.open("examples/style/1/1.jpg"),
104
- # Image.open("examples/style/1/2.jpg"),
105
- # Image.open("examples/style/1/3.jpg"),
106
- # Image.open("examples/style/1/4.jpg"),
107
- # ]
108
-
109
 
110
  # Model inference
111
  with torch.no_grad():
@@ -117,7 +105,7 @@ def generate_lora(
117
 
118
  save_file(lora, lora_path)
119
 
120
- return lora_name, gr.update(visible=True, value=lora_path), gr.update(visible=True)
121
 
122
  @spaces.GPU
123
  def generate_image(
@@ -199,7 +187,7 @@ with gr.Blocks() as demo:
199
  with gr.Column():
200
  lora_name = gr.Textbox(label="Generated LoRA path",lines=2, interactive=False)
201
  lora_download = gr.DownloadButton(label=f"Download LoRA", visible=False)
202
- with gr.Column(visible=False, elem_id='imagen-container') as imagen_container:
203
  gr.Markdown("### After your LoRA is ready, you can try generate image here.")
204
  with gr.Row():
205
  with gr.Column():
@@ -208,11 +196,11 @@ with gr.Blocks() as demo:
208
  show_label=False,
209
  lines=2,
210
  placeholder="Enter your prompt",
211
- value="a man in a fishing boat. high quality, detailed",
212
  container=False,
213
  )
214
 
215
- imagen_button = gr.Button("Generate Image", variant="primary")
216
  with gr.Accordion("Advanced Settings", open=False):
217
  negative_prompt = gr.Textbox(
218
  label="Negative prompt",
@@ -264,7 +252,7 @@ with gr.Blocks() as demo:
264
  with gr.Column():
265
  output_image = gr.Image(label="Generated image", show_label=False)
266
 
267
- # gr.Examples(examples=examples, inputs=[input_image])
268
  gr.Markdown(read_file("static/footer.md"))
269
 
270
  lora_button.click(
@@ -272,7 +260,7 @@ with gr.Blocks() as demo:
272
  inputs=[
273
  input_images
274
  ],
275
- outputs=[lora_name, lora_download, imagen_container],
276
  )
277
  imagen_button.click(
278
  fn=generate_image,
 
91
  ulid = str(ULID()).lower()[:12]
92
  print(f"ulid: {ulid}")
93
 
 
 
94
  input_images = [Image.open(filepath) for filepath, _ in input_images]
 
95
  if not input_images:
96
  print("images are empty.")
 
 
 
 
 
 
 
 
 
97
 
98
  # Model inference
99
  with torch.no_grad():
 
105
 
106
  save_file(lora, lora_path)
107
 
108
+ return lora_name, gr.update(visible=True, value=lora_path), gr.update(interactive=True)
109
 
110
  @spaces.GPU
111
  def generate_image(
 
187
  with gr.Column():
188
  lora_name = gr.Textbox(label="Generated LoRA path",lines=2, interactive=False)
189
  lora_download = gr.DownloadButton(label=f"Download LoRA", visible=False)
190
+ with gr.Column(elem_id='imagen-container') as imagen_container:
191
  gr.Markdown("### After your LoRA is ready, you can try generate image here.")
192
  with gr.Row():
193
  with gr.Column():
 
196
  show_label=False,
197
  lines=2,
198
  placeholder="Enter your prompt",
199
+ value="a man in a fishing boat.",
200
  container=False,
201
  )
202
 
203
+ imagen_button = gr.Button("Generate Image", variant="primary", interactive=False)
204
  with gr.Accordion("Advanced Settings", open=False):
205
  negative_prompt = gr.Textbox(
206
  label="Negative prompt",
 
252
  with gr.Column():
253
  output_image = gr.Image(label="Generated image", show_label=False)
254
 
255
+ gr.Examples(examples=examples, inputs=[input_images])
256
  gr.Markdown(read_file("static/footer.md"))
257
 
258
  lora_button.click(
 
260
  inputs=[
261
  input_images
262
  ],
263
+ outputs=[lora_name, lora_download, imagen_button],
264
  )
265
  imagen_button.click(
266
  fn=generate_image,
examples/0_examples.json CHANGED
@@ -1,8 +1,9 @@
1
  [
2
- "Saitama, punching",
3
- "Levi Ackerman, kick",
4
- "Goku, powering up",
5
- "Light Yagami, writing",
6
- "Naruto, eating ramen",
7
- "Luffy, grinning"
 
8
  ]
 
1
  [
2
+ [
3
+ "examples/style/1/0.jpg",
4
+ "examples/style/1/1.jpg",
5
+ "examples/style/1/2.jpg",
6
+ "examples/style/1/3.jpg",
7
+ "examples/style/1/4.jpg"
8
+ ]
9
  ]
static/header.html CHANGED
@@ -6,6 +6,6 @@
6
  <p>
7
  Generate LoRA from a few images.
8
  <br>
9
- If you like my work, please support me by visiting <a href="https://aisudo.com/" target="_blank">AiSudo</a> 😊
10
  </div>
11
  </div>
 
6
  <p>
7
  Generate LoRA from a few images.
8
  <br>
9
+ Demo by <a href="https://aisudo.com/" target="_blank">AiSudo</a> 😊
10
  </div>
11
  </div>