in source/neo/eval.py [0:0]
def post_process(self, class_ids, mx_scores, mx_bounding_boxes):
"""
rescale the bounding boxes back to its original space
:param class_ids: ids of detected objects
:param mx_scores: confidences of bounding boxes
:param mx_bounding_boxes: bounding boxes of detected objects
:return: detection response (dictionary)
"""
if not isinstance(class_ids, np.ndarray):
class_ids = class_ids.asnumpy()
if not isinstance(mx_scores, np.ndarray):
mx_scores = mx_scores.asnumpy()
if not isinstance(mx_bounding_boxes, np.ndarray):
mx_bounding_boxes = mx_bounding_boxes.asnumpy()
# rescale detection results back to original image size
scale_ratio = self._short_size / self._height if self._height < self._width else self._short_size / self._width
bbox_coords, bbox_scores = list(), list()
for index, bbox in enumerate(mx_bounding_boxes[0]):
prob = float(mx_scores[0][index][0])
if prob < 0.0:
continue
[x_min, y_min, x_max, y_max] = bbox
x_min = int(x_min / scale_ratio)
y_min = int(y_min / scale_ratio)
x_max = int(x_max / scale_ratio)
y_max = int(y_max / scale_ratio)
bbox_coords.append([x_min, y_min, x_max, y_max])
bbox_scores.append([prob])
body = {
'width': self._width,
'height': self._height,
'channels': self._channels,
'bbox_scores': bbox_scores, # shape = (N, 1)
'bbox_coords': bbox_coords, # shape = (N, 4)
}
return body