k-l-lambda commited on
Commit
8e6bca2
1 Parent(s): a907317

app.py: enlarge target size for small reference image.

Browse files
Files changed (1) hide show
  1. app.py +11 -5
app.py CHANGED
@@ -256,7 +256,7 @@ def generate_image (
256
  seed,
257
  scheduler,
258
  #enable_LCM,
259
- enhance_face_region,
260
  progress=gr.Progress(track_tqdm=True),
261
  ):
262
  if face_image_path is None:
@@ -280,7 +280,13 @@ def generate_image (
280
 
281
  ref_image_path = pose_image_path if pose_image_path else face_image_path
282
  ref_image = PIL.Image.open(ref_image_path)
 
283
  width, height = ref_image.size
 
 
 
 
 
284
 
285
  CONTROLNET_DICT['pose']['strength'] = pose_strength
286
  CONTROLNET_DICT['canny']['strength'] = canny_strength
@@ -292,7 +298,7 @@ def generate_image (
292
  },
293
  'model_name': f'{model_name}.safetensors',
294
  'face_image_assets_ids': client.upload_assets([face_image_path]),
295
- 'ref_image_assets_ids': client.upload_assets([pose_image_path]) if pose_image_path else [],
296
  'prompt': prompt,
297
  'negative_prompt': negative_prompt,
298
  'controlnet': {
@@ -493,10 +499,10 @@ with gr.Blocks(css=css) as demo:
493
  scheduler = gr.Dropdown(
494
  label='Schedulers',
495
  choices=schedulers,
496
- value='Euler a',
497
  )
498
  randomize_seed = gr.Checkbox(label='Randomize seed', value=True)
499
- enhance_face_region = gr.Checkbox(label='Enhance non-face region', value=True)
500
 
501
  with gr.Column(scale=1):
502
  gallery = gr.Image(label='Generated Images')
@@ -534,7 +540,7 @@ with gr.Blocks(css=css) as demo:
534
  seed,
535
  scheduler,
536
  #enable_LCM,
537
- enhance_face_region,
538
  ],
539
  outputs=[gallery, usage_tips],
540
  )
 
256
  seed,
257
  scheduler,
258
  #enable_LCM,
259
+ #enhance_face_region,
260
  progress=gr.Progress(track_tqdm=True),
261
  ):
262
  if face_image_path is None:
 
280
 
281
  ref_image_path = pose_image_path if pose_image_path else face_image_path
282
  ref_image = PIL.Image.open(ref_image_path)
283
+
284
  width, height = ref_image.size
285
+ large_edge = max(width, height)
286
+ if large_edge < 1024:
287
+ scaling = 1024 / large_edge
288
+ width = int(width * scaling)
289
+ height = int(height * scaling)
290
 
291
  CONTROLNET_DICT['pose']['strength'] = pose_strength
292
  CONTROLNET_DICT['canny']['strength'] = canny_strength
 
298
  },
299
  'model_name': f'{model_name}.safetensors',
300
  'face_image_assets_ids': client.upload_assets([face_image_path]),
301
+ 'ref_image_assets_ids': client.upload_assets([ref_image_path]),
302
  'prompt': prompt,
303
  'negative_prompt': negative_prompt,
304
  'controlnet': {
 
499
  scheduler = gr.Dropdown(
500
  label='Schedulers',
501
  choices=schedulers,
502
+ value='Euler',
503
  )
504
  randomize_seed = gr.Checkbox(label='Randomize seed', value=True)
505
+ #enhance_face_region = gr.Checkbox(label='Enhance non-face region', value=True)
506
 
507
  with gr.Column(scale=1):
508
  gallery = gr.Image(label='Generated Images')
 
540
  seed,
541
  scheduler,
542
  #enable_LCM,
543
+ #enhance_face_region,
544
  ],
545
  outputs=[gallery, usage_tips],
546
  )