コード例 #1
0
def test_load_directory_data():

    invalid_directory_path = 'invalid_directory_path'
    valid_dummy_directory = resource_filename('EmoPy','tests/unittests/resources/dummy_data_directory')
    empty_dummy_directory = resource_filename('EmoPy','tests/unittests/resources/dummy_empty_data_directory')
    channels = 1

    # should raise error when receives an invalid directory path
    with pytest.raises(NotADirectoryError):
        DirectoryDataLoader(datapath=invalid_directory_path)

    # should raise error when tries to load empty directory
    data_loader = DirectoryDataLoader(datapath=empty_dummy_directory)
    with pytest.raises(AssertionError):
        data_loader.load_data()
コード例 #2
0
validation_split = 0.15
verbose = True
model_name = 'inception_v3'

target_dimensions = (128, 128)
target_dimensions2 = (490, 640)

#directory_path = r'C:\Users\localadmin\Desktop\final_proj\cohn-kanade-images2'
directory_path = r'D:\Degree\Final project\cohn-kanade-formated2'

data_loader = DirectoryDataLoader(datapath=directory_path,
                                  validation_split=validation_split,
                                  target_dimension=target_dimensions2,
                                  out_channels=3)
dataset = data_loader.load_data()

if verbose:
    dataset.print_data_details()

print('Creating training/testing data...')
train_images, train_labels = dataset.get_training_data()
train_gen = DataGenerator().fit(train_images, train_labels)
test_images, test_labels = dataset.get_test_data()
test_gen = DataGenerator().fit(test_images, test_labels)

print('Initializing neural network with InceptionV3 base model...')
model = TransferLearningNN(model_name=model_name,
                           emotion_map=dataset.get_emotion_index_map())

print('Training model...')