forked from zakharos/DPOD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
52 lines (41 loc) · 1.38 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
"""
Dense pose estimation module no. 1
Copyright (C) 2020 Siemens AG
SPDX-License-Identifier: MIT for non-commercial use otherwise see license terms
Author 2020 Sergey Zakharov
"""
import sys
import argparse
import configparser
from pipelines.train import train
from pipelines.test import test as test
from networks.resnet_uvw import resnet18 as dpod_uvw
from networks.resnet_uv import resnet18 as dpod_uv
import utils.data as data
def main():
# Set arguments
parser = argparse.ArgumentParser()
parser.add_argument('config', default='config.ini', help='config file')
parser.add_argument('--test', '-t', action='store_true', help='test network')
# Parse arguments
args = parser.parse_args()
# Read config file
cfg = args.config
cfgparser = configparser.ConfigParser()
res = cfgparser.read(cfg)
if len(res) == 0:
print("Error: None of the config files could be read")
sys.exit(1)
# Correspondence type
corr_type = data.read_cfg_string(cfgparser, 'input', 'corr_type', default='')
if corr_type == 'uv':
dpod = dpod_uv
elif corr_type == 'uvw':
dpod = dpod_uvw
# Execution
if not args.test:
train(cfgparser, test_function=test, create_cnn=dpod)
else:
test(cfgparser, create_cnn=dpod)
if __name__ == '__main__':
main()