Spaces:
Running
on
Zero
Running
on
Zero
Pierre Chapuis
commited on
fix bbox when resizing large vertical images
Browse files- src/app.py +2 -2
src/app.py
CHANGED
|
@@ -127,10 +127,10 @@ def _process(
|
|
| 127 |
) -> tuple[tuple[Image.Image, Image.Image], gr.DownloadButton]:
|
| 128 |
# enforce max dimensions for pymatting performance reasons
|
| 129 |
if img.width > 2048 or img.height > 2048:
|
| 130 |
-
|
| 131 |
img.thumbnail((2048, 2048))
|
| 132 |
if isinstance(prompt, tuple):
|
| 133 |
-
x0, y0, x1, y1 = (int(x * 2048 /
|
| 134 |
prompt = (x0, y0, x1, y1)
|
| 135 |
|
| 136 |
mask, bbox, time_log = _gpu_process(img, prompt)
|
|
|
|
| 127 |
) -> tuple[tuple[Image.Image, Image.Image], gr.DownloadButton]:
|
| 128 |
# enforce max dimensions for pymatting performance reasons
|
| 129 |
if img.width > 2048 or img.height > 2048:
|
| 130 |
+
orig_res = max(img.width, img.height)
|
| 131 |
img.thumbnail((2048, 2048))
|
| 132 |
if isinstance(prompt, tuple):
|
| 133 |
+
x0, y0, x1, y1 = (int(x * 2048 / orig_res) for x in prompt)
|
| 134 |
prompt = (x0, y0, x1, y1)
|
| 135 |
|
| 136 |
mask, bbox, time_log = _gpu_process(img, prompt)
|