multimodalart HF staff commited on
Commit
32b0f65
β€’
1 Parent(s): e572a73

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -213,7 +213,7 @@ def merge_incompatible_lora(full_path_lora, lora_scale):
213
  del lora_model
214
  gc.collect()
215
 
216
- def run_lora(face_image, prompt, negative, lora_scale, selected_state, sdxl_loras, sdxl_loras_new, progress=gr.Progress(track_tqdm=True)):
217
  global last_lora, last_merged, last_fused, pipe
218
  face_info = app.get(cv2.cvtColor(np.array(face_image), cv2.COLOR_RGB2BGR))
219
  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
@@ -276,11 +276,11 @@ def run_lora(face_image, prompt, negative, lora_scale, selected_state, sdxl_lora
276
  height=1024,
277
  image_embeds=face_emb,
278
  image=face_image,
279
- strength=0.85,
280
  control_image=images,
281
  num_inference_steps=20,
282
  guidance_scale = 7,
283
- controlnet_conditioning_scale=[0.8, 0.8],
284
  ).images[0]
285
  last_lora = repo_name
286
  gc.collect()
@@ -339,9 +339,12 @@ with gr.Blocks(css="custom.css") as demo:
339
  result = gr.Image(
340
  interactive=False, label="Generated Image", elem_id="result-image"
341
  )
 
 
342
  with gr.Accordion("Advanced options", open=False):
343
  negative = gr.Textbox(label="Negative Prompt")
344
- weight = gr.Slider(0, 10, value=0.8, step=0.1, label="LoRA weight")
 
345
  with gr.Column(elem_id="extra_info"):
346
  with gr.Accordion(
347
  "Use it with: 🧨 diffusers, ComfyUI, Invoke AI, SD.Next, AUTO1111",
@@ -406,7 +409,7 @@ with gr.Blocks(css="custom.css") as demo:
406
  show_progress=False
407
  ).success(
408
  fn=run_lora,
409
- inputs=[photo, prompt, negative, weight, selected_state, gr_sdxl_loras, gr_sdxl_loras_new],
410
  outputs=[result, share_group],
411
  )
412
  button.click(
@@ -416,7 +419,7 @@ with gr.Blocks(css="custom.css") as demo:
416
  show_progress=False
417
  ).success(
418
  fn=run_lora,
419
- inputs=[photo, prompt, negative, weight, selected_state, gr_sdxl_loras, gr_sdxl_loras_new],
420
  outputs=[result, share_group],
421
  )
422
  share_button.click(None, [], [], js=share_js)
 
213
  del lora_model
214
  gc.collect()
215
 
216
+ def run_lora(face_image, prompt, negative, lora_scale, selected_state, face_strength, image_strength, sdxl_loras, sdxl_loras_new, progress=gr.Progress(track_tqdm=True)):
217
  global last_lora, last_merged, last_fused, pipe
218
  face_info = app.get(cv2.cvtColor(np.array(face_image), cv2.COLOR_RGB2BGR))
219
  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
 
276
  height=1024,
277
  image_embeds=face_emb,
278
  image=face_image,
279
+ strength=image_strength,
280
  control_image=images,
281
  num_inference_steps=20,
282
  guidance_scale = 7,
283
+ controlnet_conditioning_scale=[face_strength, 0.8],
284
  ).images[0]
285
  last_lora = repo_name
286
  gc.collect()
 
339
  result = gr.Image(
340
  interactive=False, label="Generated Image", elem_id="result-image"
341
  )
342
+ face_strength = gr.Slider(0, 1, value=0.85, step=0.1, label="Face strength", info="Higher values increase the face likeness but reduce the creative liberty of the models")
343
+ image_strength = gr.Slider(0, 1, value=0.85, step=0.1, label="Image strength", info="Higher values increase the similarity with the structure of the original photo")
344
  with gr.Accordion("Advanced options", open=False):
345
  negative = gr.Textbox(label="Negative Prompt")
346
+ weight = gr.Slider(0, 10, value=0.9, step=0.1, label="LoRA weight")
347
+
348
  with gr.Column(elem_id="extra_info"):
349
  with gr.Accordion(
350
  "Use it with: 🧨 diffusers, ComfyUI, Invoke AI, SD.Next, AUTO1111",
 
409
  show_progress=False
410
  ).success(
411
  fn=run_lora,
412
+ inputs=[photo, prompt, negative, weight, selected_state, face_strength, image_strength, gr_sdxl_loras, gr_sdxl_loras_new],
413
  outputs=[result, share_group],
414
  )
415
  button.click(
 
419
  show_progress=False
420
  ).success(
421
  fn=run_lora,
422
+ inputs=[photo, prompt, negative, weight, selected_state, face_strength, image_strength, gr_sdxl_loras, gr_sdxl_loras_new],
423
  outputs=[result, share_group],
424
  )
425
  share_button.click(None, [], [], js=share_js)