def PRRB(xyz,x_points,is_training, bn_decay, i): c=x_points.shape[2] # (B,N,512) x1 = tf_util.conv1d(x_points, c, 1, padding='VALID', bn=True, is_training=is_training, scope='fc_URB_'+str(i),bn_decay=bn_decay,activation_fn=None) x11=x1 # (B,N,512) _, x11, _ = pointSIFT_module(xyz, x11, radius=0.2, out_channel=c, is_training=is_training, bn_decay=bn_decay,bn=True, scope='fsift_URB_'+str(i)+'_1') x11 = lrelu(x11, 0) # (B,N,512) _, x11, _ = pointSIFT_module(xyz, x11, radius=0.2, out_channel=c, is_training=is_training, bn_decay=None, bn=False, scope='fsiftnobn_URB_'+str(i)+'_1') # (B,N,512) x=tf.add(x11,x1) x = lrelu(x, 0) return x
def get_model(point_cloud, is_training, num_class, bn_decay=None): """ Semantic segmentation PointNet, input is BxNx5, output Bxnum_class """ batch_size = point_cloud.get_shape()[0].value num_point = point_cloud.get_shape()[1].value end_points = {} l0_xyz = tf.slice(point_cloud, [0, 0, 0], [-1, -1, 3]) # x, y ,z => BxNx3 l0_points = tf.slice(point_cloud, [0, 0, 3], [-1, -1, 2]) # 强度,返回值 =>BxNx2 end_points['l0_xyz'] = l0_xyz # c0 c0_l0_xyz, c0_l0_points, c0_l0_indices = pointSIFT_res_module( l0_xyz, l0_points, radius=0.1, out_channel=64, is_training=is_training, bn_decay=bn_decay, scope='layer0_c0', merge='concat') l1_xyz, l1_points, l1_indices = pointnet_sa_module_layer1( c0_l0_xyz, c0_l0_points, npoint=512, radius=0.1, nsample=32, mlp=[64, 128], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer1') # c1 c0_l1_xyz, c0_l1_points, c0_l1_indices = pointSIFT_res_module( l1_xyz, l1_points, radius=0.25, out_channel=128, is_training=is_training, bn_decay=bn_decay, scope='layer1_c0') l2_xyz, l2_points, l2_indices = pointnet_sa_module(c0_l1_xyz, c0_l1_points, npoint=256, radius=0.2, nsample=32, mlp=[128, 256], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer2') # c2 c0_l2_xyz, c0_l2_points, c0_l2_indices = pointSIFT_res_module( l2_xyz, l2_points, radius=0.5, out_channel=256, is_training=is_training, bn_decay=bn_decay, scope='layer2_c0') c1_l2_xyz, c1_l2_points, c1_l2_indices = pointSIFT_res_module( c0_l2_xyz, c0_l2_points, radius=0.5, out_channel=512, is_training=is_training, bn_decay=bn_decay, scope='layer2_c1', same_dim=True) l2_cat_points = tf.concat([c0_l2_points, c1_l2_points], axis=-1) fc_l2_points = tf_util.conv1d(l2_cat_points, 512, 1, padding='VALID', bn=True, is_training=is_training, scope='conv_2_fc', bn_decay=bn_decay) # c3 l3_xyz, l3_points, l3_indices = pointnet_sa_module(c1_l2_xyz, fc_l2_points, npoint=64, radius=0.4, nsample=32, mlp=[512, 512], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer3') l2_points = pointnet_fp_module(l2_xyz, l3_xyz, l2_points, l3_points, [512, 512], is_training, bn_decay, scope='fa_layer2') _, l2_points_1, _ = pointSIFT_module(l2_xyz, l2_points, radius=0.5, out_channel=512, is_training=is_training, bn_decay=bn_decay, scope='fa_layer2_c0') _, l2_points_2, _ = pointSIFT_module(l2_xyz, l2_points, radius=0.5, out_channel=512, is_training=is_training, bn_decay=bn_decay, scope='fa_layer2_c1') _, l2_points_3, _ = pointSIFT_module(l2_xyz, l2_points, radius=0.5, out_channel=512, is_training=is_training, bn_decay=bn_decay, scope='fa_layer2_c2') l2_points = tf.concat([l2_points_1, l2_points_2, l2_points_3], axis=-1) l2_points = tf_util.conv1d(l2_points, 512, 1, padding='VALID', bn=True, is_training=is_training, scope='fa_2_fc', bn_decay=bn_decay) l1_points = pointnet_fp_module(l1_xyz, l2_xyz, l1_points, l2_points, [256, 256], is_training, bn_decay, scope='fa_layer3') _, l1_points_1, _ = pointSIFT_module(l1_xyz, l1_points, radius=0.25, out_channel=256, is_training=is_training, bn_decay=bn_decay, scope='fa_layer3_c0') _, l1_points_2, _ = pointSIFT_module(l1_xyz, l1_points_1, radius=0.25, out_channel=256, is_training=is_training, bn_decay=bn_decay, scope='fa_layer3_c1') l1_points = tf.concat([l1_points_1, l1_points_2], axis=-1) l1_points = tf_util.conv1d(l1_points, 256, 1, padding='VALID', bn=True, is_training=is_training, scope='fa_1_fc', bn_decay=bn_decay) l0_points = pointnet_fp_module(l0_xyz, l1_xyz, l0_points, l1_points, [128, 128, 128], is_training, bn_decay, scope='fa_layer4') _, l0_points, _ = pointSIFT_module(l0_xyz, l0_points, radius=0.1, out_channel=128, is_training=is_training, bn_decay=bn_decay, scope='fa_layer4_c0') # FC layers net = tf_util.conv1d(l0_points, 128, 1, padding='VALID', bn=True, is_training=is_training, scope='fc1', bn_decay=bn_decay) net = tf_util.dropout(net, keep_prob=0.5, is_training=is_training, scope='dp1') net = tf_util.conv1d(net, num_class, 1, padding='VALID', activation_fn=None, scope='fc2') return net, end_points
def get_model(point_cloud, is_training, num_class, bn_decay=None, feature=None): """ Semantic segmentation PointNet, input is B x N x 3, output B x num_class """ end_points = {} l0_xyz = point_cloud[:, :, :3] l0_points = point_cloud end_points['l0_xyz'] = l0_xyz # c0 c0_l0_xyz, c0_l0_points, c0_l0_indices = pointSIFT_res_module( l0_xyz, l0_points, radius=0.1, out_channel=64, is_training=is_training, bn_decay=bn_decay, scope='layer0_c0', merge='concat') ###c0_10_points(B,8192,64) l1_xyz, l1_points, l1_indices = pointnet_sa_module(c0_l0_xyz, c0_l0_points, npoint=1024, radius=0.1, nsample=32, mlp=[64, 128], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer1') ###l1_points:(B,1024,128) # c1 c0_l1_xyz, c0_l1_points, c0_l1_indices = pointSIFT_res_module( l1_xyz, l1_points, radius=0.25, out_channel=128, is_training=is_training, bn_decay=bn_decay, scope='layer1_c0') ###c0_11_points(B,1024,128) l2_xyz, l2_points, l2_indices = pointnet_sa_module(c0_l1_xyz, c0_l1_points, npoint=256, radius=0.2, nsample=32, mlp=[128, 256], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer2') ###l2_points(B,256,256) # c2 c0_l2_xyz, c0_l2_points, c0_l2_indices = pointSIFT_res_module( l2_xyz, l2_points, radius=0.5, out_channel=256, is_training=is_training, bn_decay=bn_decay, scope='layer2_c0') ###c0_12_points(B,256,256) c1_l2_xyz, c1_l2_points, c1_l2_indices = pointSIFT_res_module( c0_l2_xyz, c0_l2_points, radius=0.5, out_channel=512, is_training=is_training, bn_decay=bn_decay, scope='layer2_c1', same_dim=True) ###c1_12_points(B,256,512) l2_cat_points = tf.concat([c0_l2_points, c1_l2_points], axis=-1) ###12_cat_points(B,256,768) fc_l2_points = tf_util.conv1d(l2_cat_points, 512, 1, padding='VALID', bn=True, is_training=is_training, scope='conv_2_fc', bn_decay=bn_decay) ###fc_cat_points(B,256,512) # c3 l3_xyz, l3_points, l3_indices = pointnet_sa_module(c1_l2_xyz, fc_l2_points, npoint=64, radius=0.4, nsample=32, mlp=[512, 512], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer3') ###l3_point (B,64,512) l2_points = pointnet_fp_module(l2_xyz, l3_xyz, l2_points, l3_points, [512, 512], is_training, bn_decay, scope='fa_layer2') ###l2_points(B,256,512) _, l2_points_1, _ = pointSIFT_module(l2_xyz, l2_points, radius=0.5, out_channel=512, is_training=is_training, bn_decay=bn_decay, scope='fa_layer2_c0') _, l2_points_2, _ = pointSIFT_module(l2_xyz, l2_points, radius=0.5, out_channel=512, is_training=is_training, bn_decay=bn_decay, scope='fa_layer2_c1') _, l2_points_3, _ = pointSIFT_module(l2_xyz, l2_points, radius=0.5, out_channel=512, is_training=is_training, bn_decay=bn_decay, scope='fa_layer2_c2') ###l2_points_1,2,3(B,256,512) l2_points = tf.concat([l2_points_1, l2_points_2, l2_points_3], axis=-1) ###l2_points(B,256,1536) l2_points = tf_util.conv1d(l2_points, 512, 1, padding='VALID', bn=True, is_training=is_training, scope='fa_2_fc', bn_decay=bn_decay) ###l2_points(B,256,512) l1_points = pointnet_fp_module(l1_xyz, l2_xyz, l1_points, l2_points, [256, 256], is_training, bn_decay, scope='fa_layer3') ###l1_points:(B,1024,256) _, l1_points_1, _ = pointSIFT_module(l1_xyz, l1_points, radius=0.25, out_channel=256, is_training=is_training, bn_decay=bn_decay, scope='fa_layer3_c0') ###l1_points_1(B,1024,256) _, l1_points_2, _ = pointSIFT_module(l1_xyz, l1_points_1, radius=0.25, out_channel=256, is_training=is_training, bn_decay=bn_decay, scope='fa_layer3_c1') ###l1_points_1(B,1024,256) l1_points = tf.concat([l1_points_1, l1_points_2], axis=-1) ###l1_points_1(B,1024,512) l1_points = tf_util.conv1d(l1_points, 256, 1, padding='VALID', bn=True, is_training=is_training, scope='fa_1_fc', bn_decay=bn_decay) ###l1_points_1(B,1024,256) l0_points = pointnet_fp_module(l0_xyz, l1_xyz, l0_points, l1_points, [128, 128, 128], is_training, bn_decay, scope='fa_layer4') ###l0_points(B,8192, 256) _, l0_points, _ = pointSIFT_module(l0_xyz, l0_points, radius=0.1, out_channel=128, is_training=is_training, bn_decay=bn_decay, scope='fa_layer4_c0') ###l0_points(B,8192,128) # FC layers net = tf_util.conv1d(l0_points, 128, 1, padding='VALID', bn=True, is_training=is_training, scope='fc1', bn_decay=bn_decay) ###l0_points(B,8192,128) net = tf_util.dropout(net, keep_prob=0.5, is_training=is_training, scope='dp1') net = tf_util.conv1d(net, num_class, 1, padding='VALID', activation_fn=None, scope='fc2') return net, end_points
def get_model(point_cloud, is_training, num_class, bn_decay=None, feature=None): """ Semantic segmentation PointNet, input is B x N x 3, output B x num_class """ end_points = {} l0_xyz = point_cloud[:,:,:3] l0_points = point_cloud end_points['l0_xyz'] = l0_xyz #################################################### E N C O D E R ###################################################### ################################################### c0 c0_l0_xyz, c0_l0_points, c0_l0_indices = pointSIFT_res_module(l0_xyz, l0_points, radius=0.1, out_channel=64, is_training=is_training, bn_decay=bn_decay, scope='layer0_c0', merge='concat') ###c0_10_points(B,N,64) l1_xyz, l1_points, l1_indices = pointnet_sa_module(c0_l0_xyz, c0_l0_points, npoint=4096, radius=0.1, nsample=32, mlp=[128], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer0') ###l1_points:(B,4096,128) ################################################### c1 c0_l1_xyz, c0_l1_points, c0_l1_indices = pointSIFT_res_module(l1_xyz, l1_points, radius=0.2, out_channel=128, is_training=is_training, bn_decay=bn_decay, scope='layer1_c0',merge='concat') ###c0_11_points(B,4096,128) l2_xyz, l2_points, l2_indices = pointnet_sa_module(c0_l1_xyz, c0_l1_points, npoint=1024, radius=0.2, nsample=32, mlp=[256], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer1') ###l2_points(B,1024,256) #################################################### c2 c0_l2_xyz, c0_l2_points, c0_l2_indices = pointSIFT_res_module(l2_xyz, l2_points, radius=0.2, out_channel=256, is_training=is_training, bn_decay=bn_decay, scope='layer2_c0',merge='concat') ###c0_12_points(B,1024,256) l3_xyz, l3_points, l3_indices = pointnet_sa_module(c0_l2_xyz, c0_l2_points, npoint=256, radius=0.2, nsample=32, mlp=[512], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer2') #l3_points(B,256,512) #################################################### c3 c0_l3_xyz, c0_l3_points, c0_l3_indices = pointSIFT_res_module(l3_xyz, l3_points, radius=0.2, out_channel=512, is_training=is_training, bn_decay=bn_decay, scope='layer3_c0',merge='concat') ###c0_13_points(B,256,512) l4_xyz, l4_points, l4_indices = pointnet_sa_module(c0_l3_xyz, c0_l3_points, npoint=64, radius=0.2, nsample=32, mlp=[1024], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer3') # l4_points(B,64,1024) #################################################### c4 c0_l4_xyz, c0_l4_points, c0_l4_indices = pointSIFT_res_module(l4_xyz, l4_points, radius=0.2, out_channel=1024, is_training=is_training, bn_decay=bn_decay, scope='layer4_c0',merge='concat') ###c0_14_points(B,64,1024) l5_xyz, l5_points, l5_indices = pointnet_sa_module(c0_l4_xyz, c0_l4_points, npoint=16, radius=0.2, nsample=32, mlp=[2048], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer4') # l5_points(B,16,2048) #################################################### c5 # c0_l5_xyz, c0_l5_points, c0_l5_indices = pointSIFT_res_module(l5_xyz, l5_points, radius=0.2, out_channel=2048, # is_training=is_training, bn_decay=bn_decay, # scope='layer5_c0',merge='concat') # ###c0_15_points(B,64,2048) # # l6_xyz, l6_points, l6_indices = pointnet_sa_module(c0_l5_xyz, c0_l5_points, npoint=16, radius=0.2, nsample=32, # mlp=[4096], mlp2=None, group_all=False, # is_training=is_training, bn_decay=bn_decay, scope='layer5') # l6_points(B,16,4096) #################################################### c6 # c0_l6_xyz, c0_l6_points, c0_l6_indices = pointSIFT_res_module(l6_xyz, l6_points, radius=0.2, out_channel=4096, # is_training=is_training, bn_decay=bn_decay, # scope='layer6_c0', merge='concat') # ###c0_16_points(B,16,4096) # # gp_xyz, gp_points, gp_indices = pointnet_sa_module(c0_l6_xyz, c0_l6_points, npoint=16, radius=0.2, nsample=32, # mlp=[4096], mlp2=None, group_all=True, # is_training=is_training, bn_decay=bn_decay, scope='layer6') # # gp_points(B,1,4096) #################################################### D E C O D E R ####################################################### # ugp_points=tf.expand_dims(gp_points, 1)#(B,1,1,4096) # # ugp_points=tf_util.conv2d_transpose(ugp_points,4096,[int(l6_points.shape[1]),1],padding='VALID',stride=[1,1], # activation_fn=None, bn=True, is_training=is_training, scope='dconv1', # bn_decay=bn_decay) # # ugp_points=tf.squeeze(ugp_points, [2])#(B,16,4096) ##################################################### stage 6 # u6_points_0 = PRRB(l6_xyz, l6_points, is_training, bn_decay,1) # # # u6_points(B,16,4096) # # c6_points = PCAB(u6_points_0, ugp_points,is_training, bn_decay,1) # # # c6_points(B,16,4096) # # u6_points_1 = PRRB(l6_xyz, c6_points, is_training, bn_decay, 2) # u6_points(B,16,4096) # l5_points_2 = pointnet_fp_module(l5_xyz, l6_xyz, l5_points, l6_points, [2048], is_training, bn_decay, # scope='fp_layer6') # # ##################################################### stage 5 # # u5_points_0 = PRRB(l5_xyz, l5_points, is_training, bn_decay, 3) # # # u5_points(B,64,2048) # # c5_points = PCAB(u5_points_0, l5_points_2, is_training, bn_decay, 2) # # # c5_points(B,64,2048) # # u5_points_1 = PRRB(l5_xyz, c5_points, is_training, bn_decay, 4) # # # u5_points(B,64,2048) l4_points_2 = pointnet_fp_module(l4_xyz, l5_xyz, l4_points, l5_points, [1024], is_training, bn_decay, scope='fp_layer5') ###################################################### stage 4 u4_points_0 = PRRB(l4_xyz, l4_points, is_training, bn_decay, 5) # u4_points(B,128,1024) c4_points = PCAB(u4_points_0, l4_points_2, is_training, bn_decay, 3) # c4_points(B,128,1024) u4_points_1 = PRRB(l4_xyz, c4_points, is_training, bn_decay, 6) # u4_points(B,128,1024) l3_points_2 = pointnet_fp_module(l3_xyz, l4_xyz, l3_points, u4_points_1, [512], is_training, bn_decay, scope='fp_layer4') ####################################################### stage 3 u3_points_0 = PRRB(l3_xyz, l3_points, is_training, bn_decay, 7) # u3_points(B,512,512) c3_points = PCAB(u3_points_0, l3_points_2, is_training, bn_decay, 4) # c3_points(B,512,512) u3_points_1 = PRRB(l3_xyz, c3_points, is_training, bn_decay, 8) # u3_points(B,512,512) l2_points_2 = pointnet_fp_module(l2_xyz, l3_xyz, l2_points, u3_points_1, [256], is_training, bn_decay, scope='fp_layer3') ######################################################## stage 2 u2_points_0 = PRRB(l2_xyz, l2_points, is_training, bn_decay, 9) # u2_points(B,2048,256) c2_points = PCAB(u2_points_0, l2_points_2, is_training, bn_decay, 5) # c2_points(B,2048,256) u2_points_1 = PRRB(l2_xyz, c2_points, is_training, bn_decay, 10) # u2_points(B,2048,256) l1_points_2 = pointnet_fp_module(l1_xyz, l2_xyz, l1_points, u2_points_1, [128], is_training, bn_decay, scope='fp_layer2') ######################################################### stage 1 u1_points_0 = PRRB(l1_xyz, l1_points, is_training, bn_decay, 11) # u1_points(B,8192,128) c1_points = PCAB(u1_points_0, l1_points_2, is_training, bn_decay, 6) # c1_points(B,8192,128) u1_points_1 = PRRB(l1_xyz, c1_points, is_training, bn_decay, 12) # u1_points(B,8192,128) l0_points = pointnet_fp_module(l0_xyz, l1_xyz, l0_points, u1_points_1, [128, 128], is_training, bn_decay, scope='fp_layer1') _, l0_points, _ = pointSIFT_module(l0_xyz, l0_points, radius=0.1, out_channel=128, is_training=is_training, bn_decay=bn_decay, scope='fsift_0') ######################################################### stage 0 # FC layers net = tf_util.conv1d(l0_points, 128, 1, padding='VALID', bn=True, is_training=is_training, scope='fc1', bn_decay=bn_decay) ###l0_points(B,8192*5,128) end_points['feats']=net net = tf_util.dropout(net, keep_prob=0.5, is_training=is_training, scope='dp1') net = tf_util.conv1d(net, num_class, 1, padding='VALID', activation_fn=None, scope='fc2') extract_fea=tf.concat([end_points['l0_xyz'],end_points['feats']],axis=-1) return net, extract_fea