-
Notifications
You must be signed in to change notification settings - Fork 2
/
sprlEval.py
43 lines (32 loc) · 1.36 KB
/
sprlEval.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
import os
import pickle
from argparse import ArgumentParser
from sprlApp import ontology_declaration, model_declaration
from utils import seed
parser = ArgumentParser(description='Test a trained model.')
parser.add_argument('--model-path', '-m', type=str,
help='Path to the model serialization_dir.')
parser.add_argument('--model', '-M', type=str, default='last',
help='Model id, last, or best.')
parser.add_argument('--data-path', '-d', type=str,
help='Path to the data.')
parser.add_argument('--log-solver', '-s', type=str, default='solver.log',
help='Path save inference log.')
parser.add_argument('--batch-size', '-b', type=int, default=1,
help='Batch size in testing.')
args = parser.parse_args()
def test(model_path, model, data_path, log_solver, batch_size):
#with open(os.path.join(model_path, 'config.pkl'), 'rb') as fin:
# Config = pickle.load(fin)
from config import Config
graph = ontology_declaration()
Config.Model.log_dir = '.'
lbp = model_declaration(graph, Config.Model)
seed()
lbp.load(model_path, model)
metrics = lbp.test(data_path, log_solver, batch_size)
print(metrics)
def main():
return test(args.model_path, args.model, args.data_path, args.log_solver, args.batch_size)
if __name__ == '__main__':
main()