Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1026,11 +1026,15 @@ def predict_with_paper(image, paper_size, offset, offset_unit, finger_clearance=
|
|
| 1026 |
|
| 1027 |
# Resize mask to match cropped region and place back in original image space
|
| 1028 |
full_mask = np.zeros((orig_size[0], orig_size[1]), dtype=np.uint8)
|
|
|
|
| 1029 |
if cropped_image.shape[:2] != processed_size:
|
| 1030 |
resized_mask = cv2.resize(objects_mask, (cropped_image.shape[1], cropped_image.shape[0]))
|
| 1031 |
else:
|
| 1032 |
resized_mask = objects_mask
|
| 1033 |
-
|
|
|
|
|
|
|
|
|
|
| 1034 |
|
| 1035 |
# Remove paper area from mask to focus only on objects
|
| 1036 |
objects_mask = exclude_paper_area(full_mask, paper_contour)
|
|
@@ -1079,8 +1083,8 @@ def predict_with_paper(image, paper_size, offset, offset_unit, finger_clearance=
|
|
| 1079 |
# Generate DXF - scaling_factor should be in mm/px for proper DXF units
|
| 1080 |
dxf, finger_polygons, original_polygons = save_dxf_spline(
|
| 1081 |
contours,
|
| 1082 |
-
scaling_factor, # This should mm/px
|
| 1083 |
-
orig_size[0], # Use original image height
|
| 1084 |
finger_clearance=(finger_clearance == "On")
|
| 1085 |
)
|
| 1086 |
except FingerCutOverlapError as e:
|
|
|
|
| 1026 |
|
| 1027 |
# Resize mask to match cropped region and place back in original image space
|
| 1028 |
full_mask = np.zeros((orig_size[0], orig_size[1]), dtype=np.uint8)
|
| 1029 |
+
x_min, y_min = crop_offset # Use crop_offset to ensure defined variables
|
| 1030 |
if cropped_image.shape[:2] != processed_size:
|
| 1031 |
resized_mask = cv2.resize(objects_mask, (cropped_image.shape[1], cropped_image.shape[0]))
|
| 1032 |
else:
|
| 1033 |
resized_mask = objects_mask
|
| 1034 |
+
if x_min == 0 and y_min == 0 and cropped_image.shape[:2] == masked_input_image.shape[:2]:
|
| 1035 |
+
full_mask = resized_mask # No cropping occurred, use mask directly
|
| 1036 |
+
else:
|
| 1037 |
+
full_mask[y_min:y_min+resized_mask.shape[0], x_min:x_min+resized_mask.shape[1]] = resized_mask
|
| 1038 |
|
| 1039 |
# Remove paper area from mask to focus only on objects
|
| 1040 |
objects_mask = exclude_paper_area(full_mask, paper_contour)
|
|
|
|
| 1083 |
# Generate DXF - scaling_factor should be in mm/px for proper DXF units
|
| 1084 |
dxf, finger_polygons, original_polygons = save_dxf_spline(
|
| 1085 |
contours,
|
| 1086 |
+
scaling_factor, # This should be mm/px
|
| 1087 |
+
orig_size[0], # Use original image height
|
| 1088 |
finger_clearance=(finger_clearance == "On")
|
| 1089 |
)
|
| 1090 |
except FingerCutOverlapError as e:
|