(self, ori_img, timer)
| 80 | self.input_shape = tuple(map(int, args.input_shape.split(','))) |
| 81 | |
| 82 | def inference(self, ori_img, timer): |
| 83 | img_info = {"id": 0} |
| 84 | height, width = ori_img.shape[:2] |
| 85 | img_info["height"] = height |
| 86 | img_info["width"] = width |
| 87 | img_info["raw_img"] = ori_img |
| 88 | |
| 89 | img, ratio = preprocess(ori_img, self.input_shape, self.rgb_means, self.std) |
| 90 | img_info["ratio"] = ratio |
| 91 | ort_inputs = {self.session.get_inputs()[0].name: img[None, :, :, :]} |
| 92 | timer.tic() |
| 93 | output = self.session.run(None, ort_inputs) |
| 94 | predictions = demo_postprocess(output[0], self.input_shape, p6=self.args.with_p6)[0] |
| 95 | |
| 96 | boxes = predictions[:, :4] |
| 97 | scores = predictions[:, 4:5] * predictions[:, 5:] |
| 98 | |
| 99 | boxes_xyxy = np.ones_like(boxes) |
| 100 | boxes_xyxy[:, 0] = boxes[:, 0] - boxes[:, 2]/2. |
| 101 | boxes_xyxy[:, 1] = boxes[:, 1] - boxes[:, 3]/2. |
| 102 | boxes_xyxy[:, 2] = boxes[:, 0] + boxes[:, 2]/2. |
| 103 | boxes_xyxy[:, 3] = boxes[:, 1] + boxes[:, 3]/2. |
| 104 | boxes_xyxy /= ratio |
| 105 | dets = multiclass_nms(boxes_xyxy, scores, nms_thr=self.args.nms_thr, score_thr=self.args.score_thr) |
| 106 | return dets[:, :-1], img_info |
| 107 | |
| 108 | |
| 109 | def imageflow_demo(predictor, args): |
no test coverage detected