-
Notifications
You must be signed in to change notification settings - Fork 1
/
plot.py
59 lines (49 loc) · 2.31 KB
/
plot.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
import tqdm
from common.load import load_data
import generate
import yaml
import argparse
from common.logs import TeamLogs
import logging
logging.basicConfig(level=logging.DEBUG)
def main(args):
# load config file for this plot
with open(args.config, 'r') as f:
cfg = yaml.load(f, Loader=yaml.FullLoader)
# load competition data
teams = cfg["teams"]
competition_data = load_data(
teams,
cfg['audits_file'],
cfg['run_file'],
args.v3c_fps_file,
args.v3c_segments_files)
competition_data['config'] = cfg
competition_data['args'] = args
plot_cfgs = [c for c in cfg["generate"] if c["name"] in args.graphs]
# create or load logs, for each team
logs = {}
for team in tqdm.tqdm(teams, desc='Loading (or generating) intermediate DataFrames'):
team_log = TeamLogs(
competition_data,
team,
max_records=10000,
use_cache=args.log_cache,
cache_path='cache/team_logs')
logs[team] = team_log
# generate results
for plot_cfg in tqdm.tqdm(plot_cfgs, desc='Generating plots'):
result = eval(plot_cfg["function"])(competition_data, teams, logs, use_cache=args.result_cache, cache_path=f"cache/results/{competition_data['version']}")
result.generate_and_render(plot_cfg["generate_args"], plot_cfg["render_args"])
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Perform evaluation on test set')
parser.add_argument('graphs', nargs='+', default=['time_recall_table'], help="Name of the plots to render (see in config.yaml for the names that can be used)")
parser.add_argument('--config', default='config2022.yaml', help='config file to generate the graph')
parser.add_argument('--v3c_segments_files', nargs='+', default=['data/v3c1_frame_segments.csv', 'data/v3c2_frame_segments.csv'])
parser.add_argument('--v3c_fps_file', default='data/v3c1_2_fps.csv')
parser.add_argument('--no_log_cache', action='store_true', help='Whether to use the log cache from each team')
parser.add_argument('--no_result_cache', action='store_true', help='Whether to use the result cache for rendering results')
args = parser.parse_args()
args.result_cache = not args.no_result_cache
args.log_cache = not args.no_log_cache
main(args)