Spaces:
Running
Running
correct overlap pool
Browse files- modules/eval.py +3 -1
- modules/toXML.py +12 -2
modules/eval.py
CHANGED
@@ -372,7 +372,9 @@ def last_correction(boxes, labels, scores, keypoints, links, best_points, pool_d
|
|
372 |
|
373 |
#concatenate the delete_elements and the delete_pool
|
374 |
delete_elements = delete_elements + delete_pool
|
375 |
-
|
|
|
|
|
376 |
boxes = np.delete(boxes, delete_elements, axis=0)
|
377 |
labels = np.delete(labels, delete_elements)
|
378 |
scores = np.delete(scores, delete_elements)
|
|
|
372 |
|
373 |
#concatenate the delete_elements and the delete_pool
|
374 |
delete_elements = delete_elements + delete_pool
|
375 |
+
#delete double value in delete_elements
|
376 |
+
delete_elements = list(set(delete_elements))
|
377 |
+
|
378 |
boxes = np.delete(boxes, delete_elements, axis=0)
|
379 |
labels = np.delete(labels, delete_elements)
|
380 |
scores = np.delete(scores, delete_elements)
|
modules/toXML.py
CHANGED
@@ -83,25 +83,32 @@ def align_boxes(pred, size):
|
|
83 |
size_elements = get_size_elements(st.session_state.size_scale)
|
84 |
if len(keep_elements) != 0:
|
85 |
min_x, min_y, max_x, max_y = calculate_pool_bounds(modified_pred['boxes'],modified_pred['labels'], keep_elements, size_elements)
|
|
|
86 |
else:
|
87 |
if pool_index >= len(modified_pred['boxes']):
|
88 |
print("Problem with the index")
|
89 |
continue
|
90 |
min_x, min_y, max_x, max_y = modified_pred['boxes'][pool_index]
|
|
|
|
|
91 |
pool_width = max_x - min_x
|
92 |
pool_height = max_y - min_y
|
93 |
if pool_width < 300 or pool_height < 30:
|
94 |
error("The pool is maybe too small, please add more elements or increase the scale by zooming on the image.")
|
95 |
continue
|
|
|
96 |
if pool_index >= len(modified_pred['boxes']):
|
97 |
-
new_box = np.array([min_x -
|
98 |
modified_pred['boxes'] = np.append(modified_pred['boxes'], [new_box], axis=0)
|
99 |
else:
|
100 |
-
modified_pred['boxes'][pool_index] = [min_x -
|
101 |
|
102 |
min_left,max_right = 0, 0
|
103 |
if len(pred['pool_dict'])>1:
|
104 |
for pool_index, element_indices in pred['pool_dict'].items():
|
|
|
|
|
|
|
105 |
x1, y1, x2, y2 = modified_pred['boxes'][pool_index]
|
106 |
left = x1
|
107 |
right = x2
|
@@ -111,6 +118,9 @@ def align_boxes(pred, size):
|
|
111 |
max_right = right
|
112 |
|
113 |
for pool_index, element_indices in pred['pool_dict'].items():
|
|
|
|
|
|
|
114 |
x1, y1, x2, y2 = modified_pred['boxes'][pool_index]
|
115 |
if x1 > min_left:
|
116 |
x1 = min_left
|
|
|
83 |
size_elements = get_size_elements(st.session_state.size_scale)
|
84 |
if len(keep_elements) != 0:
|
85 |
min_x, min_y, max_x, max_y = calculate_pool_bounds(modified_pred['boxes'],modified_pred['labels'], keep_elements, size_elements)
|
86 |
+
marge = 50
|
87 |
else:
|
88 |
if pool_index >= len(modified_pred['boxes']):
|
89 |
print("Problem with the index")
|
90 |
continue
|
91 |
min_x, min_y, max_x, max_y = modified_pred['boxes'][pool_index]
|
92 |
+
marge = 0
|
93 |
+
|
94 |
pool_width = max_x - min_x
|
95 |
pool_height = max_y - min_y
|
96 |
if pool_width < 300 or pool_height < 30:
|
97 |
error("The pool is maybe too small, please add more elements or increase the scale by zooming on the image.")
|
98 |
continue
|
99 |
+
|
100 |
if pool_index >= len(modified_pred['boxes']):
|
101 |
+
new_box = np.array([min_x - marge, min_y - marge//2, min_x + pool_width + marge, min_y + pool_height + marge//2])
|
102 |
modified_pred['boxes'] = np.append(modified_pred['boxes'], [new_box], axis=0)
|
103 |
else:
|
104 |
+
modified_pred['boxes'][pool_index] = [min_x -marge, min_y-marge//2, min_x+pool_width+marge, min_y+pool_height+marge//2]
|
105 |
|
106 |
min_left,max_right = 0, 0
|
107 |
if len(pred['pool_dict'])>1:
|
108 |
for pool_index, element_indices in pred['pool_dict'].items():
|
109 |
+
if pool_index >= len(modified_pred['boxes']):
|
110 |
+
print(f"Problem with the index {pool_index} with a length of {len(modified_pred['boxes'])}")
|
111 |
+
continue
|
112 |
x1, y1, x2, y2 = modified_pred['boxes'][pool_index]
|
113 |
left = x1
|
114 |
right = x2
|
|
|
118 |
max_right = right
|
119 |
|
120 |
for pool_index, element_indices in pred['pool_dict'].items():
|
121 |
+
if pool_index >= len(modified_pred['boxes']):
|
122 |
+
#print(f"Problem with the index {pool_index} with a length of {len(modified_pred['boxes'])}")
|
123 |
+
continue
|
124 |
x1, y1, x2, y2 = modified_pred['boxes'][pool_index]
|
125 |
if x1 > min_left:
|
126 |
x1 = min_left
|