k-l-lambda commited on
Commit
5975e3b
1 Parent(s): ab0ddbd

app.py: fixed examples.

Browse files
Files changed (1) hide show
  1. app.py +13 -35
app.py CHANGED
@@ -172,7 +172,7 @@ def get_example ():
172
  case = [
173
  [
174
  './examples/yann-lecun_resize.jpg',
175
- './examples/poses/pose.jpg',
176
  'a man',
177
  'Spring Festival',
178
  '(lowres, low quality, worst quality:1.2), (text:1.2), watermark, (frame:1.2), deformed, ugly, deformed eyes, blur, out of focus, blurry, deformed cat, deformed, photo, anthropomorphic cat, monochrome, photo, pet collar, gun, weapon, blue, 3d, drones, drone, buildings in background, green',
@@ -209,32 +209,11 @@ def get_example ():
209
  return case
210
 
211
 
212
- def run_for_examples_with_key (novita_key):
213
- def run_for_examples (model_name, face_file, pose_file, prompt, style, negative_prompt):
214
- print('run_for_examples:', novita_key, face_file)
215
- #return generate_image(
216
- # novita_key,
217
- # model_name,
218
- # face_file,
219
- # pose_file,
220
- # prompt,
221
- # negative_prompt,
222
- # style,
223
- # 20, # num_steps
224
- # 0.8, # identitynet_strength_ratio
225
- # 0.8, # adapter_strength_ratio
226
- # 0.4, # pose_strength
227
- # 0.3, # canny_strength
228
- # 0.5, # depth_strength
229
- # ['pose', 'canny'], # controlnet_selection
230
- # 5.0, # guidance_scale
231
- # 42, # seed
232
- # 'Euler a', # scheduler
233
- # #False, # enable_LCM
234
- # True, # enable_Face_Region
235
- #)
236
- return None, gr.update(visible=True)
237
- return run_for_examples
238
 
239
 
240
  def generate_image (
@@ -552,14 +531,13 @@ with gr.Blocks(css=css) as demo:
552
  # queue=False,
553
  #)
554
 
555
- #gr.Examples(
556
- # examples=get_example(),
557
- # inputs=[model_name, face_file, pose_file, prompt, style, negative_prompt],
558
- # fn=run_for_examples_with_key(novita_key),
559
- # run_on_click=True,
560
- # outputs=[gallery, usage_tips],
561
- # cache_examples=True,
562
- #)
563
 
564
  gr.Markdown(article)
565
 
 
172
  case = [
173
  [
174
  './examples/yann-lecun_resize.jpg',
175
+ None,
176
  'a man',
177
  'Spring Festival',
178
  '(lowres, low quality, worst quality:1.2), (text:1.2), watermark, (frame:1.2), deformed, ugly, deformed eyes, blur, out of focus, blurry, deformed cat, deformed, photo, anthropomorphic cat, monochrome, photo, pet collar, gun, weapon, blue, 3d, drones, drone, buildings in background, green',
 
209
  return case
210
 
211
 
212
+ def load_example (face_file, pose_file, prompt, style, negative_prompt):
213
+ name = os.path.basename(face_file).split('_')[0]
214
+ image = PIL.Image.open(open(f'./examples/generated/{name}.jpg', 'rb'))
215
+
216
+ return image, gr.update(visible=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
217
 
218
 
219
  def generate_image (
 
531
  # queue=False,
532
  #)
533
 
534
+ gr.Examples(
535
+ examples=get_example(),
536
+ inputs=[face_file, pose_file, prompt, style, negative_prompt],
537
+ fn=load_example,
538
+ outputs=[gallery, usage_tips],
539
+ cache_examples=True,
540
+ )
 
541
 
542
  gr.Markdown(article)
543