Example #1
0
def Main():
    #matplotlib.use('Agg')
    if len(sys.argv) > 1 and os.path.isfile(sys.argv[1]):
        extension = os.path.splitext(sys.argv[1])[1]
        fig = plt.figure()
        if extension == '.ply':

            #A = np.expand_dims(A,axis=0)
            V, A = ply2graph(sys.argv[1],K)
            V = np.expand_dims(np.array(V),axis=0)
            print(V.shape)
            #A = np.expand_dims(np.transpose(np.array(A),axes=(1,0,2)),axis=0)
            A = np.expand_dims(np.array(A),axis=0)
            print(A.shape)
            #eng = matlab.engine.start_matlab()
            #eng.addpath(os.path.abspath(os.path.join(os.path.dirname(__file__),'../util/pooling/graclus1.2/matlab/')))
            #pooler = GraclusPoolingPyramid(len(POOL_RATIOS), GeometricAdjacencyCompander, POOL_RATIOS)#,eng)
            #pooler = SpectralClusteringPoolingPyramid(len(POOL_RATIOS), MemoryAdjacencyCompander, POOL_RATIOS)
            pooler = LloydPoolingPyramid(len(POOL_RATIOS), SphericalAdjacencyCompander, POOL_RATIOS)
            #pooler = SBFSStrideAdjacencyPyramid(len(POOL_RATIOS), GeometricAdjacencyCompander, STRIDE, POOL_RATIOS)
            #draw3DGraph(V.sum(axis=0), A.sum(axis=(0, 2)), V.shape[1], '141', fig)

        #plt.show()
        Plist = pooler.makeP(A.sum(axis=0),V.sum(axis=0),THETA,PHI)
        #print(Plist[0].shape)
        Avar = tf.placeholder(tf.float32, shape=(None, None, None, None))
        Vvar = tf.placeholder(tf.float32, shape=(None, None, None))
        Pvar = tf.placeholder(tf.float32, shape=(None, None, None))
        Vout,Aout = make_graph_pooling_layer(Vvar,Avar,Pvar)
        #vshape = V.shape
        #V = tf.constant(V,dtype=tf.float32,shape=vshape)
        #A = tf.constant(A,dtype=tf.float32,shape=A.shape)
        #Vout,Aout,W = make_graph_embed_pooling(V, A, no_vertices=111)
        #Vrev,Arev = make_graph_unpooling_layer(Vvar,Avar,Pvar)

        init = tf.initialize_all_variables()
        with tf.Session() as sess:
            sess.run(init)
            for i in range(2,2+len(POOL_RATIOS)):
                subplotId = '16' + str(i)
                [V,A] = sess.run([Vout,Aout],feed_dict={Vvar: V, Avar: A, Pvar: np.expand_dims(Plist[i-2],axis=0)})
                print(V.shape)
                if extension == '.ply':
                    draw3DGraph(V.sum(axis=0),A.sum(axis=(0,2)),Plist[i - 2].shape[1],subplotId,fig)

            #fig2 = plt.figure(2)
            #subplotId = '421'
            #draw3DGraph(V.sum(axis=0), A.sum(axis=(0, 2)), A.shape[1], subplotId, fig2)
            #for i in range(2,2 + len(POOL_RATIOS)):
            #    subplotId = '42' + str(i)
            #    print(V.shape)
            #    [V, A] = sess.run([Vrev, Arev], feed_dict={Vvar: V, Avar: A, Pvar: np.expand_dims(Plist[len(POOL_RATIOS) - (i - 2) - 1], axis=0)})
            #    draw3DGraph(V.sum(axis=0), A.sum(axis=(0, 2)), Plist[len(POOL_RATIOS) - (i - 2) - 1].shape[1], subplotId, fig2)
        plt.show()

    else:
        print('Could not find path LOL!')
Example #2
0
def processFile(filename):
    V, A = ply2graph(filename, K)
    V = np.expand_dims(np.array(V), axis=0)
    A = np.expand_dims(np.array(A), axis=0)  # BxNxLxN?
    print(A.shape)
    pooler = LloydPoolingPyramid(len(POOL_RATIOS), SphericalAdjacencyCompander,
                                 POOL_RATIOS)
    Plist = pooler.makeP(A.sum(axis=0), V.sum(axis=0), THETA, PHI)
    for i in range(len(Plist)):
        Plist[i] = np.expand_dims(np.expand_dims(Plist[i], axis=0), axis=0)
    return V, A, Plist
Example #3
0
def processFile(filename):
    V, A = ply2graph(filename, K)
    V = np.expand_dims(np.array(V), axis=0)
    A = np.expand_dims(np.transpose(np.array(A), axes=(1, 0, 2)),
                       axis=0)  # BxNxLxN?
    pooler = LloydPoolingPyramid(len(POOL_RATIOS), SphericalAdjacencyCompander,
                                 POOL_RATIOS)
    P = np.expand_dims(np.expand_dims(np.transpose(
        pooler.makeP(
            np.transpose(A, axes=(0, 2, 1, 3)).sum(axis=0), V.sum(axis=0),
            THETA, PHI)[0]),
                                      axis=0),
                       axis=0)
    return V, A, P