def saveFVs(QuadDir,NumberofFrame,gmm,nbc,halfWindows):
    savefilename = "{}FVS/FVsnbc_{}_halfwin_{}.mat".format(QuadDir,str(nbc),str(halfWindows[-1])) 
#    if not os.path.isfile(savefilename):
    XX = []
    print "Saving Framwise FVS for ", QuadDir;
    for numFrame in range(1,NumberofFrame+1):
        filename = '{}desc{}.mat'.format(QuadDir,str(numFrame).zfill(5))
        Quads  = sio.loadmat(filename)['QuadDescriptors']
        XX.append(Quads)
    num = np.shape(XX)[0]
#    fvs = np.zeros((NumberofFrame,nbc*13))
    Allfvs = [np.zeros((NumberofFrame,nbc*13)) for k in range(len(halfWindows)) ]
#    del fvs
    print np.shape(Allfvs),' one ',np.shape(Allfvs[0])
    for numFrame in xrange(1,NumberofFrame+1):
        wincount = -1
        for halfwin in halfWindows:
            wincount+=1
            XXtemp = []
            for fnum in np.arange(max(0,numFrame-halfwin-1),min(numFrame+halfwin,NumberofFrame),1):
                Quads = XX[fnum]
                if np.shape(Quads)[0]>1:
                    XXtemp.extend(Quads)
            num = np.shape(XXtemp)[0]
            if num>0:
                Allfvs[wincount][numFrame-1,:] = mytools.fisher_vector(XXtemp, gmm)
    
    wincount = -1    
    for halfwin in halfWindows:
        wincount+=1
        savefilename = "{}FVS/FVsnbc_{}_halfwin_{}.mat".format(QuadDir,str(nbc),str(halfwin))
        fvs = Allfvs[wincount]
        sio.savemat(savefilename,mdict = {'fvs':fvs})
Beispiel #2
0
def saveFVs(QuadDir, NumberofFrame, gmm, nbc, halfWindows):
    savefilename = "{}FVS/FVsnbc_{}_halfwin_{}.mat".format(
        QuadDir, str(nbc), str(halfWindows[-1]))
    #    if not os.path.isfile(savefilename):
    XX = []
    print "Saving Framwise FVS for ", QuadDir
    for numFrame in range(1, NumberofFrame + 1):
        filename = '{}desc{}.mat'.format(QuadDir, str(numFrame).zfill(5))
        Quads = sio.loadmat(filename)['QuadDescriptors']
        XX.append(Quads)
    num = np.shape(XX)[0]
    #    fvs = np.zeros((NumberofFrame,nbc*13))
    Allfvs = [
        np.zeros((NumberofFrame, nbc * 13)) for k in range(len(halfWindows))
    ]
    #    del fvs
    print np.shape(Allfvs), ' one ', np.shape(Allfvs[0])
    for numFrame in xrange(1, NumberofFrame + 1):
        wincount = -1
        for halfwin in halfWindows:
            wincount += 1
            XXtemp = []
            for fnum in np.arange(max(0, numFrame - halfwin - 1),
                                  min(numFrame + halfwin, NumberofFrame), 1):
                Quads = XX[fnum]
                if np.shape(Quads)[0] > 1:
                    XXtemp.extend(Quads)
            num = np.shape(XXtemp)[0]
            if num > 0:
                Allfvs[wincount][numFrame - 1, :] = mytools.fisher_vector(
                    XXtemp, gmm)

    wincount = -1
    for halfwin in halfWindows:
        wincount += 1
        savefilename = "{}FVS/FVsnbc_{}_halfwin_{}.mat".format(
            QuadDir, str(nbc), str(halfwin))
        fvs = Allfvs[wincount]
        sio.savemat(savefilename, mdict={'fvs': fvs})