Esempio n. 1
0
    rnd.shuffle(TIMIT_lst)

    p = Augmentor.Pipeline()
    p.random_distortion(probability=1,
                        grid_width=4,
                        grid_height=4,
                        magnitude=8)
    p.flip_left_right(probability=0.5)
    # p.flip_top_bottom(probability=0.5)
    # p.rotate90(probability=0.5)
    # p.rotate270(probability=0.5)

    dp = FaceScrubDataProvider(
        top_dir + '/facescrub_128x128',
        min_cluster_count=1,
        max_cluster_count=5,
        target_img_size=(128, 128),
        min_element_count_per_cluster=2,
        additional_augmentor=lambda x: p.sample_with_array(x))
    dp.use_augmentation_for_test_data = False
    dp.use_augmentation_for_validation_data = False
    en = CnnEmbedding(output_size=256,
                      cnn_layers_per_block=1,
                      block_feature_counts=[32, 64, 128],
                      fc_layer_feature_counts=[256],
                      hidden_activation=LeakyReLU(),
                      final_activation=LeakyReLU(),
                      batch_norm_for_init_layer=False,
                      batch_norm_after_activation=True,
                      batch_norm_for_final_layer=True,
                      dropout_init=0.25,
Esempio n. 2
0
                        magnitude=8)
    p.flip_left_right(probability=0.5)
    # p.flip_top_bottom(probability=0.5)
    # p.rotate90(probability=0.5)
    # p.rotate270(probability=0.5)

    classes = list(range(530))
    rand = Random()
    rand.seed(1729)
    rand.shuffle(classes)

    dp = FaceScrubDataProvider(
        top_dir + '/facescrub_128x128',
        min_cluster_count=1,
        max_cluster_count=5,
        target_img_size=(128, 128),
        min_element_count_per_cluster=2,
        additional_augmentor=lambda x: p.sample_with_array(x),
        train_classes=classes[0:424],
        validate_classes=classes[424:(424 + 53)],
        test_classes=classes[(424 + 53):(424 + 53 + 53)])
    dp.use_augmentation_for_test_data = False
    dp.use_augmentation_for_validation_data = False

    def get_cnn(dataprovider=None):
        if dataprovider is None:
            dataprovider = dp

        en = CnnEmbedding(output_size=256,
                          cnn_layers_per_block=1,
                          block_feature_counts=[32, 64, 128],
                          fc_layer_feature_counts=[256],
if __name__ == '__main__':

    # Difference to test_cluster_nn_try00.py: No embedding is used and the network always returns that 10 clusters were
    # found, but some of them may be empty

    from sys import platform

    from impl.data.image.facescrub_data_provider import FaceScrubDataProvider
    from impl.nn.base.embedding_nn.cnn_embedding import CnnEmbedding

    is_linux = platform == "linux" or platform == "linux2"
    top_dir = "/cluster/home/meierbe8/data/MT/" if is_linux else "G:/tmp/"
    ds_dir = "./" if is_linux else "../"

    dp = FaceScrubDataProvider(top_dir + '/test/facescrub_128x128',
                               min_element_count_per_cluster=4,
                               min_cluster_count=1,
                               max_cluster_count=10)
    en = CnnEmbedding(output_size=256,
                      cnn_layers_per_block=1,
                      block_feature_counts=[64, 128, 256],
                      fc_layer_feature_counts=[256],
                      hidden_activation=LeakyReLU(),
                      final_activation=LeakyReLU(),
                      batch_norm_for_init_layer=False,
                      batch_norm_after_activation=True,
                      batch_norm_for_final_layer=True)

    c_nn = ClusterNNTry00_V51(dp,
                              40,
                              en,
                              lstm_layers=7,