multimodalart HF staff commited on
Commit
1f087be
1 Parent(s): 8873146

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -28,7 +28,7 @@ from pipeline_stable_diffusion_xl_instantid_img2img import StableDiffusionXLInst
28
  from controlnet_aux import ZoeDetector
29
 
30
  from compel import Compel, ReturnedEmbeddingsType
31
- from gradio_imageslider import ImageSlider
32
 
33
  with open("sdxl_loras.json", "r") as file:
34
  data = json.load(file)
@@ -205,13 +205,13 @@ def merge_incompatible_lora(full_path_lora, lora_scale):
205
  del lora_model
206
  gc.collect()
207
 
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
- print("Images:", images)
211
- print("Face image", images[0])
212
- face_image = images[0]
213
  face_image = center_crop_image_as_square(face_image)
214
- print("Cropped image:", face_image)
215
  face_info = app.get(cv2.cvtColor(np.array(face_image), cv2.COLOR_RGB2BGR))
216
  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
217
  face_emb = face_info['embedding']
@@ -301,7 +301,7 @@ def run_lora(images, prompt, negative, lora_scale, selected_state, face_strength
301
  ).images[0]
302
  last_lora = repo_name
303
  gc.collect()
304
- return (face_image, image), gr.update(visible=True)
305
 
306
  def shuffle_gallery(sdxl_loras):
307
  random.shuffle(sdxl_loras)
@@ -328,7 +328,7 @@ with gr.Blocks(css="custom.css") as demo:
328
  with gr.Row(elem_id="main_app"):
329
  with gr.Column(scale=2):
330
  with gr.Group(elem_id="gallery_box"):
331
- photo = ImageSlider(label="Upload a picture of yourself", interactive=True, type="pil")
332
  selected_loras = gr.Gallery(label="Selected LoRAs", height=80, show_share_button=False, visible=False, elem_id="gallery_selected", )
333
  order_gallery = gr.Radio(choices=["random", "likes"], value="random", label="Order by", elem_id="order_radio")
334
  #new_gallery = gr.Gallery(
 
28
  from controlnet_aux import ZoeDetector
29
 
30
  from compel import Compel, ReturnedEmbeddingsType
31
+ #from gradio_imageslider import ImageSlider
32
 
33
  with open("sdxl_loras.json", "r") as file:
34
  data = json.load(file)
 
205
  del lora_model
206
  gc.collect()
207
 
208
+ def run_lora(face_image, 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
+ #print("Images:", images)
211
+ #print("Face image", images[0])
212
+ #face_image = images[0]
213
  face_image = center_crop_image_as_square(face_image)
214
+ #print("Cropped image:", face_image)
215
  face_info = app.get(cv2.cvtColor(np.array(face_image), cv2.COLOR_RGB2BGR))
216
  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
217
  face_emb = face_info['embedding']
 
301
  ).images[0]
302
  last_lora = repo_name
303
  gc.collect()
304
+ return image, gr.update(visible=True)
305
 
306
  def shuffle_gallery(sdxl_loras):
307
  random.shuffle(sdxl_loras)
 
328
  with gr.Row(elem_id="main_app"):
329
  with gr.Column(scale=2):
330
  with gr.Group(elem_id="gallery_box"):
331
+ photo = gr.Image(label="Upload a picture of yourself", interactive=True, type="pil")
332
  selected_loras = gr.Gallery(label="Selected LoRAs", height=80, show_share_button=False, visible=False, elem_id="gallery_selected", )
333
  order_gallery = gr.Radio(choices=["random", "likes"], value="random", label="Order by", elem_id="order_radio")
334
  #new_gallery = gr.Gallery(