Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -41,10 +41,6 @@ class ReferenceBoxNotDetectedError(Exception):
|
|
41 |
"""Raised when the reference box cannot be detected in the image"""
|
42 |
pass
|
43 |
|
44 |
-
class BoundaryExceedsError(Exception):
|
45 |
-
"""Raised when the optional boundary dimensions exceed allowed image dimensions."""
|
46 |
-
pass
|
47 |
-
|
48 |
class BoundaryOverlapError(Exception):
|
49 |
"""Raised when the optional boundary dimensions are too small and overlap with the inner contours."""
|
50 |
pass
|
@@ -390,11 +386,6 @@ def add_rectangular_boundary(doc, polygons_inch, boundary_length, boundary_width
|
|
390 |
if boundary_width_in <= inner_width + 2 * clearance_side or boundary_length_in <= inner_length + 2 * clearance_tb:
|
391 |
raise BoundaryOverlapError("Error: The specified boundary dimensions are too small and overlap with the inner contours. Please provide larger values.")
|
392 |
|
393 |
-
# Check if boundary exceeds image limits (1 inch less than image dimensions)
|
394 |
-
if image_height_in is not None and image_width_in is not None:
|
395 |
-
if boundary_length_in > (image_height_in - 2) or boundary_width_in > (image_width_in - 2):
|
396 |
-
raise BoundaryExceedsError("Error: The specified boundary dimensions exceed the allowed image dimensions. Please enter smaller values.")
|
397 |
-
|
398 |
# Calculate center of inner contours
|
399 |
center_x = (min_x + max_x) / 2
|
400 |
center_y = (min_y + max_y) / 2
|
@@ -539,17 +530,7 @@ def predict(
|
|
539 |
else:
|
540 |
boundary_length_in = boundary_length
|
541 |
boundary_width_in = boundary_width
|
542 |
-
|
543 |
-
# [Rest of the function remains exactly the same]
|
544 |
-
|
545 |
-
return (
|
546 |
-
cv2.cvtColor(output_img, cv2.COLOR_BGR2RGB),
|
547 |
-
outlines_color,
|
548 |
-
dxf_filepath,
|
549 |
-
dilated_mask,
|
550 |
-
str(scaling_factor)
|
551 |
-
)
|
552 |
-
|
553 |
# ---------------------
|
554 |
# 5) Remove background from the shrunked drawer image (main objects)
|
555 |
# ---------------------
|
|
|
41 |
"""Raised when the reference box cannot be detected in the image"""
|
42 |
pass
|
43 |
|
|
|
|
|
|
|
|
|
44 |
class BoundaryOverlapError(Exception):
|
45 |
"""Raised when the optional boundary dimensions are too small and overlap with the inner contours."""
|
46 |
pass
|
|
|
386 |
if boundary_width_in <= inner_width + 2 * clearance_side or boundary_length_in <= inner_length + 2 * clearance_tb:
|
387 |
raise BoundaryOverlapError("Error: The specified boundary dimensions are too small and overlap with the inner contours. Please provide larger values.")
|
388 |
|
|
|
|
|
|
|
|
|
|
|
389 |
# Calculate center of inner contours
|
390 |
center_x = (min_x + max_x) / 2
|
391 |
center_y = (min_y + max_y) / 2
|
|
|
530 |
else:
|
531 |
boundary_length_in = boundary_length
|
532 |
boundary_width_in = boundary_width
|
533 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
534 |
# ---------------------
|
535 |
# 5) Remove background from the shrunked drawer image (main objects)
|
536 |
# ---------------------
|