-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_table.py
53 lines (33 loc) · 1.33 KB
/
make_table.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
import json
import os
import pandas as pd
from tqdm import tqdm
import argparse
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument("--output_dir", type=str, default="out")
args = parser.parse_args()
results = []
for exp in tqdm(os.listdir(args.output_dir)):
exp_dir = os.path.join(args.output_dir, exp)
exp_sub_dirs = [f for f in os.listdir(exp_dir) if f not in ['config.json', 'samples' , 'tmp_results_clip']]
metrics = dict()
metrics['name'] = exp
config_path = os.path.join(exp_dir, 'config.json')
if not os.path.exists(config_path):
print(f"Config {config_path} not exist")
with open(config_path, 'r') as f:
config = json.load(f)
metrics.update(config)
for exp_metric_dir in exp_sub_dirs:
metrics_result_file = os.path.join(exp_dir, exp_metric_dir, 'result.json')
if not os.path.exists(metrics_result_file):
print(f"{metrics_result_file} not exist")
metrics[exp_metric_dir] = None
continue
with open(metrics_result_file, 'r') as f:
metrics[exp_metric_dir] = json.load(f)['result']
results.append(metrics)
df = pd.DataFrame(results)
# print(df)
df.to_csv('table.csv')