@@ -17,7 +17,7 @@ def main(results):
17
17
# restore config and model
18
18
dir_output = results
19
19
20
- config_data = Config (dir_output + "data.json" )
20
+ config_data = Config (dir_output + "data.json" )
21
21
config_vocab = Config (dir_output + "vocab.json" )
22
22
config_model = Config (dir_output + "model.json" )
23
23
@@ -28,22 +28,24 @@ def main(results):
28
28
29
29
# load dataset
30
30
test_set = DataGenerator (path_formulas = config_data .path_formulas_test ,
31
- dir_images = config_data .dir_images_test , img_prepro = greyscale ,
32
- max_iter = config_data .max_iter , bucket = config_data .bucket_test ,
33
- path_matching = config_data .path_matching_test ,
34
- max_len = config_data .max_length_formula ,
35
- form_prepro = vocab .form_prepro ,)
31
+ dir_images = config_data .dir_images_test ,
32
+ img_prepro = greyscale ,
33
+ max_iter = config_data .max_iter ,
34
+ bucket = config_data .bucket_test ,
35
+ path_matching = config_data .path_matching_test ,
36
+ max_len = config_data .max_length_formula ,
37
+ form_prepro = vocab .form_prepro ,)
36
38
37
39
# use model to write predictions in files
38
- config_eval = Config ({"dir_answers" : dir_output + "formulas_test/" ,
39
- "batch_size" : 20 })
40
+ config_eval = Config ({
41
+ "dir_answers" : dir_output + "formulas_test/" ,
42
+ "batch_size" : 20
43
+ })
40
44
files , perplexity = model .write_prediction (config_eval , test_set )
41
- formula_ref , formula_hyp = files [0 ], files [1 ]
42
-
43
- # score the ref and prediction files
44
- scores = score_files (formula_ref , formula_hyp )
45
+ scores = score_files (files [0 ], files [1 ])
45
46
scores ["perplexity" ] = perplexity
46
- msg = " ... " .join (["{} is {:04.2f}" .format (k , v ) for k , v in scores .items ()])
47
+
48
+ msg = " || " .join (["{} is {:04.2f}" .format (k , v ) for k , v in scores .items ()])
47
49
model .logger .info ("- Test Txt: {}" .format (msg ))
48
50
49
51
0 commit comments