-
Notifications
You must be signed in to change notification settings - Fork 14
/
batch_sort_iou.py
30 lines (26 loc) · 1.23 KB
/
batch_sort_iou.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from similari import BatchSort, BoundingBox, SpatioTemporalConstraints, PositionalMetricType, SortPredictionBatchRequest
if __name__ == '__main__':
constraints = SpatioTemporalConstraints()
constraints.add_constraints([(1, 1.0)])
sort = BatchSort(distance_shards=4, voting_shards=4, bbox_history=10, max_idle_epochs=5,
method=PositionalMetricType.iou(threshold=0.3),
spatio_temporal_constraints=constraints,
kalman_position_weight=0.1,
kalman_velocity_weight=0.1)
box1 = BoundingBox(10., 5., 7., 7.).as_xyaah()
box2 = BoundingBox(5., 5., 3., 7.).as_xyaah()
batch = SortPredictionBatchRequest()
batch.add(0, box1, 11111)
batch.add(1, box2, 22222)
prediction_result = sort.predict(batch)
for _ in range(prediction_result.batch_size()):
scene_id, tracks = prediction_result.get()
print("Scene", scene_id)
print(tracks[0])
sort.skip_epochs_for_scene(0, 10)
sort.skip_epochs_for_scene(1, 10)
# you have to call wasted from time to time to purge wasted tracks
# out of the waste bin. Without doing that the memory utilization will grow.
wasted = sort.wasted()
for w in wasted:
print(w)