import argparse
import glob
import os
import sys

import numpy

from anna.datasets.supervised_data_loader import SupervisedDataLoaderCrossVal
from anna import util

import data_paths
from model import SupervisedModel


if __name__ == "__main__":
    parser = argparse.ArgumentParser(
        prog='ck_plus_single_checkpoint_evaluator',
        description='Script to evaluate the performance of a checkpoint \
                     on CK+.')
    parser.add_argument("-s", "--split", default='0',
                        help='Training split of CK+ to use. (0-9)')
    parser.add_argument("checkpoint_file",
                        help='Path to a single model checkpoint (.pkl file).')
    args = parser.parse_args()

    checkpoint_file = args.checkpoint_file
    fold = int(args.split)
    dataset_path = data_paths.ck_plus_data_path

    print 'Checkpoint: %s' % checkpoint_file
    print 'Testing on split %d\n' % fold

    # Load model
    model = SupervisedModel('evaluation', './')

    # Load dataset
    supervised_data_loader = SupervisedDataLoaderCrossVal(dataset_path)
    test_data_container = supervised_data_loader.load(mode='test', fold=fold)
    test_data_container.X = numpy.float32(test_data_container.X)
    test_data_container.X /= 255.0
    test_data_container.X *= 2.0

    # Construct evaluator
    preprocessor = [util.Normer3(filter_size=5, num_channels=1)]

    evaluator = util.Evaluator(model, test_data_container,
                               checkpoint_file, preprocessor)

    # For the inputted checkpoint, compute the overall test accuracy
    accuracies = []
    print 'Checkpoint: %s' % os.path.split(checkpoint_file)[1]
    evaluator.set_checkpoint(checkpoint_file)
    accuracy = evaluator.run()
    print 'Accuracy: %f\n' % accuracy

@@ -120,30 +120,25 @@
 isedData
-LoaderCrossVal
+Container
 %0Afrom an
@@ -153,16 +153,40 @@
 t util%0A%0A
+import data_fold_loader%0A
 import d
@@ -542,12 +542,11 @@
 p='T
-rain
+est
 ing 
@@ -775,20 +775,26 @@
 ile%0A    
-fold
+test_split
  = int(a
@@ -934,20 +934,26 @@
 %25d%5Cn' %25 
-fold
+test_split
 %0A%0A    # 
@@ -1039,179 +1039,430 @@
     
-supervised_data_loader = SupervisedDataLoaderCrossVal(dataset_path
+train_folds, val_fold, _ = data_fold_loader.load_fold_assignment(test_fold=test_split)%0A    X_val, y_val = data_fold_loader.load_folds(data_paths.ck_plus_data_path, %5Bval_fold%5D
 )%0A    
+X_
 test
-_data_container = supervised_data_loader.load(mode='test', fold=fold)%0A    test_data_container.X
+, y_test = data_fold_loader.load_folds(data_paths.ck_plus_data_path, %5Btest_split%5D)%0A    print X_val.shape, y_val.shape%0A    print X_test.shape, y_test.shape%0A%0A    X_val = numpy.float32(X_val)%0A    X_val /= 255.0%0A    X_val *= 2.0%0A%0A    X_test
  = n
@@ -1474,20 +1474,70 @@
 float32(
+X_
 test
+)%0A    X_test /= 255.0%0A    X_test *= 2.0%0A%0A    val
 _data_co
@@ -1547,35 +1547,34 @@
 iner
-.X)%0A    test_data_c
+ = SupervisedDataC
 ontainer
 .X /
@@ -1573,19 +1573,22 @@
 iner
-.X /= 255.0
+(X_val, y_val)
 %0A   
@@ -1611,17 +1611,50 @@
 iner
-.X *= 2.0
+ = SupervisedDataContainer(X_test, y_test)
 %0A%0A  
@@ -1743,24 +1743,158 @@
 ls=1)%5D%0A%0A    
+val_evaluator = util.Evaluator(model, val_data_container,%0A                                   checkpoint_file, preprocessor)%0A%0A    test_
 evaluator = 
@@ -1928,32 +1928,37 @@
 data_container,%0A
+     
                 
@@ -2063,41 +2063,288 @@
 all 
-test accuracy%0A    accuracies = %5B%5D
+val accuracy%0A    print 'Checkpoint: %25s' %25 os.path.split(checkpoint_file)%5B1%5D%0A    val_evaluator.set_checkpoint(checkpoint_file)%0A    val_accuracy = val_evaluator.run()%0A    print 'Val Accuracy: %25f%5Cn' %25 val_accuracy%0A%0A    # For the inputted checkpoint, cmopute the overall test accuracy
 %0A   
@@ -2348,33 +2348,32 @@
     print 'Check
-p
 oint: %25s' %25 os.p
@@ -2406,16 +2406,21 @@
 %5B1%5D%0A    
+test_
 evaluato
@@ -2457,16 +2457,21 @@
 le)%0A    
+test_
 accuracy
@@ -2473,16 +2473,21 @@
 uracy = 
+test_
 evaluato
@@ -2505,16 +2505,21 @@
  print '
+Test 
 Accuracy
@@ -2528,16 +2528,21 @@
 %25f%5Cn' %25 
+test_
 accuracy

Edit ck_plus_single_checkpoint_evaluator.py file.