def __init__(self, top_shape, front_shape, rgb_shape, debug_mode=False, log_tag=None, weigths_dir=None): # anchors self.top_stride = None self.num_class = data.preprocess.num_class # incude background if cfg.OBJ_TYPE == 'ped': ratios = np.array([1], dtype=np.float32) elif cfg.OBJ_TYPE == 'car': ratios = np.array([0.5, 1, 2], dtype=np.float32) scales = np.array([1, 2, 3], dtype=np.float32) self.bases = make_bases( base_size=16, ratios=ratios, #aspet ratio scales=scales) # output dir, etc utilfile.makedirs(cfg.CHECKPOINT_DIR) self.log_msg = utilfile.Logger(cfg.LOG_DIR + '/log.txt', mode='a') self.track_log = utilfile.Logger(cfg.LOG_DIR + '/tracking_log.txt', mode='a') # creat sesssion self.config = tf.ConfigProto() self.config.gpu_options.allow_growth = True self.sess = tf.Session(config=self.config) self.debug_mode = debug_mode if self.debug_mode: print('\n\nstart debug mode\n\n') self.sess = tf_debug.LocalCLIDebugWrapperSession(self.sess) self.sess.add_tensor_filter('has_inf_or_nan', tf_debug.has_inf_or_nan) self.use_pretrain_weights = [] self.build_net(top_shape, front_shape, rgb_shape) #init subnet self.tag = log_tag self.ckpt_dir = os.path.join( cfg.CHECKPOINT_DIR, log_tag) if weigths_dir == None else weigths_dir self.subnet_rpn = Net(prefix='MV3D', scope_name=mv3d_net.top_view_rpn_name, checkpoint_dir=self.ckpt_dir) self.subnet_imfeatrue = Net(prefix='MV3D', scope_name=mv3d_net.imfeature_net_name, checkpoint_dir=self.ckpt_dir) self.subnet_fusion = Net(prefix='MV3D', scope_name=mv3d_net.fusion_net_name, checkpoint_dir=self.ckpt_dir) # set anchor boxes self.top_stride = self.net['top_feature_stride'] top_feature_shape = get_top_feature_shape(top_shape, self.top_stride) self.top_view_anchors, self.anchors_inside_inds = make_anchors( self.bases, self.top_stride, top_shape[0:2], top_feature_shape[0:2]) self.anchors_inside_inds = np.arange( 0, len(self.top_view_anchors), dtype=np.int32) # use all #<todo> self.log_subdir = None self.top_image = None self.time_str = None self.frame_info = None self.batch_top_inds = None self.batch_top_labels = None self.batch_top_pos_inds = None self.batch_top_targets = None self.batch_proposals = None self.batch_proposal_scores = None self.batch_gt_top_boxes = None self.batch_gt_labels = None # default_summary_writer self.default_summary_writer = None # about tensorboard. self.tb_dir = log_tag if log_tag != None else strftime( "%Y_%m_%d_%H_%M", localtime()) self.log_iou_range = [ range(0, 2), range(2, 30), range(30, 60), range(60, 100) ] self.raw_img = raw_data_from_mapping.Image()
def __init__(self, top_shape, front_shape, rgb_shape, debug_mode=False, log_tag=None, weigths_dir=None): # anchors self.top_stride = None self.num_class = 2 # incude background ratios = np.array([0.5, 1, 2], dtype=np.float32) scales = np.array([1, 2, 3], dtype=np.float32) self.bases = make_bases( base_size=16, ratios=ratios, #aspet ratio scales=scales) # output dir, etc utilfile.makedirs(cfg.CHECKPOINT_DIR) self.log_msg = utilfile.Logger(cfg.LOG_DIR + '/log.txt', mode='a') self.track_log = utilfile.Logger(cfg.LOG_DIR + '/tracking_log.txt', mode='a') # creat sesssion self.sess = tf.Session() self.use_pretrain_weights = [] self.build_net(top_shape, front_shape, rgb_shape) #init subnet self.tag = log_tag self.ckpt_dir = os.path.join( cfg.CHECKPOINT_DIR, log_tag) if weigths_dir == None else weigths_dir self.subnet_rpn = Net(prefix='MV3D', scope_name=mv3d_net.top_view_rpn_name, checkpoint_dir=self.ckpt_dir) self.subnet_imfeatrue = Net(prefix='MV3D', scope_name=mv3d_net.imfeature_net_name, checkpoint_dir=self.ckpt_dir) self.subnet_fusion = Net(prefix='MV3D', scope_name=mv3d_net.fusion_net_name, checkpoint_dir=self.ckpt_dir) # set anchor boxes self.top_stride = self.net['top_feature_stride'] top_feature_shape = get_top_feature_shape(top_shape, self.top_stride) self.top_view_anchors, self.anchors_inside_inds = make_anchors( self.bases, self.top_stride, top_shape[0:2], top_feature_shape[0:2]) self.anchors_inside_inds = np.arange( 0, len(self.top_view_anchors), dtype=np.int32) # use all #<todo> self.log_subdir = None self.top_image = None self.time_str = None self.frame_info = None self.batch_top_inds = None self.batch_top_labels = None self.batch_top_pos_inds = None self.batch_top_targets = None self.batch_proposals = None self.batch_proposal_scores = None self.batch_gt_top_boxes = None self.batch_gt_labels = None # default_summary_writer self.default_summary_writer = None self.debug_mode = debug_mode # about tensorboard. self.tb_dir = log_tag if log_tag != None else strftime( "%Y_%m_%d_%H_%M", localtime())