Performs inference using an ONNX model and returns the output image with drawn detections. Returns: output_img: The output image with drawn detections.
(self, img, shape_raw, **kwargs)
| 284 | person_results[i] = result |
| 285 | |
| 286 | def forward(self, img, shape_raw, **kwargs): |
| 287 | """ |
| 288 | Performs inference using an ONNX model and returns the output image with drawn detections. |
| 289 | |
| 290 | Returns: |
| 291 | output_img: The output image with drawn detections. |
| 292 | """ |
| 293 | if isinstance(img, torch.Tensor): |
| 294 | img = img.cpu().numpy() |
| 295 | shape_raw = shape_raw.cpu().numpy() |
| 296 | |
| 297 | outputs = self.session.run(None, {self.session.get_inputs()[0].name: img})[0] |
| 298 | person_results = [[{"bbox": np.array([0.0, 0.0, 1.0 * shape_raw[i][1], 1.0 * shape_raw[i][0], -1]), "track_id": -1}] for i in range(len(outputs))] |
| 299 | |
| 300 | for i in range(len(outputs)): |
| 301 | self.postprocess_threading(outputs, shape_raw, person_results, i, **kwargs) |
| 302 | return person_results |
| 303 | |
| 304 | |
| 305 | class ViTPose(SimpleOnnxInference): |
no test coverage detected