This repository has been archived by the owner on May 7, 2024. It is now read-only.
forked from baumgach/PHiSeg-code
-
Notifications
You must be signed in to change notification settings - Fork 0
/
phiseg_train.py
51 lines (34 loc) · 1.44 KB
/
phiseg_train.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
import logging
from importlib.machinery import SourceFileLoader
import argparse
from data.data_switch import data_switch
import os
import config.system as sys_config
import shutil
import utils
from phiseg import phiseg_model
logging.basicConfig(level=logging.INFO, format='%(asctime)s %(message)s')
def main(exp_config):
logging.info('**************************************************************')
logging.info(' *** Running Experiment: %s', exp_config.experiment_name)
logging.info('**************************************************************')
# Get Data
data_loader = data_switch(exp_config.data_identifier)
data = data_loader(exp_config)
# Create Model
phiseg = phiseg_model.phiseg(exp_config)
# Fit model to data
phiseg.train(data)
if __name__ == '__main__':
parser = argparse.ArgumentParser(
description="Script for training")
parser.add_argument("EXP_PATH", type=str, help="Path to experiment config file")
args = parser.parse_args()
config_file = args.EXP_PATH
config_module = config_file.split('/')[-1].rstrip('.py')
exp_config = SourceFileLoader(config_module, config_file).load_module()
log_dir = os.path.join(sys_config.log_root, exp_config.log_dir_name, exp_config.experiment_name)
utils.makefolder(log_dir)
shutil.copy(exp_config.__file__, log_dir)
logging.info('!!!! Copied exp_config file to experiment folder !!!!')
main(exp_config=exp_config)