-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy patheval_all_test_H.py
46 lines (43 loc) · 1.58 KB
/
eval_all_test_H.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
import numpy as np
import h5py
import cv2
from utils import *
from tqdm import tqdm
import os
from metrics import *
import argparse
if __name__ == '__main__':
# Search for the best hyperparameters on the validation set
parser = argparse.ArgumentParser()
parser.add_argument(
"--data_dir",
default='f_data',
type=str,
help='path to the data')
args = parser.parse_args()
BASE = f'results/test/h/'
res = {}
for method in os.listdir(BASE):
B1 = f'{BASE}/{method}/'
if 'sklearn' not in method:
continue
for hypers in os.listdir(B1):
key = f'{method}-{hypers}'
print (f"Evaluating {key}")
parts = hypers.split('_')
conf = float(parts[1].split('-')[-1])
inl_th = float(parts[3].split('-')[-1])
match_th = float(parts[5].split('-')[-1])
maxiters = int(parts[6].split('-')[-1])
run_str_eval = f'python eval_H_submission.py --force True --data_dir {args.data_dir} --conf {conf} --match_th {match_th} --inlier_th {inl_th} --method {method} --split test --maxiter {maxiters}'
os.system(run_str_eval)
params = {"maxiter": maxiters,
"inl_th": inl_th,
"conf": conf,
"match_th": match_th
}
OUT_DIR = get_output_dir('h', 'test', method, params)
out_maa_final_fname = os.path.join(OUT_DIR, f'maa_FINAL.h5')
final_res = load_h5(out_maa_final_fname)
res[key] = final_res['mAA']
print (final_res['mAA'])