Skip to content

Commit 8b2e8ed

Browse files
committed
new resize of polygons
1 parent 9e2fbbf commit 8b2e8ed

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

patched_yolo_infer/elements/CropElement.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ def resize_results(self):
100100
# from source_image_resized to source_image sizes transformation
101101
resized_xyxy = []
102102
resized_masks = []
103+
resized_polygons = []
103104

104105
for bbox in self.detected_xyxy_real:
105106
# Resize bbox coordinates
@@ -116,5 +117,12 @@ def resize_results(self):
116117
interpolation=cv2.INTER_NEAREST)
117118
resized_masks.append(mask_resized)
118119

120+
121+
for polygon in self.detected_polygons_real:
122+
polygon[:, 0] = (polygon[:, 0] * (self.source_image.shape[1] / self.source_image_resized.shape[1])).astype(np.uint16)
123+
polygon[:, 1] = (polygon[:, 1] * (self.source_image.shape[0] / self.source_image_resized.shape[0])).astype(np.uint16)
124+
resized_polygons.append(polygon)
125+
119126
self.detected_xyxy_real = resized_xyxy
120127
self.detected_masks_real = resized_masks
128+
self.detected_polygons_real = resized_polygons

patched_yolo_infer/nodes/MakeCropsDetectThem.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def __init__(
6868
show_crops=False,
6969
resize_initial_size=False,
7070
model=None,
71-
memory_optimize=False
71+
memory_optimize=True
7272
) -> None:
7373
if model is None:
7474
self.model = YOLO(model_path) # Load the model from the specified path

0 commit comments

Comments
 (0)