Spaces:
Paused
Paused
Commit
•
050c639
1
Parent(s):
32b0f65
Update app.py
Browse files
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, 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,7 +276,7 @@ def run_lora(face_image, prompt, negative, lora_scale, selected_state, face_stre
|
|
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,
|
@@ -339,12 +339,13 @@ with gr.Blocks(css="custom.css") as demo:
|
|
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.
|
343 |
-
image_strength = gr.Slider(0, 1, value=0.
|
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,7 +410,7 @@ with gr.Blocks(css="custom.css") as demo:
|
|
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,7 +420,7 @@ with gr.Blocks(css="custom.css") as demo:
|
|
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)
|
|
|
213 |
del lora_model
|
214 |
gc.collect()
|
215 |
|
216 |
+
def run_lora(face_image, prompt, negative, lora_scale, selected_state, face_strength, image_strength, guidance_scale, depth_control_scale, 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=1-image_strength,
|
280 |
control_image=images,
|
281 |
num_inference_steps=20,
|
282 |
guidance_scale = 7,
|
|
|
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.01, 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.15, step=0.01, label="Image strength", info="Higher values increase the similarity with the structure/colors 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 |
+
guidance_scale = gr.Slider(0, 50, value=7, step=0.1, label="Guidance Scale")
|
348 |
+
depth_control_scale = gr.Slider(0, 1, value=0.8, step=0.01, label="Zoe Depth ControlNet strenght")
|
349 |
with gr.Column(elem_id="extra_info"):
|
350 |
with gr.Accordion(
|
351 |
"Use it with: 🧨 diffusers, ComfyUI, Invoke AI, SD.Next, AUTO1111",
|
|
|
410 |
show_progress=False
|
411 |
).success(
|
412 |
fn=run_lora,
|
413 |
+
inputs=[photo, prompt, negative, weight, selected_state, face_strength, image_strength, guidance_scale, depth_control_scale, gr_sdxl_loras, gr_sdxl_loras_new],
|
414 |
outputs=[result, share_group],
|
415 |
)
|
416 |
button.click(
|
|
|
420 |
show_progress=False
|
421 |
).success(
|
422 |
fn=run_lora,
|
423 |
+
inputs=[photo, prompt, negative, weight, selected_state, face_strength, image_strength, guidance_scale, depth_control_scale, gr_sdxl_loras, gr_sdxl_loras_new],
|
424 |
outputs=[result, share_group],
|
425 |
)
|
426 |
share_button.click(None, [], [], js=share_js)
|