def main(args): #---set up path for training and test data (NUAA face liveness dataset)-------------- model_name = args.model learning_rate = args.lr epoch = args.epoch with open(path) as file: print("Reading from json ... ") data = json.load(file)[model_name] accuracy = data['accuracy'] model_file = data['file'] print("Reading input from the NUAA dataset ... ") readd = ReadData() clientdir = '/content/drive/MyDrive/NormalizedFace_NUAA/ClientNormalized/' imposterdir = '/content/drive/MyDrive/NormalizedFace_NUAA/ImposterNormalized/' client_train_normaized_file = '/content/drive/MyDrive/NormalizedFace_NUAA/client_train_normalized.txt' imposter_train_normaized_file = '/content/drive/MyDrive/NormalizedFace_NUAA/imposter_train_normalized.txt' client_test_normaized_file = '/content/drive/MyDrive/NormalizedFace_NUAA/client_test_normalized.txt' imposter_test_normaized_file = '/content/drive/MyDrive/NormalizedFace_NUAA/imposter_test_normalized.txt' #---------------read training, test data---------------- train_images, train_labels = readd.read_data(clientdir, imposterdir, client_train_normaized_file, imposter_train_normaized_file) test_images, test_labels = readd.read_data(clientdir, imposterdir, client_test_normaized_file, imposter_test_normaized_file) for i in range(0,1): #--pick one of the following models for face liveness detection--- if model_name =='CNN': print("Selected CNN") cnn = CNNModel() # simple CNN model for face liveness detection--- else: print("Selected Inception") cnn = InceptionV4Model() #Inception model for liveness detection if args.resume: print("Resuming from the best model") model = cnn.load_model(model_file)#to use pretrained model else: print("Starting from scratch by creating a new model") model = cnn.create_model(learning_rate) # create and train a new model print("Starting training ...") model = cnn.train_model(model, train_images,train_labels,test_images,test_labels, epoch, accuracy, model_file, model_name) test_loss, test_acc = cnn.evaluate(model, test_images, test_labels) print('iteration = ' + str(i) + ' ---------------------------------------------========') print("**************************************Done***************************************")