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

Method inference_single_image

tutorials/motr/motr_det.py:573–591  ·  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 track_instances = self._generate_empty_tracks()
579
580 res = self._forward_single_image(img, track_instances=track_instances)
581
582 track_instances = res['track_instances']
583 track_instances = self.post_process(track_instances, ori_img_size)
584 ret = {'track_instances': track_instances}
585 if 'ref_pts' in res:
586 ref_pts = res['ref_pts']
587 img_h, img_w = ori_img_size
588 scale_fct = torch.Tensor([img_w, img_h]).to(ref_pts)
589 ref_pts = ref_pts * scale_fct[None]
590 ret['ref_pts'] = ref_pts
591 return ret
592
593 def forward(self, data: dict):
594 if self.training:

Callers

nothing calls this directly

Calls 3

_forward_single_imageMethod · 0.95
post_processMethod · 0.45

Tested by

no test coverage detected