-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_fishnchips.py
34 lines (29 loc) · 1.41 KB
/
test_fishnchips.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
import tensorflow as tf
import src.api as api
import argparse
import os
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument('-c', '--config', required=True, help='Config filepath.')
parser.add_argument('-n', '--name', required=False, help='Name of the experiment. If none provided, name with a timestamp will be assigned.')
parser.add_argument('-d', '--discard', required=False, default=False, action='store_true', help='Discard existing trained model (if one exists) and begin training from scratch.')
parser.add_argument('-w', '--warnings', required=False, default=False, action='store_true', help='Display tensorflow warning.')
args = parser.parse_args()
verify_args(args)
set_logging(args)
return args
def verify_args(args):
assert os.path.exists(args.config), 'Config filepath is not valid.'
assert type(args.name) == str, 'Experiment name must be a string.'
def set_logging(args):
if args.warnings == False:
tf.get_logger().setLevel('ERROR')
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
def main(config_path, experiment_name, discard_existing):
config = api.get_config(config_path)
api.setup_experiment(experiment_name, config)
api.test(config, experiment_name, new_testing=discard_existing)
if __name__ == "__main__":
args = parse_args()
main(args.config, args.name, args.discard)
print(' - Script has finished successfully.')