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

Method eval_frame

yolox/tracking_utils/evaluation.py:30–76  ·  view source on GitHub ↗
(self, frame_id, trk_tlwhs, trk_ids, rtn_events=False)

Source from the content-addressed store, hash-verified

28 self.acc = mm.MOTAccumulator(auto_id=True)
29
30 def eval_frame(self, frame_id, trk_tlwhs, trk_ids, rtn_events=False):
31 # results
32 trk_tlwhs = np.copy(trk_tlwhs)
33 trk_ids = np.copy(trk_ids)
34
35 # gts
36 gt_objs = self.gt_frame_dict.get(frame_id, [])
37 gt_tlwhs, gt_ids = unzip_objs(gt_objs)[:2]
38
39 # ignore boxes
40 ignore_objs = self.gt_ignore_frame_dict.get(frame_id, [])
41 ignore_tlwhs = unzip_objs(ignore_objs)[0]
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 #match_is, match_js = mm.lap.linear_sum_assignment(iou_distance)
57 #match_is, match_js = map(lambda a: np.asarray(a, dtype=int), [match_is, match_js])
58 #match_ious = iou_distance[match_is, match_js]
59
60 #match_js = np.asarray(match_js, dtype=int)
61 #match_js = match_js[np.logical_not(np.isnan(match_ious))]
62 #keep[match_js] = False
63 #trk_tlwhs = trk_tlwhs[keep]
64 #trk_ids = trk_ids[keep]
65
66 # get distance matrix
67 iou_distance = mm.distances.iou_matrix(gt_tlwhs, trk_tlwhs, max_iou=0.5)
68
69 # acc
70 self.acc.update(gt_ids, trk_ids, iou_distance)
71
72 if rtn_events and iou_distance.size > 0 and hasattr(self.acc, 'last_mot_events'):
73 events = self.acc.last_mot_events # only supported by https://github.com/longcw/py-motmetrics
74 else:
75 events = None
76 return events
77
78 def eval_file(self, filename):
79 self.reset_accumulator()

Callers 1

eval_fileMethod · 0.95

Calls 2

unzip_objsFunction · 0.90
updateMethod · 0.45

Tested by

no test coverage detected