in models/01_YoloV5/01_Pytorch/processing.py [0:0]
def post_process(self, predictions, source_image_shape, image=None):
xc = predictions[..., 4] > self.threshold
predictions = predictions[xc]
bboxes, scores, cids = self.get_detections(predictions)
# Normalise box coordinates to be in the range (0, 1]
h, w = source_image_shape[:2]
h1, w1 = h, w
if self.keep_ratio and h != w:
# Padding was used during pre-process to make the source image square
h1 = w1 = max(h, w)
y_scale,x_scale = (h1,w1) / self.input_shape.astype(np.float32) / (h,w)
bboxes[:, (0, 2)] *= x_scale
bboxes[:, (1, 3)] *= y_scale
bboxes = np.clip(bboxes, 0, 1)
if image is not None:
self.draw_cv2(image, bboxes, scores, cids)
return (bboxes, scores, cids), image