-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
57 lines (42 loc) · 1.46 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
47
48
49
50
51
52
53
54
55
56
57
#! /usr/bin/python3
# -*- coding: utf-8 -*-
"""
Executable for experiments for Calibration Where it Matters.
"""
# Built-in/Generic Imports
import warnings
# Own Modules Imports
from test import test_classifier
from train import train_classifier
from utils import log, set_random_seed
from config import load_configurations, print_arguments
__author__ = ["Jacob Carse"]
__copyright__ = "Copyright 2023, Calibration Where it Matters"
__credits__ = ["Jacob Carse"]
__license__ = "MIT"
__version__ = "1.0.0"
__maintainer = ["Jacob Carse"]
__email__ = ["j.carse@dundee.ac.uk"]
__status__ = "Development"
if __name__ == "__main__":
# Loads the arguments from configurations file and command line.
description = "Experiments on Calibration Where it Matters"
arguments = load_configurations(description)
# Displays the loaded arguments.
log(arguments, "Loaded Arguments:")
print_arguments(arguments)
# Removes warnings from output.
if not arguments.warning:
warnings.filterwarnings("ignore")
# Sets random seed.
if arguments.seed != -1:
set_random_seed(arguments.seed)
log(arguments, f"Set Random Seed to {arguments.seed}")
# Trains a CNN model.
if arguments.task.lower() == "train":
train_classifier(arguments)
# Tests a CNN model.
elif arguments.task.lower() == "test":
test_classifier(arguments)
else:
log(arguments, "Enter a valid task. \"train\" or \"test\"")