Spaces:
Running
on
Zero
Running
on
Zero
amildravid4292
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -386,7 +386,16 @@ def file_upload(file):
|
|
386 |
return image
|
387 |
|
388 |
|
389 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
390 |
|
391 |
intro = """
|
392 |
<div style="display: flex;align-items: center;justify-content: center">
|
@@ -476,6 +485,13 @@ with gr.Blocks(css="style.css") as demo:
|
|
476 |
|
477 |
|
478 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
479 |
|
480 |
|
481 |
invert_button.click(fn=run_inversion,
|
|
|
386 |
return image
|
387 |
|
388 |
|
389 |
+
def crop_image(image):
|
390 |
+
h, w, c = image.shape
|
391 |
+
if h < w:
|
392 |
+
offset = (w - h) // 2
|
393 |
+
image = image[:, offset:offset + h]
|
394 |
+
elif w < h:
|
395 |
+
offset = (h - w) // 2
|
396 |
+
image = image[offset:offset + w]
|
397 |
+
image = np.array(Image.fromarray(image).resize((512, 512)))
|
398 |
+
return image
|
399 |
|
400 |
intro = """
|
401 |
<div style="display: flex;align-items: center;justify-content: center">
|
|
|
485 |
|
486 |
|
487 |
|
488 |
+
input_image.upload(
|
489 |
+
fn = crop_image,
|
490 |
+
inputs = [input_image],
|
491 |
+
outputs = [input_image],
|
492 |
+
queue=False,
|
493 |
+
concurrency_limit=None,
|
494 |
+
)
|
495 |
|
496 |
|
497 |
invert_button.click(fn=run_inversion,
|