-
Notifications
You must be signed in to change notification settings - Fork 21
/
config.py
147 lines (124 loc) · 4.74 KB
/
config.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
from easydict import EasyDict as edict
import dataset.zpark as zpark
import dataset.dlake as dlake
import dataset.data_iters as data_iter
import data_transform as ts
from collections import OrderedDict
import cv2
import numpy as np
config = edict()
config.path = edict()
config.path.data_root = './data/'
config.path.model_root = './models/'
config.dataset = edict()
config.dataset.zpark = zpark
config.dataset.dlake = dlake
def get_pose_cnn_setting(with_points=False,
K=None,
with_pose_in=False,
pre_render=True,
rand_num=10):
"""
image: the image input
label_db: rendered label map from 3D points
pose_in: the noisy pose
"""
data= OrderedDict([])
data['image'] = {'size': [512, 608],
'channel': 3,
'is_img': True,
'resize_method': cv2.INTER_CUBIC,
'transform':ts.image_transform,
'transform_params':{}}
if pre_render:
data['label_db'] = {'size': [512, 608],
'reader': data_iter.trans_reader_pre_all,
'reader_params': {'rand_num':rand_num},
'channel': 1,
'is_img': False,
'resize_method': cv2.INTER_NEAREST,
'transform': ts.label_db_transform,
'transform_params':{'with_channel':True}}
else:
data['label_db'] = {'size': [512, 608],
'reader': data_iter.trans_reader,
'reader_params': {'multi_return': True,
'proj_mat': True},
'channel': 1,
'is_img': False,
'resize_method': cv2.INTER_NEAREST,
'transform': ts.label_db_transform,
'transform_params': {'with_channel':True}}
if with_pose_in:
data['pose_in'] = {'reader': data_iter.trans_reader,
'reader_params': {'multi_return': True,
'convert_to': 'mat'},
'is_img': False,
'transform': ts.pose_transform,
'transform_params':{}}
if with_points:
data['points'] = {'size': [512/2, 608/2],
'reader': data_iter.depth_reader,
'is_img': False,
'reader_params': {'K': K},
'transform':ts.point_transform,
'transform_params':{}}
label = OrderedDict([])
if pre_render:
label['pose'] = {'reader': np.loadtxt,
'reader_params': {},
'transform' : ts.pose_transform,
'transform_params': {}}
return data, label
def get_seg_cnn_setting(with_3d=False,
pre_render=False,
method='',
ignore_labels=0,
gt_type='',
obj_ids=None,
label_mapping=None):
"""
Inputs:
with_3d: whether have rendered label as input for the network
pre_render: whether directly load the pre-rendered label map
"""
data= OrderedDict([])
data['data'] = {'size': [512, 608],
'channel': 3,
'is_img': True,
'resize_method': cv2.INTER_CUBIC,
'transform':ts.image_transform,
'transform_params':{}}
if with_3d:
if pre_render:
data['label_db'] = {'size': [512, 608],
'reader': data_iter.trans_reader_pre,
'reader_params': {'is_gt':True} if method=='gt' \
else {},
'channel': 1,
'is_img': False,
'resize_method': cv2.INTER_NEAREST,
'transform':ts.label_db_transform,
'transform_params':{'with_channel':True}}
else:
data['label_db'] = {'size': [512, 608],
'reader': data_iter.trans_reader,
'reader_params': {'multi_return': False,
'proj_mat': True},
'channel': 1,
'is_img': False,
'resize_method': cv2.INTER_NEAREST,
'transform':ts.label_db_transform,
'transform_params':{'with_channel':True,
'ignore_labels':ignore_labels}}
label = OrderedDict([])
label['softmax_label'] = {'size': [512, 608],
'channel': 1,
'resize_method': cv2.INTER_NEAREST,
'transform':ts.label_transform,
'transform_params':{
'label_mapping':label_mapping}}
return data, label
config.network = edict()
config.network.pose_cnn_setting = get_pose_cnn_setting
config.network.seg_cnn_setting = get_seg_cnn_setting