(self, opt, frame_rate=30)
| 168 | |
| 169 | class JDETracker(object): |
| 170 | def __init__(self, opt, frame_rate=30): |
| 171 | self.opt = opt |
| 172 | if int(opt.gpus[0]) >= 0: |
| 173 | opt.device = torch.device('cuda') |
| 174 | else: |
| 175 | opt.device = torch.device('cpu') |
| 176 | print('Creating model...') |
| 177 | |
| 178 | ckpt = torch.load(opt.weights, map_location=opt.device) # load checkpoint |
| 179 | self.model = Model(opt.cfg or ckpt['model'].yaml, ch=3, nc=1).to(opt.device) # create |
| 180 | exclude = ['anchor'] if opt.cfg else [] # exclude keys |
| 181 | if type(ckpt['model']).__name__ == "OrderedDict": |
| 182 | state_dict = ckpt['model'] |
| 183 | else: |
| 184 | state_dict = ckpt['model'].float().state_dict() # to FP32 |
| 185 | state_dict = intersect_dicts(state_dict, self.model.state_dict(), exclude=exclude) # intersect |
| 186 | self.model.load_state_dict(state_dict, strict=False) # load |
| 187 | self.model.cuda().eval() |
| 188 | total_params = sum(p.numel() for p in self.model.parameters()) |
| 189 | print(f'{total_params:,} total parameters.') |
| 190 | |
| 191 | |
| 192 | self.tracked_stracks = [] # type: list[STrack] |
| 193 | self.lost_stracks = [] # type: list[STrack] |
| 194 | self.removed_stracks = [] # type: list[STrack] |
| 195 | |
| 196 | self.frame_id = 0 |
| 197 | self.det_thresh = opt.conf_thres |
| 198 | self.buffer_size = int(frame_rate / 30.0 * opt.track_buffer) |
| 199 | self.max_time_lost = self.buffer_size |
| 200 | self.mean = np.array(opt.mean, dtype=np.float32).reshape(1, 1, 3) |
| 201 | self.std = np.array(opt.std, dtype=np.float32).reshape(1, 1, 3) |
| 202 | |
| 203 | self.kalman_filter = KalmanFilter() |
| 204 | self.low_thres = 0.1 |
| 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 |
nothing calls this directly
no test coverage detected