def backbone_pointnet(self, X_pc, is_train): [_, _, points_cc] = X_pc.get_shape() points_num = tf.shape(X_pc)[1] X_pc = tf.reshape(X_pc, [-1, points_num, int(points_cc), 1]) l1 = Ops.xxlu(Ops.conv2d(X_pc, k=(1, points_cc), out_c=64, str=1, pad='VALID', name='l1'), label='lrelu') l2 = Ops.xxlu(Ops.conv2d(l1, k=(1, 1), out_c=64, str=1, pad='VALID', name='l2'), label='lrelu') l3 = Ops.xxlu(Ops.conv2d(l2, k=(1, 1), out_c=64, str=1, pad='VALID', name='l3'), label='lrelu') l4 = Ops.xxlu(Ops.conv2d(l3, k=(1, 1), out_c=128, str=1, pad='VALID', name='l4'), label='lrelu') l5 = Ops.xxlu(Ops.conv2d(l4, k=(1, 1), out_c=1024, str=1, pad='VALID', name='l5'), label='lrelu') global_features = tf.reduce_max(l5, axis=1, name='maxpool') global_features = tf.reshape(global_features, [-1, int(l5.shape[-1])]) point_features = tf.reshape(l5, [-1, points_num, int(l5.shape[-1])]) #### sem g1 = Ops.xxlu(Ops.fc(global_features, out_d=256, name='semg1'), label='lrelu') g2 = Ops.xxlu(Ops.fc(g1, out_d=128, name='semg2'), label='lrelu') sem1 = tf.tile(g2[:,None,None,:], [1, points_num, 1, 1]) sem1 = tf.concat([l5, sem1], axis=-1) sem1 = Ops.xxlu(Ops.conv2d(sem1, k=(1,1), out_c=512, str=1, pad='VALID', name='sem1'), label='lrelu') sem2 = Ops.xxlu(Ops.conv2d(sem1, k=(1, 1), out_c=256, str=1, pad='VALID', name='sem2'), label='lrelu') sem3 = Ops.xxlu(Ops.conv2d(sem2, k=(1, 1), out_c=128, str=1, pad='VALID', name='sem3'), label='lrelu') sem3 = Ops.dropout(sem3, keep_prob=0.5, is_train=is_train, name='sem3_dropout') sem4 = Ops.conv2d(sem3, k=(1, 1), out_c=self.sem_num, str=1, pad='VALID', name='sem4') sem4 = tf.reshape(sem4, [-1, points_num, self.sem_num]) self.y_psem_logits = sem4 y_sem_pred = tf.nn.softmax(self.y_psem_logits, name='y_sem_pred') return point_features, global_features, y_sem_pred
def pmask_net(self, point_features, global_features, bbox, bboxscore): p_f_num = int(point_features.shape[-1]) p_num = tf.shape(point_features)[1] bb_num = int(bbox.shape[1]) global_features = tf.tile(Ops.xxlu(Ops.fc(global_features, out_d=256, name='down_g1'), label='lrelu')[:,None,None,:], [1, p_num, 1, 1]) point_features = Ops.xxlu(Ops.conv2d(point_features[:,:,:,None],k=(1, p_f_num), out_c=256, str=1,name='down_p1',pad='VALID'), label='lrelu') point_features = tf.concat([point_features, global_features], axis=-1) point_features = Ops.xxlu(Ops.conv2d(point_features, k=(1,int(point_features.shape[-2])), out_c=128, str=1, pad='VALID', name='down_p2'), label='lrelu') point_features = Ops.xxlu(Ops.conv2d(point_features, k=(1, int(point_features.shape[-2])), out_c=128, str=1, pad='VALID',name='down_p3'), label='lrelu') point_features = tf.squeeze(point_features, axis=-2) bbox_info = tf.tile(tf.concat([tf.reshape(bbox, [-1, bb_num, 6]), bboxscore[:,:,None]],axis=-1)[:,:,None,:], [1,1,p_num,1]) pmask0 = tf.tile(point_features[:,None,:,:], [1, bb_num, 1, 1]) pmask0 = tf.concat([pmask0, bbox_info], axis=-1) pmask0 = tf.reshape(pmask0, [-1, p_num, int(pmask0.shape[-1]), 1]) pmask1 = Ops.xxlu(Ops.conv2d(pmask0, k=(1,int(pmask0.shape[-2])), out_c=64, str=1, pad='VALID', name='pmask1'), label='lrelu') pmask2 = Ops.xxlu(Ops.conv2d(pmask1, k=(1, 1), out_c=32, str=1, pad='VALID', name='pmask2'),label='lrelu') pmask3 = Ops.conv2d(pmask2, k=(1,1), out_c=1, str=1, pad='VALID', name='pmask3') pmask3 = tf.reshape(pmask3, [-1, bb_num, p_num]) y_pmask_logits = pmask3 y_pmask_pred = tf.nn.sigmoid(y_pmask_logits, name='y_pmask_pred') return y_pmask_pred
def bbox_net(self, global_features): b1 = Ops.xxlu(Ops.fc(global_features, out_d= 512, name='b1'), label='lrelu') b2 = Ops.xxlu(Ops.fc(b1, out_d= 256, name='b2'), label='lrelu') #### sub branch 1 b3 = Ops.xxlu(Ops.fc(b2, out_d=256, name='b3'), label='lrelu') bbvert = Ops.fc(b3, out_d=self.bb_num * 2 * 3, name='bbvert') bbvert = tf.reshape(bbvert, [-1, self.bb_num, 2, 3]) points_min = tf.reduce_min(bbvert, axis=-2)[:, :, None, :] points_max = tf.reduce_max(bbvert, axis=-2)[:, :, None, :] y_bbvert_pred = tf.concat([points_min, points_max], axis=-2, name='y_bbvert_pred') #### sub branch 2 b4 = Ops.xxlu(Ops.fc(b2, out_d=256, name='b4'), label='lrelu') y_bbscore_pred = tf.sigmoid(Ops.fc(b4, out_d=self.bb_num * 1, name='y_bbscore_pred')) return y_bbvert_pred, y_bbscore_pred