MCPcopy Index your code
hub / github.com/FoundationVision/ByteTrack / inference

Method inference

tools/demo_track.py:147–175  ·  view source on GitHub ↗
(self, img, timer)

Source from the content-addressed store, hash-verified

145 self.std = (0.229, 0.224, 0.225)
146
147 def inference(self, img, timer):
148 img_info = {"id": 0}
149 if isinstance(img, str):
150 img_info["file_name"] = osp.basename(img)
151 img = cv2.imread(img)
152 else:
153 img_info["file_name"] = None
154
155 height, width = img.shape[:2]
156 img_info["height"] = height
157 img_info["width"] = width
158 img_info["raw_img"] = img
159
160 img, ratio = preproc(img, self.test_size, self.rgb_means, self.std)
161 img_info["ratio"] = ratio
162 img = torch.from_numpy(img).unsqueeze(0).float().to(self.device)
163 if self.fp16:
164 img = img.half() # to FP16
165
166 with torch.no_grad():
167 timer.tic()
168 outputs = self.model(img)
169 if self.decoder is not None:
170 outputs = self.decoder(outputs, dtype=outputs.type())
171 outputs = postprocess(
172 outputs, self.num_classes, self.confthre, self.nmsthre
173 )
174 #logger.info("Infer time: {:.4f}s".format(time.time() - t0))
175 return outputs, img_info
176
177
178def image_demo(predictor, vis_folder, current_time, args):

Callers 2

image_demoFunction · 0.45
imageflow_demoFunction · 0.45

Calls 3

preprocFunction · 0.90
postprocessFunction · 0.90
ticMethod · 0.80

Tested by

no test coverage detected