yanze commited on
Commit
6391fa9
·
1 Parent(s): ffd7981
Files changed (1) hide show
  1. app.py +8 -37
app.py CHANGED
@@ -16,6 +16,7 @@ import spaces
16
  import argparse
17
 
18
  import os
 
19
  import cv2
20
  import gradio as gr
21
  import numpy as np
@@ -36,6 +37,10 @@ args = parser.parse_args()
36
 
37
  huggingface_hub.login(os.getenv('HF_TOKEN'))
38
 
 
 
 
 
39
 
40
  class Generator:
41
  def __init__(self):
@@ -189,8 +194,8 @@ def create_demo():
189
  with gr.Row():
190
  with gr.Column():
191
  with gr.Row():
192
- ref_image1 = gr.Image(label="ref image 1", type="filepath", height=256)
193
- ref_image2 = gr.Image(label="ref image 2", type="filepath", height=256)
194
  with gr.Row():
195
  ref_task1 = gr.Dropdown(choices=["ip", "id", "style"], value="ip", label="task for ref image 1")
196
  ref_task2 = gr.Dropdown(choices=["ip", "id", "style"], value="ip", label="task for ref image 2")
@@ -254,12 +259,6 @@ def create_demo():
254
  'a perfume under spotlight',
255
  116150031980664704,
256
  ],
257
- ]
258
- gr.Examples(examples=example_inps, inputs=[ref_image1, ref_image2, ref_task1, ref_task2, prompt, seed], label='IP task', cache_examples='lazy',
259
- outputs=[output_image, debug_image, seed_output],
260
- fn=generate_image,)
261
-
262
- example_inps = [
263
  [
264
  'example_inputs/hinton.jpeg',
265
  None,
@@ -268,17 +267,6 @@ def create_demo():
268
  'portrait, Chibi',
269
  5443415087540486371,
270
  ],
271
- ]
272
- gr.Examples(
273
- examples=example_inps,
274
- inputs=[ref_image1, ref_image2, ref_task1, ref_task2, prompt, seed],
275
- label='ID task (similar to PuLID, will only refer to the face)',
276
- cache_examples='lazy',
277
- outputs=[output_image, debug_image, seed_output],
278
- fn=generate_image,
279
- )
280
-
281
- example_inps = [
282
  [
283
  'example_inputs/mickey.png',
284
  None,
@@ -295,12 +283,6 @@ def create_demo():
295
  'generate a same style image. A pavilion by the river, and the distant mountains are endless',
296
  5248066378927500767,
297
  ],
298
- ]
299
- gr.Examples(examples=example_inps, inputs=[ref_image1, ref_image2, ref_task1, ref_task2, prompt, seed], label='Style task', cache_examples='lazy',
300
- outputs=[output_image, debug_image, seed_output],
301
- fn=generate_image,)
302
-
303
- example_inps = [
304
  [
305
  'example_inputs/shirt.png',
306
  'example_inputs/skirt.jpeg',
@@ -317,17 +299,6 @@ def create_demo():
317
  'the woman wearing a dress, In the banquet hall',
318
  7698454872441022867,
319
  ],
320
- ]
321
- gr.Examples(
322
- examples=example_inps,
323
- inputs=[ref_image1, ref_image2, ref_task1, ref_task2, prompt, seed],
324
- label='Try-On task',
325
- cache_examples='lazy',
326
- outputs=[output_image, debug_image, seed_output],
327
- fn=generate_image,
328
- )
329
-
330
- example_inps = [
331
  [
332
  'example_inputs/dog1.png',
333
  'example_inputs/dog2.png',
@@ -356,7 +327,7 @@ def create_demo():
356
  gr.Examples(
357
  examples=example_inps,
358
  inputs=[ref_image1, ref_image2, ref_task1, ref_task2, prompt, seed],
359
- label='Multi IP',
360
  cache_examples='lazy',
361
  outputs=[output_image, debug_image, seed_output],
362
  fn=generate_image,
 
16
  import argparse
17
 
18
  import os
19
+ import shutil
20
  import cv2
21
  import gradio as gr
22
  import numpy as np
 
37
 
38
  huggingface_hub.login(os.getenv('HF_TOKEN'))
39
 
40
+ try:
41
+ shutil.rmtree('gradio_cached_examples')
42
+ except FileNotFoundError:
43
+ print("cache folder not exist")
44
 
45
  class Generator:
46
  def __init__(self):
 
194
  with gr.Row():
195
  with gr.Column():
196
  with gr.Row():
197
+ ref_image1 = gr.Image(label="ref image 1", type="numpy", height=256)
198
+ ref_image2 = gr.Image(label="ref image 2", type="numpy", height=256)
199
  with gr.Row():
200
  ref_task1 = gr.Dropdown(choices=["ip", "id", "style"], value="ip", label="task for ref image 1")
201
  ref_task2 = gr.Dropdown(choices=["ip", "id", "style"], value="ip", label="task for ref image 2")
 
259
  'a perfume under spotlight',
260
  116150031980664704,
261
  ],
 
 
 
 
 
 
262
  [
263
  'example_inputs/hinton.jpeg',
264
  None,
 
267
  'portrait, Chibi',
268
  5443415087540486371,
269
  ],
 
 
 
 
 
 
 
 
 
 
 
270
  [
271
  'example_inputs/mickey.png',
272
  None,
 
283
  'generate a same style image. A pavilion by the river, and the distant mountains are endless',
284
  5248066378927500767,
285
  ],
 
 
 
 
 
 
286
  [
287
  'example_inputs/shirt.png',
288
  'example_inputs/skirt.jpeg',
 
299
  'the woman wearing a dress, In the banquet hall',
300
  7698454872441022867,
301
  ],
 
 
 
 
 
 
 
 
 
 
 
302
  [
303
  'example_inputs/dog1.png',
304
  'example_inputs/dog2.png',
 
327
  gr.Examples(
328
  examples=example_inps,
329
  inputs=[ref_image1, ref_image2, ref_task1, ref_task2, prompt, seed],
330
+ label='row 1-4: IP task; row 5: ID task; row 6-7: Style task. row 8-9: Try-On task; row 10-12: Multi IP',
331
  cache_examples='lazy',
332
  outputs=[output_image, debug_image, seed_output],
333
  fn=generate_image,