multimodalart HF staff commited on
Commit
6ba990e
1 Parent(s): 2c247b9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -15
app.py CHANGED
@@ -167,8 +167,7 @@ def update_selection(selected_state: gr.SelectData, sdxl_loras, face_strength, i
167
  selected_state
168
  )
169
 
170
- def center_crop_image_as_square(images):
171
- img = images[0]
172
  square_size = min(img.size)
173
 
174
  left = (img.width - square_size) / 2
@@ -177,7 +176,7 @@ def center_crop_image_as_square(images):
177
  bottom = (img.height + square_size) / 2
178
 
179
  img_cropped = img.crop((left, top, right, bottom))
180
- return (img_cropped, None)
181
 
182
  def check_selected(selected_state):
183
  if not selected_state:
@@ -209,6 +208,7 @@ def merge_incompatible_lora(full_path_lora, lora_scale):
209
  def run_lora(images, prompt, negative, lora_scale, selected_state, face_strength, image_strength, guidance_scale, depth_control_scale, sdxl_loras, progress=gr.Progress(track_tqdm=True)):
210
  global last_lora, last_merged, last_fused, pipe
211
  face_image = images[0]
 
212
  face_info = app.get(cv2.cvtColor(np.array(face_image), cv2.COLOR_RGB2BGR))
213
  face_info = sorted(face_info, key=lambda x:(x['bbox'][2]-x['bbox'][0])*x['bbox'][3]-x['bbox'][1])[-1] # only use the maximum face
214
  face_emb = face_info['embedding']
@@ -390,12 +390,6 @@ with gr.Blocks(css="custom.css") as demo:
390
  inputs=[selected_state],
391
  queue=False,
392
  show_progress=False
393
- ).success(
394
- fn=center_crop_image_as_square,
395
- inputs=[photo],
396
- outputs=[photo],
397
- queue=False,
398
- show_progress=False,
399
  ).success(
400
  fn=run_lora,
401
  inputs=[photo, prompt, negative, weight, selected_state, face_strength, image_strength, guidance_scale, depth_control_scale, gr_sdxl_loras],
@@ -406,12 +400,6 @@ with gr.Blocks(css="custom.css") as demo:
406
  inputs=[selected_state],
407
  queue=False,
408
  show_progress=False
409
- ).success(
410
- fn=center_crop_image_as_square,
411
- inputs=[photo],
412
- outputs=[photo],
413
- queue=False,
414
- show_progress=False,
415
  ).success(
416
  fn=run_lora,
417
  inputs=[photo, prompt, negative, weight, selected_state, face_strength, image_strength, guidance_scale, depth_control_scale, gr_sdxl_loras],
 
167
  selected_state
168
  )
169
 
170
+ def center_crop_image_as_square(img):
 
171
  square_size = min(img.size)
172
 
173
  left = (img.width - square_size) / 2
 
176
  bottom = (img.height + square_size) / 2
177
 
178
  img_cropped = img.crop((left, top, right, bottom))
179
+ return img_cropped
180
 
181
  def check_selected(selected_state):
182
  if not selected_state:
 
208
  def run_lora(images, prompt, negative, lora_scale, selected_state, face_strength, image_strength, guidance_scale, depth_control_scale, sdxl_loras, progress=gr.Progress(track_tqdm=True)):
209
  global last_lora, last_merged, last_fused, pipe
210
  face_image = images[0]
211
+ face_image = center_crop_image_as_square(face_image)
212
  face_info = app.get(cv2.cvtColor(np.array(face_image), cv2.COLOR_RGB2BGR))
213
  face_info = sorted(face_info, key=lambda x:(x['bbox'][2]-x['bbox'][0])*x['bbox'][3]-x['bbox'][1])[-1] # only use the maximum face
214
  face_emb = face_info['embedding']
 
390
  inputs=[selected_state],
391
  queue=False,
392
  show_progress=False
 
 
 
 
 
 
393
  ).success(
394
  fn=run_lora,
395
  inputs=[photo, prompt, negative, weight, selected_state, face_strength, image_strength, guidance_scale, depth_control_scale, gr_sdxl_loras],
 
400
  inputs=[selected_state],
401
  queue=False,
402
  show_progress=False
 
 
 
 
 
 
403
  ).success(
404
  fn=run_lora,
405
  inputs=[photo, prompt, negative, weight, selected_state, face_strength, image_strength, guidance_scale, depth_control_scale, gr_sdxl_loras],