Skip to content

Commit

Permalink
fix flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
wangg12 committed Dec 13, 2018
1 parent 902bc36 commit 6eb3cdc
Show file tree
Hide file tree
Showing 83 changed files with 4,886 additions and 3,114 deletions.
13 changes: 13 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
dist: trusty
language: python

install:
- pip install flake8

python:
- "2.7"
- "3.5"
- "3.6"

script:
- flake8
2 changes: 2 additions & 0 deletions deepim/_init_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
import os.path as osp
import sys


def add_path(path):
if path not in sys.path:
sys.path.insert(0, path)


this_dir = osp.dirname(__file__)

lib_path = osp.join(this_dir, '../lib')
Expand Down
56 changes: 33 additions & 23 deletions deepim/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

config.output_path = ''
config.symbol = ''
config.SCALES = [(480, 640)] # first is scale (the shorter side); second is max size
config.SCALES = [(480, 640)
] # first is scale (the shorter side); second is max size

# default training
config.default = edict()
Expand All @@ -36,11 +37,10 @@
config.network.STANDARD_FLOW_REP = False
config.network.TRAIN_ITER = False
config.network.TRAIN_ITER_SIZE = 1
config.network.REGRESSOR_NUM = 1 # 1 or num_classes
config.network.ROT_TYPE = 'QUAT' # 'QUAT', 'EULER'
config.network.REGRESSOR_NUM = 1 # 1 or num_classes
config.network.ROT_TYPE = 'QUAT' # 'QUAT', 'EULER'
config.network.ROT_COORD = 'CAMERA'
config.network.TRANS_LOSS_TYPE = 'L2' # 'L1', 'smooth_L1'

config.network.TRANS_LOSS_TYPE = 'L2' # 'L1', 'smooth_L1'

# dataset related params
config.dataset = edict()
Expand All @@ -50,13 +50,15 @@
config.dataset.root_path = './data'
config.dataset.test_image_set = 'val_ape'
config.dataset.model_dir = ''
config.dataset.model_file = './data/ModelNet/render_v1/models.txt' # optional, if too many classes
config.dataset.pose_file = './data/ModelNet/render_v1/poses.txt' # optional, if too many classes
config.dataset.model_file = './data/ModelNet/render_v1/models.txt' # optional, if too many classes
config.dataset.pose_file = './data/ModelNet/render_v1/poses.txt' # optional, if too many classes

config.dataset.DEPTH_FACTOR = 1000
config.dataset.NORMALIZE_FLOW = 1.0
config.dataset.NORMALIZE_3D_POINT = 0.1
config.dataset.INTRINSIC_MATRIX = np.array([[572.4114, 0, 325.2611], [0, 573.57043, 242.04899], [0, 0, 1]])
config.dataset.INTRINSIC_MATRIX = np.array([[572.4114, 0, 325.2611],
[0, 573.57043, 242.04899],
[0, 0, 1]])
config.dataset.ZNEAR = 0.25
config.dataset.ZFAR = 6.0

Expand All @@ -80,13 +82,13 @@
config.TRAIN.RESUME = False
config.TRAIN.SHUFFLE = True
config.TRAIN.BATCH_PAIRS = 1
config.TRAIN.FLOW_WEIGHT_TYPE = 'all' # 'all', 'viz', 'valid'
config.TRAIN.FLOW_WEIGHT_TYPE = 'all' # 'all', 'viz', 'valid'
# config.TRAIN.VISUALIZE = False
config.TRAIN.TENSORBOARD_LOG = False
config.TRAIN.INIT_MASK = 'box_gt' # mask_gt, box_gt
config.TRAIN.INIT_MASK = 'box_gt' # mask_gt, box_gt
config.TRAIN.UPDATE_MASK = 'box_gt'
config.TRAIN.MASK_DILATE = False
config.TRAIN.REPLACE_OBSERVED_BG_RATIO = 0.0 # replace train images' bg with VOC
config.TRAIN.REPLACE_OBSERVED_BG_RATIO = 0.0 # replace train images' bg with VOC

config.TEST = edict()
config.TEST.BATCH_PAIRS = 1
Expand All @@ -96,28 +98,29 @@
config.TEST.INIT_MASK = 'box_rendered'
config.TEST.UPDATE_MASK = 'box_rendered'
config.TEST.FAST_TEST = False
config.TEST.PRECOMPUTED_ICP = False # evaluate with ICP refinement
config.TEST.BEFORE_ICP = False # evaluate without ICP refinement
config.TEST.PRECOMPUTED_ICP = False # evaluate with ICP refinement
config.TEST.BEFORE_ICP = False # evaluate without ICP refinement

# for iterative train
## se3 distance loss
# se3 distance loss
config.train_iter = edict()
config.train_iter.SE3_DIST_LOSS = False
config.train_iter.LW_ROT = 0.0
config.train_iter.LW_TRANS = 0.0
config.train_iter.TRANS_LOSS_TYPE = 'L2' # 'L1', 'smooth_L1'
config.train_iter.TRANS_LOSS_TYPE = 'L2' # 'L1', 'smooth_L1'
config.train_iter.TRANS_SMOOTH_L1_SCALAR = 3.0
## se3 point matching loss
# se3 point matching loss
config.train_iter.SE3_PM_LOSS = False
config.train_iter.LW_PM = 0.0
config.train_iter.SE3_PM_LOSS_TYPE = 'L1'
config.train_iter.SE3_PM_SL1_SCALAR = 1.0
config.train_iter.NUM_3D_SAMPLE = -1
## flow loss
# flow loss
config.train_iter.LW_FLOW = 0.0
## segmentation loss
# segmentation loss
config.train_iter.LW_MASK = 0.0


def update_config(config_file):
exp_config = None
with open(config_file) as f:
Expand All @@ -134,15 +137,21 @@ def update_config(config_file):
elif k == 'dataset':
# make elegant later
if 'INTRINSIC_MATRIX' in v:
v['INTRINSIC_MATRIX'] = np.array(v['INTRINSIC_MATRIX']).reshape([3,3]).astype(np.float32)
v['INTRINSIC_MATRIX'] = np.array(
v['INTRINSIC_MATRIX']).reshape([3, 3]).astype(
np.float32)
if 'trans_means' in v:
v['trans_means'] = np.array(v['trans_means']).flatten().astype(np.float32)
v['trans_means'] = np.array(
v['trans_means']).flatten().astype(np.float32)
if 'trans_stds' in v:
v['trans_stds'] = np.array(v['trans_stds']).flatten().astype(np.float32)
v['trans_stds'] = np.array(
v['trans_stds']).flatten().astype(np.float32)
if 'class_name_file' in v:
if v['class_name_file'] != '':
with open(v['class_name_file']) as f:
v['class_name'] = [line.strip() for line in f.readlines()]
v['class_name'] = [
line.strip() for line in f.readlines()
]
for vk, vv in v.items():
config[k][vk] = vv
else:
Expand All @@ -151,4 +160,5 @@ def update_config(config_file):
else:
config[k] = v
else:
raise ValueError("key: {} does not exist in config.py".format(k))
raise ValueError(
"key: {} does not exist in config.py".format(k))
Loading

0 comments on commit 6eb3cdc

Please sign in to comment.