-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_eval.py
More file actions
55 lines (45 loc) · 2.1 KB
/
run_eval.py
File metadata and controls
55 lines (45 loc) · 2.1 KB
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
import time
import argparse
import numpy as np
from eval.eval_detection import ANETEval
# noinspection SpellCheckingInspection
def evaluate(gtfile, predfile, propfile=None, max_avg_nr_proposals=100,
tiou_thresholds=np.linspace(0.5, 0.95, 10),
subset='validation', verbose=False, check_status=False, plot=False):
"""
:param gtfile: path to gt.json
:param predfile: path to prediction.json
:param propfile: None (if you want to calculate AUC, pass proposal_file.json and call anet_eval.evaluate_proposal)
:param max_avg_nr_proposals:
:param tiou_thresholds:
:param subset: 'validation' for ANet and 'test' for Thumos
:param verbose:
:param check_status:
:param plot: Not used
:return:
"""
start = time.time()
mode = ['prediction']
anet_eval = ANETEval(gtfile, predfile, propfile, tiou_thresholds=tiou_thresholds,
max_avg_nr_proposals=max_avg_nr_proposals, subset=subset,
verbose=verbose, check_status=check_status, mode=mode)
mean_ap: float = 0.0
class_ap = []
mean_ap, class_ap = anet_eval.evaluate_detection()
end = time.time()
return mean_ap, class_ap
def parse_input():
p = argparse.ArgumentParser()
p.add_argument('--gtfile', type=str, required=True, help='Full path to json file containing the ground truth.')
p.add_argument('--predfile', type=str, default=None, help='Full path to json file containing the predictions.')
p.add_argument('--propfile', type=str, default=None, help='Full path to json file containing the proposals.')
p.add_argument('--subset', default='validation', help='String indicating subset to evaluate: training, validation')
p.add_argument('--tiou_thresholds', type=float, default=np.linspace(0.5, 0.95, 10), help='Temporal iou threshold.')
p.add_argument('--verbose', type=bool, default=True)
p.add_argument('--check_status', type=bool, default=False)
return p.parse_args()
def main():
args = parse_input()
evaluate(args.gtfile, args.predfile, args.propfile, subset=args.subset)
if __name__ == '__main__':
main()