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

Method eval_frame

tutorials/jde/evaluation.py:29–67  ·  view source on GitHub ↗
(self, frame_id, trk_tlwhs, trk_ids, rtn_events=False)

Source from the content-addressed store, hash-verified

27 self.acc = mm.MOTAccumulator(auto_id=True)
28
29 def eval_frame(self, frame_id, trk_tlwhs, trk_ids, rtn_events=False):
30 # results
31 trk_tlwhs = np.copy(trk_tlwhs)
32 trk_ids = np.copy(trk_ids)
33
34 # gts
35 gt_objs = self.gt_frame_dict.get(frame_id, [])
36 gt_tlwhs, gt_ids = unzip_objs(gt_objs)[:2]
37
38 # ignore boxes
39 ignore_objs = self.gt_ignore_frame_dict.get(frame_id, [])
40 ignore_tlwhs = unzip_objs(ignore_objs)[0]
41
42
43 # remove ignored results
44 keep = np.ones(len(trk_tlwhs), dtype=bool)
45 iou_distance = mm.distances.iou_matrix(ignore_tlwhs, trk_tlwhs, max_iou=0.5)
46 if len(iou_distance) > 0:
47 match_is, match_js = mm.lap.linear_sum_assignment(iou_distance)
48 match_is, match_js = map(lambda a: np.asarray(a, dtype=int), [match_is, match_js])
49 match_ious = iou_distance[match_is, match_js]
50
51 match_js = np.asarray(match_js, dtype=int)
52 match_js = match_js[np.logical_not(np.isnan(match_ious))]
53 keep[match_js] = False
54 trk_tlwhs = trk_tlwhs[keep]
55 trk_ids = trk_ids[keep]
56
57 # get distance matrix
58 iou_distance = mm.distances.iou_matrix(gt_tlwhs, trk_tlwhs, max_iou=0.5)
59
60 # acc
61 self.acc.update(gt_ids, trk_ids, iou_distance)
62
63 if rtn_events and iou_distance.size > 0 and hasattr(self.acc, 'last_mot_events'):
64 events = self.acc.last_mot_events # only supported by https://github.com/longcw/py-motmetrics
65 else:
66 events = None
67 return events
68
69 def eval_file(self, filename):
70 self.reset_accumulator()

Callers 1

eval_fileMethod · 0.95

Calls 2

unzip_objsFunction · 0.90
updateMethod · 0.45

Tested by

no test coverage detected