コード例 #1
0
def main():
    # Get input arguments
    wddOutputRoot = sys.argv[1]
    inputModelFile = sys.argv[2]
    resultFolder = sys.argv[3]
    
    print('Folder with unfiltered dances is "', wddOutputRoot)
    print('Input model file is "', inputModelFile)
    
    kM = kerasModel.KerasModel()
    model = kM.getModel()
    
    model.load_weights(inputModelFile)
    
    # Init Confusion Matrix
    CM = np.zeros((2,2))
    progress = 0
    # Traverse folder structure and build matrix for every single dance so that CNN can test it
    # Set the directory you want to start from
    rootDir = wddOutputRoot
    for dirName, subdirList, fileList in os.walk(rootDir):
        print(dirName)
        if 'orient.png' in fileList:
                image_list = []
                for fname in glob.glob(dirName + '/image*.png'):
                    if fname != 'orient.png':
                        im = scipy.misc.imread(fname)[:, :, 1]
                        image_list.append(im)
                image_array = np.asarray(image_list)
                pred = classify_dance(image_array, model, kM.get_image_count())
                CM = update_confusion_matrix(pred, CM, dirName, resultFolder)
                progress += 1
                print(progress)
    print(CM)
def main():
    validationFolder = sys.argv[1]
    inputModelFile = sys.argv[2]
    outputFolder = sys.argv[3]

    print('Validation folder is "', validationFolder)
    print('Input model file is "', inputModelFile)
    print('Output folder is "', outputFolder)

    kM = kerasModel.KerasModel()
    model = kM.getModel()

    model.load_weights(inputModelFile)

    # Init Confusion Matrix
    CM = np.zeros((2, 2))
    progress = 0
    # traverse folder structure and build matrix for every single dance so that CNN can test it
    # Set the directory you want to start from
    rootDir = validationFolder
    for dirName, subdirList, fileList in os.walk(rootDir):
        print("Found directory: %s" % dirName)
        if "gt.csv" in fileList:
            with open(dirName + "/gt.csv", "rt") as csvfile:
                spamReader = csv.reader(csvfile, delimiter=" ", quotechar="|")
                Y = 0
                for row in spamReader:
                    Y = row[0]
                if Y == "j":
                    Y = 1
                elif Y == "n":
                    Y = 0
                else:
                    Y = -1
                    continue
                image_list = []
                for fname in glob.glob(dirName + "/image*.png"):
                    im = scipy.misc.imread(fname)[:, :, 1]
                    image_list.append(im)
                image_array = np.asarray(image_list)
                pred = classify_dance(image_array, model, kM.get_image_count())
                CM = update_confusion_matrix(pred, CM, Y, dirName, outputFolder)
                progress += 1
                print(progress)
    print(CM)
コード例 #3
0
def main():
    # Get input arguments
    validationFolderRoot = sys.argv[1]
    inputModelFile = sys.argv[2]
    
    print('Validation folder root is "', validationFolderRoot)
    print('Input model file is "', inputModelFile)
    
    kM = kerasModel.KerasModel()
    model = kM.getModel()
    model.load_weights(inputModelFile)
    
    # Init Confusion Matrix
    CM = np.zeros((2,2))
    progress = 0
    # Traverse folder structure and build matrix for every single dance so that CNN can test it
    # Set the directory you want to start from
    rootDir = validationFolderRoot
    for dirName, subdirList, fileList in os.walk(rootDir):
        print('Found directory: %s' % dirName)
        if 'gt.csv' in fileList:
            with open(dirName+'/gt.csv', 'rt') as csvfile:
                spamReader = csv.reader(csvfile, delimiter=' ', quotechar='|')
                Y = 0
                for row in spamReader:
                    Y = row[0]
                if Y == 'j':
                    Y = 1
                elif Y == 'n':
                    Y = 0
                else:
                    Y = -1
                    continue
                image_list = []
                for fname in glob.glob(dirName + '/image*.png'):
                    im = scipy.misc.imread(fname)[:, :, 1]
                    image_list.append(im)
                image_array = np.asarray(image_list)
                pred = classify_dance(image_array, model, kM.get_image_count())
                CM = update_confusion_matrix(pred, CM, Y)
                progress += 1;
                print(progress)
        print(CM)