MCPcopy Create free account
hub / github.com/FoundationVision/ByteTrack / inference_single_image

Method inference_single_image

tutorials/motr/motr.py:573–590  ·  view source on GitHub ↗
(self, img, ori_img_size, track_instances=None)

Source from the content-addressed store, hash-verified

571
572 @torch.no_grad()
573 def inference_single_image(self, img, ori_img_size, track_instances=None):
574 if not isinstance(img, NestedTensor):
575 img = nested_tensor_from_tensor_list(img)
576 if track_instances is None:
577 track_instances = self._generate_empty_tracks()
578
579 res = self._forward_single_image(img, track_instances=track_instances)
580
581 track_instances = res['track_instances']
582 track_instances = self.post_process(track_instances, ori_img_size)
583 ret = {'track_instances': track_instances}
584 if 'ref_pts' in res:
585 ref_pts = res['ref_pts']
586 img_h, img_w = ori_img_size
587 scale_fct = torch.Tensor([img_w, img_h]).to(ref_pts)
588 ref_pts = ref_pts * scale_fct[None]
589 ret['ref_pts'] = ref_pts
590 return ret
591
592 def forward(self, data: dict):
593 if self.training:

Callers 1

detectMethod · 0.45

Calls 3

_forward_single_imageMethod · 0.95
post_processMethod · 0.45

Tested by

no test coverage detected