MCPcopy Create free account
hub / github.com/ModelTC/LightX2V / forward

Method forward

tools/preprocess/pose2d.py:286–302  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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
305class ViTPose(SimpleOnnxInference):

Callers 1

__call__Method · 0.45

Calls 3

postprocess_threadingMethod · 0.95
cpuMethod · 0.80
runMethod · 0.45

Tested by

no test coverage detected