Spaces:
Runtime error
Runtime error
Commit
•
74395e4
1
Parent(s):
94f5b13
Update app.py
Browse files
app.py
CHANGED
@@ -190,7 +190,19 @@ def update_selection(selected_state: gr.SelectData, sdxl_loras, is_new=False):
|
|
190 |
gr.Gallery(selected_index=None)
|
191 |
)
|
192 |
|
193 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
194 |
def check_selected(selected_state):
|
195 |
if not selected_state:
|
196 |
raise gr.Error("You must select a LoRA")
|
@@ -425,6 +437,12 @@ with gr.Blocks(css="custom.css") as demo:
|
|
425 |
inputs=[selected_state],
|
426 |
queue=False,
|
427 |
show_progress=False
|
|
|
|
|
|
|
|
|
|
|
|
|
428 |
).success(
|
429 |
fn=run_lora,
|
430 |
inputs=[photo, prompt, negative, weight, selected_state, face_strength, image_strength, guidance_scale, depth_control_scale, gr_sdxl_loras, gr_sdxl_loras_new],
|
@@ -435,6 +453,12 @@ with gr.Blocks(css="custom.css") as demo:
|
|
435 |
inputs=[selected_state],
|
436 |
queue=False,
|
437 |
show_progress=False
|
|
|
|
|
|
|
|
|
|
|
|
|
438 |
).success(
|
439 |
fn=run_lora,
|
440 |
inputs=[photo, prompt, negative, weight, selected_state, face_strength, image_strength, guidance_scale, depth_control_scale, gr_sdxl_loras, gr_sdxl_loras_new],
|
|
|
190 |
gr.Gallery(selected_index=None)
|
191 |
)
|
192 |
|
193 |
+
def center_crop_image_as_square(img):
|
194 |
+
square_size = min(img.size) # Use the smaller dimension of the image
|
195 |
+
|
196 |
+
# Calculate the coordinates of the crop box
|
197 |
+
left = (img.width - square_size) / 2
|
198 |
+
top = (img.height - square_size) / 2
|
199 |
+
right = (img.width + square_size) / 2
|
200 |
+
bottom = (img.height + square_size) / 2
|
201 |
+
|
202 |
+
# Perform the crop
|
203 |
+
img_cropped = img.crop((left, top, right, bottom))
|
204 |
+
return img_cropped
|
205 |
+
|
206 |
def check_selected(selected_state):
|
207 |
if not selected_state:
|
208 |
raise gr.Error("You must select a LoRA")
|
|
|
437 |
inputs=[selected_state],
|
438 |
queue=False,
|
439 |
show_progress=False
|
440 |
+
).success(
|
441 |
+
fn=center_crop_image_as_square,
|
442 |
+
inputs=[photo],
|
443 |
+
outputs=[photo],
|
444 |
+
queue=False,
|
445 |
+
show_progress=False,
|
446 |
).success(
|
447 |
fn=run_lora,
|
448 |
inputs=[photo, prompt, negative, weight, selected_state, face_strength, image_strength, guidance_scale, depth_control_scale, gr_sdxl_loras, gr_sdxl_loras_new],
|
|
|
453 |
inputs=[selected_state],
|
454 |
queue=False,
|
455 |
show_progress=False
|
456 |
+
).success(
|
457 |
+
fn=center_crop_image_as_square,
|
458 |
+
inputs=[photo],
|
459 |
+
outputs=[photo],
|
460 |
+
queue=False,
|
461 |
+
show_progress=False,
|
462 |
).success(
|
463 |
fn=run_lora,
|
464 |
inputs=[photo, prompt, negative, weight, selected_state, face_strength, image_strength, guidance_scale, depth_control_scale, gr_sdxl_loras, gr_sdxl_loras_new],
|