return 0 normals, lower, upper = dataset.box3d_to_normals(label) projected = np.matmul(xyz, np.transpose(normals)) x_cover_rate = (np.max(projected[:, 0])-np.min(projected[:, 0]))\ /(upper[0] - lower[0]) y_cover_rate = (np.max(projected[:, 1])-np.min(projected[:, 1]))\ /(upper[1] - lower[1]) z_cover_rate = (np.max(projected[:, 2])-np.min(projected[:, 2]))\ /(upper[2] - lower[2]) return x_cover_rate * y_cover_rate * z_cover_rate # setup model ================================================================= BOX_ENCODING_LEN = get_encoding_len(config['box_encoding_method']) box_encoding_fn = get_box_encoding_fn(config['box_encoding_method']) box_decoding_fn = get_box_decoding_fn(config['box_encoding_method']) if config['input_features'] == 'irgb': t_initial_vertex_features = tf.placeholder(dtype=tf.float32, shape=[None, 4]) elif config['input_features'] == 'rgb': t_initial_vertex_features = tf.placeholder(dtype=tf.float32, shape=[None, 3]) elif config['input_features'] == '0000': t_initial_vertex_features = tf.placeholder(dtype=tf.float32, shape=[None, 4]) elif config['input_features'] == 'i000': t_initial_vertex_features = tf.placeholder(dtype=tf.float32, shape=[None, 4]) elif config['input_features'] == 'i': t_initial_vertex_features = tf.placeholder(dtype=tf.float32, shape=[None, 1])
def fetch_data(dataset, frame_idx, train_config, config): aug_fn = preprocess.get_data_aug(train_config['data_aug_configs']) BOX_ENCODING_LEN = get_encoding_len(config['box_encoding_method']) box_encoding_fn = get_box_encoding_fn(config['box_encoding_method']) box_decoding_fn = get_box_decoding_fn(config['box_encoding_method']) graph_generate_fn = get_graph_generate_fn(config['graph_gen_method']) cam_rgb_points = dataset.get_cam_points_in_image_with_rgb( frame_idx, config['downsample_by_voxel_size']) box_label_list = dataset.get_label(frame_idx) if 'crop_aug' in train_config: cam_rgb_points, box_label_list = sampler.crop_aug( cam_rgb_points, box_label_list, sample_rate=train_config['crop_aug']['sample_rate'], parser_kwargs=train_config['crop_aug']['parser_kwargs']) cam_rgb_points, box_label_list = aug_fn(cam_rgb_points, box_label_list) (vertex_coord_list, keypoint_indices_list, edges_list) = \ graph_generate_fn(cam_rgb_points.xyz, **config['graph_gen_kwargs']) if config['input_features'] == 'irgb': input_v = cam_rgb_points.attr elif config['input_features'] == '0rgb': input_v = np.hstack([ np.zeros((cam_rgb_points.attr.shape[0], 1)), cam_rgb_points.attr[:, 1:] ]) elif config['input_features'] == '0000': input_v = np.zeros_like(cam_rgb_points.attr) elif config['input_features'] == 'i000': input_v = np.hstack([ cam_rgb_points.attr[:, [0]], np.zeros((cam_rgb_points.attr.shape[0], 3)) ]) elif config['input_features'] == 'i': input_v = cam_rgb_points.attr[:, [0]] elif config['input_features'] == '0': input_v = np.zeros((cam_rgb_points.attr.shape[0], 1)) last_layer_graph_level = config['model_kwargs']['layer_configs'][-1][ 'graph_level'] last_layer_points_xyz = vertex_coord_list[last_layer_graph_level + 1] if config['label_method'] == 'yaw': cls_labels, boxes_3d, valid_boxes, label_map = \ dataset.assign_classaware_label_to_points(box_label_list, last_layer_points_xyz, expend_factor=train_config.get('expend_factor', (1.0, 1.0, 1.0))) if config['label_method'] == 'Car': cls_labels, boxes_3d, valid_boxes, label_map = \ dataset.assign_classaware_car_label_to_points(box_label_list, last_layer_points_xyz, expend_factor=train_config.get('expend_factor', (1.0, 1.0, 1.0))) if config['label_method'] == 'Pedestrian_and_Cyclist': (cls_labels, boxes_3d, valid_boxes, label_map) =\ dataset.assign_classaware_ped_and_cyc_label_to_points( box_label_list, last_layer_points_xyz, expend_factor=train_config.get('expend_factor', (1.0, 1.0, 1.0))) encoded_boxes = box_encoding_fn(cls_labels, last_layer_points_xyz, boxes_3d, label_map) input_v = input_v.astype(np.float32) vertex_coord_list = [p.astype(np.float32) for p in vertex_coord_list] keypoint_indices_list = [e.astype(np.int32) for e in keypoint_indices_list] edges_list = [e.astype(np.int32) for e in edges_list] cls_labels = cls_labels.astype(np.int32) encoded_boxes = encoded_boxes.astype(np.float32) valid_boxes = valid_boxes.astype(np.float32) return (input_v, vertex_coord_list, keypoint_indices_list, edges_list, cls_labels, encoded_boxes, valid_boxes)