Beispiel #1
0
def wnet_model(img,is_training,class_num,bn_decay=None):        

    with tf.variable_scope('input_layer'):

        out0=input_down_size_unit(img,64,192,is_training,bn_decay,'input_pre')
        skip0=out0

    with tf.variable_scope('intermidate_layer'):

        out1 ,skip1= skip_sbstract_layer(skip0,out0,[16,16,32],[[5,5],[3,3],[1,1]],is_training,bn_decay=bn_decay,scope='inception_1')      
        out2 ,skip2= skip_sbstract_layer(skip1,out1,[32,32,64],[[5,5],[3,3],[1,1]],is_training,bn_decay=bn_decay,scope='inception_2')       
        out3 ,skip3= skip_sbstract_layer(skip2,out2,[64,64,96],[[5,5],[3,3],[1,1]],is_training,bn_decay=bn_decay,scope='inception_3',maxpool=False) 
        
        out = output_down_size_unit(tf.concat((out3,skip3),-1),256,is_training,bn_decay,'out_downsize')
      
    with tf.variable_scope('output_layer'):        

        out = basic_tf.fully_connected(out,1024, bn=True, is_training=is_training, scope='fc1', bn_decay=bn_decay)
        out = basic_tf.dropout(out, keep_prob=0.5, is_training=is_training, scope='dp1')
        out = basic_tf.fully_connected(out,128, bn=True, is_training=is_training, scope='fc2', bn_decay=bn_decay)
        out = basic_tf.dropout(out, keep_prob=0.5, is_training=is_training, scope='dp2')       
        out = basic_tf.fully_connected(out,class_num, bn=True, is_training=is_training, scope='fc3', activation_fn=None,bn_decay=bn_decay)  
        out_pred = tf.argmax(out,1,name="final")
   
    return out,out_pred
Beispiel #2
0
def fullyconnected_layer(input, batch_size, class_num, scope, is_training,
                         bn_decay):

    with tf.variable_scope(scope):
        net = tf.reshape(input, (batch_size, -1))
        net = basic_tf.fully_connected(net,
                                       512,
                                       bn=True,
                                       is_training=is_training,
                                       scope='fc1',
                                       bn_decay=bn_decay)
        net = basic_tf.dropout(net,
                               keep_prob=0.5,
                               is_training=is_training,
                               scope='dp1')
        net = basic_tf.fully_connected(net,
                                       128,
                                       bn=True,
                                       is_training=is_training,
                                       scope='fc2',
                                       bn_decay=bn_decay)
        net = basic_tf.dropout(net,
                               keep_prob=0.5,
                               is_training=is_training,
                               scope='dp2')
        net = basic_tf.fully_connected(net,
                                       class_num,
                                       activation_fn=None,
                                       scope='fc3')

    return net
Beispiel #3
0
def basic_detectModel(img, is_training, bn_decay, cell_size, num_class,
                      box_num):  #512->4

    with tf.variable_scope('conv_unit1'):

        out = basic_tf.conv2d(img, 16, [3, 3], 'conv_11', [1, 1], 'SAME')
        out = basic_tf.max_pool2d(out, [2, 2], 'maxpool_11', [2, 2], 'SAME')

        out = basic_tf.conv2d(out, 32, [3, 3], 'conv_12', [1, 1], 'SAME')
        out = basic_tf.max_pool2d(out, [2, 2], 'maxpool_12', [2, 2], 'SAME')

        out = basic_tf.conv2d(out, 64, [3, 3], 'conv_13', [1, 1], 'SAME')
        out = basic_tf.max_pool2d(out, [2, 2], 'maxpool_13', [2, 2], 'SAME')

        out = basic_tf.conv2d(out, 128, [3, 3], 'conv_14', [1, 1], 'SAME')
        out = basic_tf.max_pool2d(out, [2, 2], 'maxpool_14', [2, 2], 'SAME')

        out = basic_tf.conv2d(out, 256, [3, 3], 'conv_15', [1, 1], 'SAME')
        out = basic_tf.max_pool2d(out, [2, 2], 'maxpool_15', [2, 2], 'SAME')

        out = basic_tf.conv2d(out, 512, [3, 3], 'conv_16', [1, 1], 'SAME')
        out = basic_tf.max_pool2d(out, [2, 2], 'maxpool_16', [2, 2], 'SAME')

        out = basic_tf.max_pool2d(out, [2, 2], 'maxpool_17', [2, 2], 'SAME')
    with tf.variable_scope('conv_unit2'):

        out1 = basic_tf.conv2d(out, 1024, [3, 3], 'conv_21', [1, 1], 'SAME')
        out1 = basic_tf.conv2d(out1, 512, [1, 1], 'conv_22', [1, 1], 'SAME')

    with tf.variable_scope('fully_connected_unit'):

        out2 = tf.reshape(out1, (int(out1._shape[0]), -1))  #b,8192
        out2 = basic_tf.fully_connected(out2, 4096, 'fc1')
        out2 = basic_tf.dropout(out2, is_training, 'dp1', 0.5)

        out2 = basic_tf.fully_connected(out2, 1024, 'fc2')
        out2 = basic_tf.dropout(out2, is_training, 'dp2', 0.5)

        out2 = basic_tf.fully_connected(
            out2, cell_size[0] * cell_size[1] * (class_num + box_num * 5),
            'fc3')

    with tf.variable_scope('output_unit'):
        n1 = cell_size[0] * cell_size[1] * num_class  #4*4*2=32
        n2 = n1 + cell_size[0] * cell_size[1] * box_num  #32+4*4*2=64

        class_pred = tf.reshape(
            out2[:, 0:n1],
            (-1, cell_size[0], cell_size[1], num_class))  #(b,4,4,2)
        scales = tf.reshape(
            out2[:,
                 n1:n2], (-1, cell_size[0], cell_size[1], box_num))  #(b,4,4,2)
        boxes = tf.reshape(
            out2[:, n2:],
            (-1, cell_size[0], cell_size[1], box_num * 4))  #(b,4,4,8)

        pred = tf.concat([class_pred, scales, boxes], 3)  #(b,4,4,12)

    return pred
Beispiel #4
0
def get_model_single_seg(point_cloud, is_training, bn_decay=None,is_tnet=False):
   
    b = point_cloud.get_shape()[0].value
    n = point_cloud.get_shape()[1].value
    end_points = {}
    l0_xyz = tf.slice(point_cloud, [0,0,0], [-1,-1,3])
    l0_points = point_cloud

    if is_tnet:
        tnet_spec={'mlp':[64,128,1024], 'is_training':is_training, 'bn_decay':bn_decay}
    else:
        tnet_spec=None

    end_points['l0_xyz'] =l0_xyz 

    #Abstraction layers 
    l1_xyz, l1_points,_ = pointnet_AB_module(l0_xyz, l0_points, m=51200, r=0.4, ns=64, mlp=[32,64,128], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer1',tnet_spec=tnet_spec)    
    l2_xyz, l2_points,_= pointnet_AB_module(l1_xyz, l1_points,m=12800, r=1.6, ns=128, mlp=[64,128,256], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer2',tnet_spec=tnet_spec)
    l3_xyz, l3_points,_ = pointnet_AB_module(l2_xyz, l2_points, m=5120, r=3.2, ns=64, mlp=[256,256,512], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer3',tnet_spec=tnet_spec)    
    l4_xyz, l4_points,_= pointnet_AB_module( l3_xyz, l3_points,m=2048, r=6.4, ns=64, mlp=[256,512,512], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer4',tnet_spec=tnet_spec)
    l5_xyz, l5_points,_ = pointnet_AB_module(l4_xyz, l4_points, m=1024, r=19.2, ns=64, mlp=[512,1024,1024], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer5',tnet_spec=tnet_spec)    
    l6_xyz, l6_points,_= pointnet_AB_module(l5_xyz, l5_points,m=512, r=38.4, ns=64, mlp=[1024,1024,2048], mlp2=None, group_all=False, is_training=is_training, bn_decay=bn_decay, scope='layer6',tnet_spec=tnet_spec)
    l7_xyz, l7_points,_ = pointnet_AB_module(l6_xyz, l6_points, m=None, r=None, ns=None, mlp=[2048,2048,4096], mlp2=None, group_all=True, is_training=is_training, bn_decay=bn_decay, scope='layer7')
      
    # Fully connected layers
    netc = tf.reshape(l7_points, [b,-1])   
    netc = basic_tf.fully_connected(netc,2048, bn=True, is_training=is_training, scope='fc1', bn_decay=bn_decay)
    netc = basic_tf.dropout(netc, keep_prob=0.8, is_training=is_training, scope='dp1')
    netc = basic_tf.fully_connected(netc,1024, bn=True, is_training=is_training, scope='fc2', bn_decay=bn_decay)
    netc = basic_tf.dropout(netc, keep_prob=0.8, is_training=is_training, scope='dp2')
    netc = basic_tf.fully_connected(netc, 512, bn=True, is_training=is_training, scope='fc3', bn_decay=bn_decay)
    netc = basic_tf.dropout(netc, keep_prob=0.5, is_training=is_training, scope='dp3')
    netc = basic_tf.fully_connected(netc, 128, bn=True, is_training=is_training, scope='fc4', bn_decay=bn_decay)
    netc = basic_tf.dropout(netc, keep_prob=0.5, is_training=is_training, scope='dp4')
    netc = basic_tf.fully_connected(netc, 40, activation_fn=None, scope='fc5')


    # Feature Propagation layers&fully connected layers for segmentation
    l6_points = pointnet_fp_module(l6_xyz, l7_xyz, l6_points, l7_points, [2048,2048,1024], is_training, bn_decay, scope='fa_layer1') 
    l5_points = pointnet_fp_module(l5_xyz, l6_xyz, l5_points, l6_points, [1024,1024], is_training, bn_decay, scope='fa_layer2')
    l4_points = pointnet_fp_module(l4_xyz, l5_xyz, l4_points, l5_points, [1024,512], is_training, bn_decay, scope='fa_layer3') 
    l3_points = pointnet_fp_module(l3_xyz, l4_xyz, l3_points, l4_points, [512,512], is_training, bn_decay, scope='fa_layer4')
    l2_points = pointnet_fp_module(l2_xyz, l3_xyz, l2_points, l3_points, [512,256], is_training, bn_decay, scope='fa_layer5') 
    l1_points = pointnet_fp_module(l1_xyz, l2_xyz, l1_points, l2_points, [256,128], is_training, bn_decay, scope='fa_layer6')
    l0_points = pointnet_fp_module(l0_xyz, l1_xyz, l0_points, l1_points, [128,128,128], is_training, bn_decay, scope='fa_layer7') #(32,102400,128)
   
    net = basic_tf.conv1d(l0_points, 128, 1, padding='VALID', bn=True, is_training=is_training, scope='fcs1', bn_decay=bn_decay)
    end_points['feats'] = net 
    net = basic_tf.dropout(net, keep_prob=0.5, is_training=is_training, scope='dps1')
    net = basic_tf.conv1d(net, 50, 1, padding='VALID', activation_fn=None, scope='fcs2')


    return netc,net,end_points
Beispiel #5
0
def get_model_multi_seg(point_cloud, is_training, bn_decay=None):
    
    b = point_cloud.get_shape()[0].value
    n = point_cloud.get_shape()[1].value
    c=point_cloud.get_shape()[2].value
    end_points = {}

    l0_points = point_cloud    
    if c>3:
        l0_xyz = tf.slice(point_cloud,[0,0,0],[-1,-1,3])
    else:
        l0_xyz = point_cloud
   

     #Abstraction layers
    l1_xyz, l1_points = pointnet_AB_module_msg(l0_xyz, l0_points, 51200, [0.2,0.4,0.8], [32,64,96], [[32,32,64], [64,64,128], [64,96,128]], is_training, bn_decay, scope='layer1')
    l2_xyz, l2_points = pointnet_AB_module_msg(l1_xyz, l1_points, 12800, [0.8,1.6,3.2], [128,128,256], [[64,64,128], [128,128,256], [128,128,256]], is_training, bn_decay, scope='layer2')
    l3_xyz, l3_points = pointnet_AB_module_msg(l2_xyz, l2_points, 5120, [1.6,3.2,6.4], [64,128,128], [[128,128,256], [256,256,512], [512,512,1024]], is_training, bn_decay, scope='layer3')
    l4_xyz, l4_points = pointnet_AB_module_msg(l3_xyz, l3_points,2048, [3.2,6.4,12.8], [128,128,256], [[256,256,512], [512,512,1024], [1024,1024,2048]], is_training, bn_decay, scope='layer4')
    l5_xyz, l5_points = pointnet_AB_module_msg(l4_xyz, l4_points,1024, [12.8,25.6], [64,128], [[512,1024,1024], [1024,2048,2048]], is_training, bn_decay, scope='layer5')
    l6_xyz, l6_points = pointnet_AB_module_msg(l5_xyz, l5_points,512, [25.6,51.2], [32,64], [[512,1024,1024], [1024,2048,2048]], is_training, bn_decay, scope='layer6')
    l7_xyz, l7_points, _ = pointnet_AB_module(l6_xyz, l6_points,m=None, r=None, ns=None, mlp=[2048,2048,4096], mlp2=None, group_all=True, is_training=is_training, bn_decay=bn_decay, scope='layer7')
  
    # Fully connected layers for classification
    netc = tf.reshape(l7_points, [b, -1])
    netc = basic_tf.fully_connected(netc,2048, bn=True, is_training=is_training, scope='fc1', bn_decay=bn_decay)
    netc = basic_tf.dropout(netc, keep_prob=0.8, is_training=is_training, scope='dp1')
    netc = basic_tf.fully_connected(netc, 1024, bn=True, is_training=is_training, scope='fc2', bn_decay=bn_decay)
    netc = basic_tf.dropout(netc, keep_prob=0.8, is_training=is_training, scope='dp2')
    netc = basic_tf.fully_connected(netc, 512, bn=True, is_training=is_training, scope='fc3', bn_decay=bn_decay)
    netc = basic_tf.dropout(netc, keep_prob=0.5, is_training=is_training, scope='dp3')
    netc = basic_tf.fully_connected(netc, 128, bn=True, is_training=is_training, scope='fc4', bn_decay=bn_decay)
    netc = basic_tf.dropout(netc, keep_prob=0.5, is_training=is_training, scope='dp4')
    netc = basic_tf.fully_connected(netc, 40, activation_fn=None, scope='fc5')

     # Feature Propagation layers&fully connected layers for segmentation
    l6_points = pointnet_fp_module(l6_xyz, l7_xyz, l6_points, l7_points, [2048,2048,1024], is_training, bn_decay, scope='fa_layer1') 
    l5_points = pointnet_fp_module(l5_xyz, l6_xyz, l5_points, l6_points, [1024,1024], is_training, bn_decay, scope='fa_layer2')
    l4_points = pointnet_fp_module(l4_xyz, l5_xyz, l4_points, l5_points, [1024,512], is_training, bn_decay, scope='fa_layer3') 
    l3_points = pointnet_fp_module(l3_xyz, l4_xyz, l3_points, l4_points, [512,512], is_training, bn_decay, scope='fa_layer4')
    l2_points = pointnet_fp_module(l2_xyz, l3_xyz, l2_points, l3_points, [512,256], is_training, bn_decay, scope='fa_layer5') 
    l1_points = pointnet_fp_module(l1_xyz, l2_xyz, l1_points, l2_points, [256,256], is_training, bn_decay, scope='fa_layer6')
    l0_points = pointnet_fp_module(l0_xyz, l1_xyz, l0_points, l1_points, [256,128,128], is_training, bn_decay, scope='fa_layer7') #(32,102400,128)
        
    net = basic_tf.conv1d(l0_points,128, 1, padding='VALID', bn=True, is_training=is_training, scope='fcs1', bn_decay=bn_decay)
    end_points['feats'] = net 
    net = basic_tf.dropout(net, keep_prob=0.5, is_training=is_training, scope='dps1')
    net = basic_tf.conv1d(net, 50, 1, padding='VALID', activation_fn=None, scope='fcs3')

    return netc,net,end_points
Beispiel #6
0
def basic_detectModel(img, is_training, bn_decay, num_class):  #512->4

    with tf.variable_scope('conv_unit1_G'):

        out = basic_tf.conv2d(img, 16, [3, 3], 'conv_11', [1, 1], 'SAME')
        out = basic_tf.max_pool2d(out, [2, 2], 'maxpool_11', [2, 2], 'SAME')

        out = basic_tf.conv2d(out, 32, [3, 3], 'conv_12', [1, 1], 'SAME')
        out = basic_tf.max_pool2d(out, [2, 2], 'maxpool_12', [2, 2], 'SAME')

        out = basic_tf.conv2d(out, 64, [3, 3], 'conv_13', [1, 1], 'SAME')
        out = basic_tf.max_pool2d(out, [2, 2], 'maxpool_13', [2, 2], 'SAME')

        out = basic_tf.conv2d(out, 128, [3, 3], 'conv_14', [1, 1], 'SAME')
        out = basic_tf.max_pool2d(out, [2, 2], 'maxpool_14', [2, 2], 'SAME')

        out = basic_tf.conv2d(out, 256, [3, 3], 'conv_15', [1, 1], 'SAME')
        out = basic_tf.max_pool2d(out, [2, 2], 'maxpool_15', [2, 2], 'SAME')

        out = basic_tf.conv2d(out, 512, [3, 3], 'conv_16', [1, 1], 'SAME')
        out = basic_tf.max_pool2d(out, [2, 2], 'maxpool_16', [2, 2], 'SAME')

        out = basic_tf.max_pool2d(out, [2, 2], 'maxpool_17', [2, 2], 'SAME')
    with tf.variable_scope('conv_unit2'):

        out1 = basic_tf.conv2d(out, 1024, [3, 3], 'conv_21', [1, 1], 'SAME')
        out1 = basic_tf.conv2d(out1, 512, [1, 1], 'conv_22', [1, 1], 'SAME')
        out1 = basic_tf.avg_pool2d(out1, [2, 2], 'pre_avepool', [2, 2], 'SAME')
    with tf.variable_scope('fully_connected_unit_G'):

        out2 = tf.reshape(out1, (int(out1._shape[0]), -1))  #b,8192
        #out2 = basic_tf.fully_connected(out2,4096,'fc1')
        #out2 = basic_tf.dropout(out2,is_training,'dp1',0.5)

        out2 = basic_tf.fully_connected(out2, 1024, 'fc2')
        out2 = basic_tf.dropout(out2, is_training, 'dp2', 0.5)

        out2 = basic_tf.fully_connected(out2, 128, 'fc3')
        out2 = basic_tf.dropout(out2, is_training, 'dp3', 0.5)

    with tf.variable_scope('output_unit_G'):

        pred = basic_tf.fully_connected(out2, (num_class + 4),
                                        'fc4',
                                        activation_fn=None)

    return pred
Beispiel #7
0
def brute_classify(img, num_class, is_training, bn_decay):  #512->4

    with tf.variable_scope('conv_unit1'):

        out = basic_tf.conv2d(img, 16, [3, 3], 'conv_11', [1, 1], 'SAME')
        out = basic_tf.max_pool2d(out, [2, 2], 'maxpool_11', [2, 2], 'SAME')

        out = basic_tf.conv2d(out, 32, [3, 3], 'conv_12', [1, 1], 'SAME')
        out = basic_tf.max_pool2d(out, [2, 2], 'maxpool_12', [2, 2], 'SAME')

        out = basic_tf.conv2d(out, 64, [3, 3], 'conv_13', [1, 1], 'SAME')
        out = basic_tf.max_pool2d(out, [2, 2], 'maxpool_13', [2, 2], 'SAME')

        out = basic_tf.conv2d(out, 128, [3, 3], 'conv_14', [1, 1], 'SAME')
        out = basic_tf.max_pool2d(out, [2, 2], 'maxpool_14', [2, 2], 'SAME')

        out = basic_tf.conv2d(out, 256, [3, 3], 'conv_15', [1, 1], 'SAME')
        out = basic_tf.max_pool2d(out, [2, 2], 'maxpool_15', [2, 2], 'SAME')

        out = basic_tf.conv2d(out, 512, [3, 3], 'conv_16', [1, 1], 'SAME')
        out = basic_tf.max_pool2d(out, [2, 2], 'maxpool_16', [2, 2], 'SAME')

        out = basic_tf.max_pool2d(out, [2, 2], 'maxpool_17', [2, 2], 'SAME')
    with tf.variable_scope('conv_unit2'):

        out1 = basic_tf.conv2d(out, 1024, [3, 3], 'conv_21', [1, 1], 'SAME')
        out1 = basic_tf.conv2d(out1, 512, [1, 1], 'conv_22', [1, 1], 'SAME')
        out1 = basic_tf.avg_pool2d(out1, [2, 2], 'pre_avepool', [2, 2], 'SAME')

    with tf.variable_scope('fully_connected_unit'):

        out2 = tf.reshape(out1, (int(out1._shape[0]), -1))  #b,4096
        out2 = basic_tf.fully_connected(out2, 1024, 'fc1')
        out2 = basic_tf.dropout(out2, is_training, 'dp1', 0.5)

        out2 = basic_tf.fully_connected(out2, 128, 'fc2')
        out2 = basic_tf.dropout(out2, is_training, 'dp2', 0.5)

        pred = basic_tf.fully_connected(out2, num_class, 'fc3')
    print(pred)
    return pred
Beispiel #8
0
def color_net(rgb, is_training, bn_decay=None):

    with tf.variable_scope('input_layer'):
        h = rgb.get_shape()[1].value
        w = rgb.get_shape()[2].value
        b = rgb.get_shape()[0].value

        og = [h, w]
        end_data = {}
        end_data['rgb_data'] = rgb
        #end_data['srgb_data']=srgb    #both of them are been normalized
        out1 = basic_tf.conv2d(rgb, 96, [1, 1], 'input_conv', [1, 1], 'SAME')
        out1 = basic_tf.max_pool2d(out1, [2, 2], 'input_pool', [1, 1], 'SAME')

    with tf.variable_scope('intermidate_layer'):
        for i, kernels in enumerate(list_of_kernel):
            mlps = list_of_mlplist[i]
            out1 = bm.ssc_color_info_abstraction(out1,
                                                 mlps,
                                                 is_training=is_training,
                                                 bn_decay=bn_decay,
                                                 scope='ssc_section_%d' % (i),
                                                 kernel_size=kernels,
                                                 bn=True)
            if i == 0:
                hyper_colume = out1
            else:
                hyper_colume = tf.concat([hyper_colume, out1], -1)

        hyper_colume = basic_tf.avg_pool2d(hyper_colume, [2, 2],
                                           'medium_avepool', [1, 1], 'SAME')
        c = hyper_colume.get_shape()[-1].value
        print(hyper_colume.shape)
        hyper_colume = tf.reshape(hyper_colume, (b * h * w, c))

    with tf.variable_scope('output_layer'):

        out = basic_tf.fully_connected(hyper_colume,
                                       256,
                                       bn=True,
                                       is_training=is_training,
                                       scope='fc2',
                                       bn_decay=bn_decay)
        out = basic_tf.dropout(out,
                               keep_prob=0.5,
                               is_training=is_training,
                               scope='dp2')
        out = basic_tf.fully_connected(out,
                                       64,
                                       bn=True,
                                       is_training=is_training,
                                       scope='fc3',
                                       bn_decay=bn_decay)
        out = basic_tf.dropout(out,
                               keep_prob=0.5,
                               is_training=is_training,
                               scope='dp3')
        out = basic_tf.fully_connected(out,
                                       3,
                                       bn=True,
                                       is_training=is_training,
                                       scope='fc4',
                                       bn_decay=bn_decay)

        pred = tf.reshape(out, (b, h, w, 3))

    return pred, end_data