-
Notifications
You must be signed in to change notification settings - Fork 270
/
eval.py
executable file
·223 lines (198 loc) · 9.57 KB
/
eval.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import os
import argparse
import sys
sys.path.append(os.path.abspath('.'))
from glob import glob
from tqdm import tqdm
from multiprocessing import Pool
from toolkit.datasets import OTBDataset, UAVDataset, LaSOTDataset, \
VOTDataset, NFSDataset, VOTLTDataset ,DTB70Dataset
from toolkit.evaluation import OPEBenchmark, AccuracyRobustnessBenchmark, \
EAOBenchmark, F1Benchmark
import warnings
warnings.filterwarnings('ignore')
from got10k.experiments import ExperimentGOT10k
def eval(args):
tracker_dir = os.path.join(args.tracker_path, args.dataset)
trackers = glob(os.path.join(args.tracker_path,
args.dataset,
args.tracker_name+'*'))
trackers = [x.split('/')[-1] for x in trackers]
assert len(trackers) > 0
args.num = min(args.num, len(trackers))
root = './datasets'
root = os.path.join(root, args.dataset)
if 'OTB' in args.dataset:
dataset = OTBDataset(args.dataset, root)
dataset.set_tracker(tracker_dir, trackers)
benchmark = OPEBenchmark(dataset)
success_ret = {}
with Pool(processes=args.num) as pool:
for ret in tqdm(pool.imap_unordered(benchmark.eval_success,trackers), desc='eval success', total=len(trackers), ncols=100):
success_ret.update(ret)
precision_ret = {}
with Pool(processes=args.num) as pool:
for ret in tqdm(pool.imap_unordered(benchmark.eval_precision,
trackers), desc='eval precision', total=len(trackers), ncols=100):
precision_ret.update(ret)
benchmark.show_result(success_ret, precision_ret,
show_video_level=args.show_video_level)
elif 'DTB70' in args.dataset:
dataset = DTB70Dataset(args.dataset, root)
dataset.set_tracker(tracker_dir, trackers)
benchmark = OPEBenchmark(dataset)
success_ret = {}
with Pool(processes=args.num) as pool:
for ret in tqdm(pool.imap_unordered(benchmark.eval_success,trackers), desc='eval success', total=len(trackers), ncols=100):
success_ret.update(ret)
precision_ret = {}
with Pool(processes=args.num) as pool:
for ret in tqdm(pool.imap_unordered(benchmark.eval_precision,
trackers), desc='eval precision', total=len(trackers), ncols=100):
precision_ret.update(ret)
benchmark.show_result(success_ret, precision_ret,
show_video_level=args.show_video_level)
elif 'UAVDT' in args.dataset:
dataset = UAVDTDataset(args.dataset, root)
dataset.set_tracker(tracker_dir, trackers)
benchmark = OPEBenchmark(dataset)
success_ret = {}
with Pool(processes=args.num) as pool:
for ret in tqdm(pool.imap_unordered(benchmark.eval_success,trackers), desc='eval success', total=len(trackers), ncols=100):
success_ret.update(ret)
precision_ret = {}
with Pool(processes=args.num) as pool:
for ret in tqdm(pool.imap_unordered(benchmark.eval_precision,
trackers), desc='eval precision', total=len(trackers), ncols=100):
precision_ret.update(ret)
benchmark.show_result(success_ret, precision_ret,
show_video_level=args.show_video_level)
elif 'VisDrone' in args.dataset:
dataset = VisDroneDataset(args.dataset, root)
dataset.set_tracker(tracker_dir, trackers)
benchmark = OPEBenchmark(dataset)
success_ret = {}
with Pool(processes=args.num) as pool:
for ret in tqdm(pool.imap_unordered(benchmark.eval_success,trackers), desc='eval success', total=len(trackers), ncols=100):
success_ret.update(ret)
precision_ret = {}
with Pool(processes=args.num) as pool:
for ret in tqdm(pool.imap_unordered(benchmark.eval_precision,
trackers), desc='eval precision', total=len(trackers), ncols=100):
precision_ret.update(ret)
benchmark.show_result(success_ret, precision_ret,
show_video_level=args.show_video_level)
elif 'GOT-10k' in args.dataset:
root_dir = os.path.abspath('datasets/GOT-10k')
e = ExperimentGOT10k(root_dir)
ao, sr, speed=e.report([args.tracker_name])
ss='ao:%.3f --sr:%.3f -speed:%.3f' % (float(ao),float(sr),float(speed))
print(ss)
elif 'LaSOT' == args.dataset:
dataset = LaSOTDataset(args.dataset, root)
dataset.set_tracker(tracker_dir, trackers)
benchmark = OPEBenchmark(dataset)
success_ret = {}
with Pool(processes=args.num) as pool:
for ret in tqdm(pool.imap_unordered(benchmark.eval_success,
trackers), desc='eval success', total=len(trackers), ncols=100):
success_ret.update(ret)
precision_ret = {}
with Pool(processes=args.num) as pool:
for ret in tqdm(pool.imap_unordered(benchmark.eval_precision,
trackers), desc='eval precision', total=len(trackers), ncols=100):
precision_ret.update(ret)
norm_precision_ret = {}
with Pool(processes=args.num) as pool:
for ret in tqdm(pool.imap_unordered(benchmark.eval_norm_precision,
trackers), desc='eval norm precision', total=len(trackers), ncols=100):
norm_precision_ret.update(ret)
benchmark.show_result(success_ret, precision_ret, norm_precision_ret,
show_video_level=args.show_video_level)
elif 'UAV' in args.dataset: #注意UAVDT和 UAV123 以及 UAV20L的区别
dataset = UAVDataset(args.dataset, root)
dataset.set_tracker(tracker_dir, trackers)
benchmark = OPEBenchmark(dataset)
success_ret = {}
with Pool(processes=args.num) as pool:
for ret in tqdm(pool.imap_unordered(benchmark.eval_success,
trackers), desc='eval success', total=len(trackers), ncols=100):
success_ret.update(ret)
precision_ret = {}
with Pool(processes=args.num) as pool:
for ret in tqdm(pool.imap_unordered(benchmark.eval_precision,
trackers), desc='eval precision', total=len(trackers), ncols=100):
precision_ret.update(ret)
benchmark.show_result(success_ret, precision_ret,
show_video_level=args.show_video_level)
elif 'NFS' in args.dataset:
dataset = NFSDataset(args.dataset, root)
dataset.set_tracker(tracker_dir, trackers)
benchmark = OPEBenchmark(dataset)
success_ret = {}
with Pool(processes=args.num) as pool:
for ret in tqdm(pool.imap_unordered(benchmark.eval_success,
trackers), desc='eval success', total=len(trackers), ncols=100):
success_ret.update(ret)
precision_ret = {}
with Pool(processes=args.num) as pool:
for ret in tqdm(pool.imap_unordered(benchmark.eval_precision,
trackers), desc='eval precision', total=len(trackers), ncols=100):
precision_ret.update(ret)
benchmark.show_result(success_ret, precision_ret,
show_video_level=args.show_video_level)
elif args.dataset in ['VOT2016', 'VOT2017', 'VOT2018', 'VOT2019']:
dataset = VOTDataset(args.dataset, root)
dataset.set_tracker(tracker_dir, trackers)
ar_benchmark = AccuracyRobustnessBenchmark(dataset)
ar_result = {}
with Pool(processes=args.num) as pool:
for ret in pool.imap_unordered(ar_benchmark.eval,
trackers):
ar_result.update(ret)
benchmark = EAOBenchmark(dataset)
eao_result = {}
with Pool(processes=args.num) as pool:
for ret in pool.imap_unordered(benchmark.eval,
trackers):
eao_result.update(ret)
ar_benchmark.show_result(ar_result, eao_result,
show_video_level=args.show_video_level)
elif 'VOT2018-LT' == args.dataset:
dataset = VOTLTDataset(args.dataset, root)
dataset.set_tracker(tracker_dir, trackers)
benchmark = F1Benchmark(dataset)
f1_result = {}
with Pool(processes=args.num) as pool:
for ret in tqdm(pool.imap_unordered(benchmark.eval,
trackers), desc='eval f1', total=len(trackers), ncols=100):
f1_result.update(ret)
benchmark.show_result(f1_result,
show_video_level=args.show_video_level)
# shell command
# python ./bin/eval.py \
# --tracker_path ./hp_search_result \
# --dataset VOT2018 \
# --num 4 \
# --tracker_name 'checkpoint*'
if __name__ == '__main__':
tracker_name='nanotrack'
dataset='DTB70'
parser = argparse.ArgumentParser(description='tracking evaluation')
parser.add_argument('--tracker_path', '-p', default='./results', type=str,
help='tracker result path')
parser.add_argument('--dataset', '-d', default=dataset, type=str,
help='dataset name')
parser.add_argument('--num', '-n', default=4, type=int,
help='number of thread to eval')
parser.add_argument('--tracker_name', '-t', default=tracker_name,
type=str, help='tracker name')
parser.add_argument('--show_video_level', '-s', dest='show_video_level',
action='store_true')
parser.set_defaults(show_video_level=False)
args = parser.parse_args()
eval(args)