def main():

    datapath = '../TestData/'
    predictionDir = '../Predictions/'
    if not os.path.isdir(predictionDir):
        os.mkdir(predictionDir)
    Single = True
    nbc = 128
    binhalfwins = [2, 3, 4]
    nbc = 128
    lenthresh = 10
    halfwins = [8, 17, 25]
    alpha = 3
    shiftstart = -4
    shiftend = -1
    fileList = os.listdir(datapath)
    siz = 1
    thresh = 0
    samplelist = [files for files in fileList if files.startswith("Sample")]

    for sample in samplelist:
        if Single:
            QuadDir = '{}{}/SpecificQuadDescriptors/'.format(datapath, sample)
        else:
            QuadDir = '{}{}/AllQuadDescriptors/'.format(datapath, sample)
        print 'saving classifction number for', sample
        smp = GestureSample(datapath, sample, training=False)
        Numberofframe = smp.data['numFrames']
        OutDir = '{}ClassifierOutputs/'.format(QuadDir)

        allBinaryLabels = np.zeros((1, Numberofframe))
        ss1 = 0
        for binhalfwin in binhalfwins:
            BinClfFile = BinClfFile = '{}binary_halfwin_{}.mat'.format(
                OutDir, str(binhalfwin))
            BinaryLabels = sio.loadmat(BinClfFile)['frame_label']
            allBinaryLabels += BinaryLabels
            ss1 += 1
        allprobs = np.zeros((20, Numberofframe))
        ss = 0
        for halfwin in halfwins:
            ss += 1
            inFile = '{}Classfication_nbc_{}_halfwin{}.mat'.format(
                OutDir, str(nbc), str(halfwin))
            probabilties = 1 - np.transpose(sio.loadmat(inFile)['frame_probs'])
            allprobs += probabilties
        (r, c) = np.shape(probabilties)
        M = np.zeros((r + 1, c))
        M[:20, :] = allprobs / ss
        #                        M[20,:] = BinaryLabels
        BinaryLabels = mytools.myfilter(allBinaryLabels / ss1, siz, thresh)
        #                        M[20,:] = binprob
        M[20, :] = BinaryLabels
        (p, D) = dpEM(M, alpha)
        (labels, starts, ends) = getLabels(p)
        FinalLabels = refineLabes(labels, starts, ends, M, lenthresh,
                                  Numberofframe, shiftstart, shiftend)

        tempfilename = '../Predictions/{}_prediction.csv'.format(sample)
        mytools.exportPredictions(FinalLabels, tempfilename)
def main():
        
    datapath = '../TestData/'
    predictionDir = '../Predictions/'
    if not os.path.isdir(predictionDir):
        os.mkdir(predictionDir)
    Single =True;
    nbc =128
    binhalfwins = [2,3,4];
    nbc =128
    lenthresh = 10
    halfwins = [8,17,25];
    alpha = 3
    shiftstart = -4
    shiftend = -1
    fileList = os.listdir(datapath)
    siz = 1;thresh = 0;
    samplelist=[files for files in fileList if files.startswith("Sample")]  

    for sample in samplelist:
        if Single:
            QuadDir = '{}{}/SpecificQuadDescriptors/'.format(datapath,sample)
        else:
            QuadDir = '{}{}/AllQuadDescriptors/'.format(datapath,sample)
        print 'saving classifction number for',sample
        smp=GestureSample(datapath,sample,training = False);
        Numberofframe = smp.data['numFrames'];
        OutDir = '{}ClassifierOutputs/'.format(QuadDir)

        allBinaryLabels = np.zeros((1,Numberofframe))
        ss1=0
        for binhalfwin in binhalfwins:
            BinClfFile = BinClfFile = '{}binary_halfwin_{}.mat'.format(OutDir,str(binhalfwin))
            BinaryLabels = sio.loadmat(BinClfFile)['frame_label']                        
            allBinaryLabels += BinaryLabels
            ss1+=1
        allprobs = np.zeros((20,Numberofframe))
        ss =0 
        for halfwin in halfwins: 
            ss+=1    
            inFile = '{}Classfication_nbc_{}_halfwin{}.mat'.format(OutDir,str(nbc),str(halfwin))
            probabilties = 1-np.transpose(sio.loadmat(inFile)['frame_probs'])
            allprobs += probabilties
        (r,c) = np.shape(probabilties);
        M = np.zeros((r+1,c));
        M[:20,:] = allprobs/ss
#                        M[20,:] = BinaryLabels
        BinaryLabels = mytools.myfilter(allBinaryLabels/ss1,siz,thresh)
#                        M[20,:] = binprob
        M[20,:] = BinaryLabels;
        (p,D) = dpEM(M,alpha)
        (labels,starts,ends) = getLabels(p)
        FinalLabels = refineLabes(labels,starts,ends,M,lenthresh,Numberofframe,shiftstart,shiftend)

        tempfilename  = '../Predictions/{}_prediction.csv'.format(sample)
        mytools.exportPredictions(FinalLabels,tempfilename)