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

Method update

tutorials/cstrack/byte_tracker.py:189–337  ·  view source on GitHub ↗
(self, im_blob, img0,seq_num, save_dir)

Source from the content-addressed store, hash-verified

187 self.high_thres = self.opt.conf_thres + 0.1
188
189 def update(self, im_blob, img0,seq_num, save_dir):
190 self.frame_id += 1
191 activated_starcks = []
192 refind_stracks = []
193 lost_stracks = []
194 removed_stracks = []
195 dets = []
196
197 ''' Step 1: Network forward, get detections & embeddings'''
198 with torch.no_grad():
199 output = self.model(im_blob, augment=False)
200 pred, train_out = output[1]
201
202 pred = pred[pred[:, :, 4] > self.low_thres]
203 detections = []
204 if len(pred) > 0:
205 dets,x_inds,y_inds = non_max_suppression_and_inds(pred[:,:6].unsqueeze(0), 0.1, self.opt.nms_thres,method='cluster_diou')
206 dets = dets.numpy()
207 if len(dets) != 0:
208 scale_coords(self.opt.img_size, dets[:, :4], img0.shape).round()
209
210 remain_inds = dets[:, 4] > self.opt.conf_thres
211 inds_low = dets[:, 4] > self.low_thres
212 inds_high = dets[:, 4] < self.opt.conf_thres
213 inds_second = np.logical_and(inds_low, inds_high)
214 dets_second = dets[inds_second]
215 dets = dets[remain_inds]
216
217 detections = [STrack(STrack.tlbr_to_tlwh(tlbrs[:4]), tlbrs[4]) for
218 tlbrs in dets[:, :5]]
219
220 else:
221 detections = []
222 dets_second = []
223
224 else:
225 detections = []
226 dets_second = []
227
228
229 ''' Add newly detected tracklets to tracked_stracks'''
230 unconfirmed = []
231 tracked_stracks = [] # type: list[STrack]
232 for track in self.tracked_stracks:
233 if not track.is_activated:
234 unconfirmed.append(track)
235 else:
236 tracked_stracks.append(track)
237
238 ''' Step 2: First association, with embedding'''
239 strack_pool = joint_stracks(tracked_stracks, self.lost_stracks)
240 # Predict the current location with KF
241 STrack.multi_predict(strack_pool)
242 dists = matching.iou_distance(strack_pool, detections)
243 matches, u_track, u_detection = matching.linear_assignment(dists, thresh=0.8)
244
245 for itracked, idet in matches:
246 track = strack_pool[itracked]

Callers

nothing calls this directly

Calls 12

STrackClass · 0.70
joint_stracksFunction · 0.70
vis_featureFunction · 0.70
sub_stracksFunction · 0.70
remove_duplicate_stracksFunction · 0.70
tlbr_to_tlwhMethod · 0.45
multi_predictMethod · 0.45
updateMethod · 0.45
re_activateMethod · 0.45
mark_lostMethod · 0.45
mark_removedMethod · 0.45
activateMethod · 0.45

Tested by

no test coverage detected