Spaces:
Paused
Paused
Muhammad Usman Nazir commited on
Commit ·
b18255a
1
Parent(s): d74d651
fix: add image resizing to maintain dimensions within MAX_DIM for segmentation bundle
Browse files
app.py
CHANGED
|
@@ -942,6 +942,10 @@ def build_segmentation_bundle(contents: bytes):
|
|
| 942 |
|
| 943 |
t0 = time.perf_counter()
|
| 944 |
img = Image.open(io.BytesIO(contents)).convert("RGB")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 945 |
img_np = np.array(img)
|
| 946 |
h, w = img_np.shape[:2]
|
| 947 |
min_floor_area = max(1200, int(w * h * 0.015))
|
|
|
|
| 942 |
|
| 943 |
t0 = time.perf_counter()
|
| 944 |
img = Image.open(io.BytesIO(contents)).convert("RGB")
|
| 945 |
+
MAX_DIM = 1280
|
| 946 |
+
if max(img.width, img.height) > MAX_DIM:
|
| 947 |
+
scale = MAX_DIM / max(img.width, img.height)
|
| 948 |
+
img = img.resize((int(img.width * scale), int(img.height * scale)), Image.LANCZOS)
|
| 949 |
img_np = np.array(img)
|
| 950 |
h, w = img_np.shape[:2]
|
| 951 |
min_floor_area = max(1200, int(w * h * 0.015))
|