(self, im_blob, img0,seq_num, save_dir)
| 205 | self.high_thres = self.opt.conf_thres + 0.1 |
| 206 | |
| 207 | def update(self, im_blob, img0,seq_num, save_dir): |
| 208 | self.frame_id += 1 |
| 209 | activated_starcks = [] |
| 210 | refind_stracks = [] |
| 211 | lost_stracks = [] |
| 212 | removed_stracks = [] |
| 213 | dets = [] |
| 214 | |
| 215 | ''' Step 1: Network forward, get detections & embeddings''' |
| 216 | with torch.no_grad(): |
| 217 | output = self.model(im_blob, augment=False) |
| 218 | pred, train_out = output[1] |
| 219 | |
| 220 | pred = pred[pred[:, :, 4] > self.low_thres] |
| 221 | detections = [] |
| 222 | if len(pred) > 0: |
| 223 | dets,x_inds,y_inds = non_max_suppression_and_inds(pred[:,:6].unsqueeze(0), 0.1, self.opt.nms_thres,method='cluster_diou') |
| 224 | dets = dets.numpy() |
| 225 | if len(dets) != 0: |
| 226 | scale_coords(self.opt.img_size, dets[:, :4], img0.shape).round() |
| 227 | id_feature = output[0][0, y_inds, x_inds, :].cpu().numpy() |
| 228 | |
| 229 | remain_inds = dets[:, 4] > self.opt.conf_thres |
| 230 | inds_low = dets[:, 4] > self.low_thres |
| 231 | inds_high = dets[:, 4] < self.opt.conf_thres |
| 232 | inds_second = np.logical_and(inds_low, inds_high) |
| 233 | dets_second = dets[inds_second] |
| 234 | if id_feature.shape[0] == 1: |
| 235 | id_feature_second = id_feature |
| 236 | else: |
| 237 | id_feature_second = id_feature[inds_second] |
| 238 | dets = dets[remain_inds] |
| 239 | id_feature = id_feature[remain_inds] |
| 240 | |
| 241 | detections = [STrack(STrack.tlbr_to_tlwh(tlbrs[:4]), tlbrs[4], f, 30) for |
| 242 | (tlbrs, f) in zip(dets[:, :5], id_feature)] |
| 243 | |
| 244 | else: |
| 245 | detections = [] |
| 246 | dets_second = [] |
| 247 | id_feature_second = [] |
| 248 | else: |
| 249 | detections = [] |
| 250 | dets_second = [] |
| 251 | id_feature_second = [] |
| 252 | |
| 253 | ''' Add newly detected tracklets to tracked_stracks''' |
| 254 | unconfirmed = [] |
| 255 | tracked_stracks = [] # type: list[STrack] |
| 256 | for track in self.tracked_stracks: |
| 257 | if not track.is_activated: |
| 258 | unconfirmed.append(track) |
| 259 | else: |
| 260 | tracked_stracks.append(track) |
| 261 | |
| 262 | ''' Step 2: First association, with embedding''' |
| 263 | strack_pool = joint_stracks(tracked_stracks, self.lost_stracks) |
| 264 | # Predict the current location with KF |
nothing calls this directly
no test coverage detected