Pierre Chapuis commited on
Commit
fb667fe
1 Parent(s): e6062ad

fix bbox when resizing large vertical images

Browse files
Files changed (1) hide show
  1. 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
- orig_width = img.width
131
  img.thumbnail((2048, 2048))
132
  if isinstance(prompt, tuple):
133
- x0, y0, x1, y1 = (int(x * 2048 / orig_width) for x in prompt)
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)