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

Method eval_frame

yolox/evaluators/evaluation.py:28–74  ·  view source on GitHub ↗
(self, frame_id, trk_tlwhs, trk_ids, rtn_events=False)

Source from the content-addressed store, hash-verified

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

Callers 1

eval_fileMethod · 0.95

Calls 2

unzip_objsFunction · 0.70
updateMethod · 0.45

Tested by

no test coverage detected