-
Notifications
You must be signed in to change notification settings - Fork 65
/
Copy pathview_model.py
107 lines (80 loc) · 2.49 KB
/
view_model.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import argparse
import sys
import os
import glob
import torch
# First thing we should try is to import two CARLAS depending on the version
from drive import CoILAgent
from configs import g_conf, merge_with_yaml, set_type_of_process
# Control for CARLA 9
if __name__ == '__main__':
argparser = argparse.ArgumentParser(description=__doc__)
argparser.add_argument(
'-cv',
'--carla-version',
dest='carla_version',
default='0.9',
type=str
)
argparser.add_argument(
'-f',
'--folder',
type=str
)
argparser.add_argument(
'-e',
'--exp',
type=str
)
argparser.add_argument(
'--host',
metavar='H',
default='127.0.0.1',
help='IP of the host server (default: 127.0.0.1)')
argparser.add_argument(
'-p', '--port',
metavar='P',
default=2000,
type=int,
help='TCP port to listen to (default: 2000)'
)
argparser.add_argument(
'-cp', '--checkpoint',
metavar='P',
default=100000,
type=int,
help='The checkpoint used for the model visualization'
)
argparser.add_argument(
'--res',
metavar='WIDTHxHEIGHT',
default='1280x720',
help='window resolution (default: 1280x720)'
)
argparser.add_argument(
'-o', '--output_folder',
metavar='P',
default=None,
type=str,
help='The folder to store images received by the network and its activations'
)
args = argparser.parse_args()
args.width, args.height = [int(x) for x in args.res.split('x')]
merge_with_yaml(os.path.join('configs', args.folder, args.exp + '.yaml'))
checkpoint = torch.load(os.path.join('_logs', args.folder, args.exp
, 'checkpoints', str(args.checkpoint) + '.pth'))
agent = CoILAgent(checkpoint, '_', args.carla_version)
# Decide the version
if args.carla_version == '0.9':
try:
sys.path.append(glob.glob('**/carla-*%d.%d-%s.egg' % (
sys.version_info.major,
sys.version_info.minor,
'win-amd64' if os.name == 'nt' else 'linux-x86_64'))[0])
except IndexError:
pass
import model_view.carla09interface as carla09interface
carla09interface.game_loop(args, agent)
else:
import model_view.carla08interface as carla08interface
carla08interface.game_loop(args, agent)