Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -991,10 +991,15 @@ def predict_with_paper(image, paper_size, offset, offset_unit, finger_clearance=
|
|
991 |
# Remove background
|
992 |
objects_mask = remove_bg(cropped_image)
|
993 |
|
|
|
|
|
|
|
|
|
|
|
994 |
# Place back in full image space
|
995 |
full_mask = np.zeros((image.shape[0], image.shape[1]), dtype=np.uint8)
|
996 |
-
full_mask[y_min:y_max, x_min:x_max] =
|
997 |
-
|
998 |
# Light filtering only - don't exclude paper area aggressively
|
999 |
# Just remove small noise
|
1000 |
kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (3, 3))
|
|
|
991 |
# Remove background
|
992 |
objects_mask = remove_bg(cropped_image)
|
993 |
|
994 |
+
# Resize mask back to cropped image size
|
995 |
+
target_height = y_max - y_min
|
996 |
+
target_width = x_max - x_min
|
997 |
+
objects_mask_resized = cv2.resize(objects_mask, (target_width, target_height))
|
998 |
+
|
999 |
# Place back in full image space
|
1000 |
full_mask = np.zeros((image.shape[0], image.shape[1]), dtype=np.uint8)
|
1001 |
+
full_mask[y_min:y_max, x_min:x_max] = objects_mask_resized
|
1002 |
+
|
1003 |
# Light filtering only - don't exclude paper area aggressively
|
1004 |
# Just remove small noise
|
1005 |
kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (3, 3))
|