-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrain.py
More file actions
51 lines (36 loc) · 1.14 KB
/
train.py
File metadata and controls
51 lines (36 loc) · 1.14 KB
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
#! /usr/bin/env python
"""
Semantic Segmentation
# Train a new model using kitti
Usage: python3 train.py --conf=./config.json
"""
import argparse
import json
from src.frontend import Segment
# define command line arguments
argparser = argparse.ArgumentParser(
description='Train and validate Kitti Road Segmentation Model')
argparser.add_argument(
'-c',
'--conf', default="config.json",
help='path to configuration file')
def _main_(args):
"""
:param args: command line argument
"""
# parse command line argument
config_path = args.conf
# open and load the config json
with open(config_path) as config_buffer:
config = json.loads(config_buffer.read())
# parse the json to retrieve the training configuration
backend = config["model"]["backend"]
input_size = (config["model"]["im_width"], config["model"]["im_height"])
classes = config["model"]["classes"]
# define the model and train
segment = Segment(backend, input_size, classes)
segment.train(config["train"])
if __name__ == '__main__':
# parse the arguments
args = argparser.parse_args()
_main_(args)