-
Notifications
You must be signed in to change notification settings - Fork 29
/
main.py
46 lines (41 loc) · 1.42 KB
/
main.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 torch
import torch.nn as nn
import argparse
import os.path as osp
import os
from evaluator import Eval_thread
from dataloader import EvalDataset
def main(cfg):
root_dir = cfg.root_dir
if cfg.save_dir is not None:
output_dir = cfg.save_dir
else:
output_dir = root_dir
gt_dir = osp.join(root_dir, 'gt')
pred_dir = osp.join(root_dir, 'pred')
if cfg.methods is None:
method_names = os.listdir(pred_dir)
else:
method_names = cfg.methods.split('+')
if cfg.datasets is None:
dataset_names = os.listdir(gt_dir)
else:
dataset_names = cfg.datasets.split('+')
threads = []
for dataset in dataset_names:
for method in method_names:
loader = EvalDataset(osp.join(pred_dir, method, dataset),
osp.join(gt_dir, dataset))
thread = Eval_thread(loader, method, dataset, output_dir, cfg.cuda)
threads.append(thread)
for thread in threads:
print(thread.run())
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('--methods', type=str, default=None)
parser.add_argument('--datasets', type=str, default=None)
parser.add_argument('--root_dir', type=str, default='./')
parser.add_argument('--save_dir', type=str, default=None)
parser.add_argument('--cuda', type=bool, default=True)
config = parser.parse_args()
main(config)