Spaces:
Running
Running
change margin with the size of a task
Browse files- modules/toXML.py +4 -4
modules/toXML.py
CHANGED
@@ -94,10 +94,10 @@ def align_x_coordinates(modified_pred, x_groups, class_dict, size):
|
|
94 |
]
|
95 |
|
96 |
# Expand the pool bounding boxes to fit the aligned elements
|
97 |
-
def expand_pool_bounding_boxes(modified_pred,
|
98 |
for idx, (pool_index, keep_elements) in enumerate(modified_pred['pool_dict'].items()):
|
99 |
if len(keep_elements) != 0:
|
100 |
-
marge =
|
101 |
else:
|
102 |
marge = 0
|
103 |
|
@@ -114,7 +114,7 @@ def expand_pool_bounding_boxes(modified_pred, pred, size_elements):
|
|
114 |
error("The pool is maybe too small, please add more elements or increase the scale by zooming on the image.")
|
115 |
continue
|
116 |
|
117 |
-
modified_pred['boxes'][position] = [min_x - marge, min_y - marge//
|
118 |
|
119 |
# Adjust left and right boundaries of all pools
|
120 |
def adjust_pool_boundaries(modified_pred, pred):
|
@@ -149,7 +149,7 @@ def align_boxes(pred, size, class_dict):
|
|
149 |
align_elements_within_pool(modified_pred, pool_groups, class_dict, size)
|
150 |
|
151 |
if len(pred['pool_dict']) > 1:
|
152 |
-
expand_pool_bounding_boxes(modified_pred,
|
153 |
adjust_pool_boundaries(modified_pred, pred)
|
154 |
|
155 |
return modified_pred['boxes']
|
|
|
94 |
]
|
95 |
|
96 |
# Expand the pool bounding boxes to fit the aligned elements
|
97 |
+
def expand_pool_bounding_boxes(modified_pred, size_elements):
|
98 |
for idx, (pool_index, keep_elements) in enumerate(modified_pred['pool_dict'].items()):
|
99 |
if len(keep_elements) != 0:
|
100 |
+
marge = size_elements['task'][1] // 2
|
101 |
else:
|
102 |
marge = 0
|
103 |
|
|
|
114 |
error("The pool is maybe too small, please add more elements or increase the scale by zooming on the image.")
|
115 |
continue
|
116 |
|
117 |
+
modified_pred['boxes'][position] = [min_x - marge, min_y - marge//2, min_x + pool_width + marge, min_y + pool_height + marge//2]
|
118 |
|
119 |
# Adjust left and right boundaries of all pools
|
120 |
def adjust_pool_boundaries(modified_pred, pred):
|
|
|
149 |
align_elements_within_pool(modified_pred, pool_groups, class_dict, size)
|
150 |
|
151 |
if len(pred['pool_dict']) > 1:
|
152 |
+
expand_pool_bounding_boxes(modified_pred, size)
|
153 |
adjust_pool_boundaries(modified_pred, pred)
|
154 |
|
155 |
return modified_pred['boxes']
|