コード例 #1
0
def create_and_save_data_images(path, filename):
    data_generator = gen_data.DataGen(
        data_path=
        '/home/johannes/Documents/master_data/jkummert_master_thesis/rwth/rwth-phoenix-full-corpus-images',
        corpus_path=
        '/home/johannes/Documents/master_data/jkummert_master_thesis/rwth/rwth-phoenix-full-20120323.corpus'
    )
    dict = data_generator.create_dictionary()
    np.save(path + '/' + '' + filename + '_' + 'dict.npy', dict)
    e_input, d_input, d_output = data_generator.read_path_images()
    np.save(path + '/' + '' + filename + '_' + 'e_input.npy', e_input)
    np.save(path + '/' + '' + filename + '_' + 'd_input.npy', d_input)
    np.save(path + '/' + '' + filename + '_' + 'd_output.npy', d_output)
コード例 #2
0
def evaluate_image_model(model, arch, op, latent_dim, num):
    data_generator = gen_data.DataGen(
        data_path=
        "/home/johannes/Documents/master_data/jkummert_master_thesis/rwth/rwth-phoenix-full-corpus-images/",
        corpus_path=
        "/home/johannes/Documents/master_data/jkummert_master_thesis/rwth/rwth-phoenix-full-20120323.corpus"
    )
    data_generator.load_from_file(sys.argv[2], sys.argv[3])
    net_eval = eval_net.NetEval(model,
                                data_generator.dict,
                                load_model=True,
                                latent_dim=latent_dim,
                                mix=("merge" in arch))

    acc = 0
    for i in range(num):
        try:
            if arch == "std":
                encoder_input_data, decoder_input_data, decoder_target_data = data_generator.get_random_sample(
                )
                encoder_input_data = np.expand_dims(encoder_input_data, 0)
            elif arch == "std_conv" or arch == "deep_conv" or arch == "vgg_19_retrain_False" or arch == "vgg_19_retrain_True":
                if not op:
                    encoder_input_data, decoder_input_data, decoder_target_data = data_generator.get_random_image_sample(
                    )
                else:
                    encoder_input_data, decoder_input_data, decoder_target_data = data_generator.get_random_image_op_sample(
                    )
                encoder_input_data = np.expand_dims(encoder_input_data, 0)
            elif arch == "std_conv_merge" or arch == "deep_conv_merge":
                if not op:
                    encoder_input_data, decoder_input_data, decoder_target_data, encoder_input_op = data_generator.get_random_mix_sample(
                    )
                else:
                    encoder_input_data, decoder_input_data, decoder_target_data, encoder_input_op = data_generator.get_random_mix_op_sample(
                    )
                if not is_same_input_size(encoder_input_data,
                                          encoder_input_op):
                    continue
                encoder_input_data = [
                    np.expand_dims(encoder_input_data, 0),
                    np.expand_dims(encoder_input_op, 0)
                ]

            acc += net_eval.test_edit_distance(
                encoder_input_data, np.expand_dims(decoder_target_data, 0))
        except ValueError or OSError:
            continue
    return acc / num
コード例 #3
0
    def __init__(self,
                 model_path,
                 data_location,
                 data_name,
                 latent_dim=1024,
                 arch="std"):
        self.net_generator = gen_net.NetGen()
        if arch == "std":
            self.model, self.model_name = self.net_generator.get_std_net(
                latent_dim)
        elif arch == "std_conv":
            self.model, self.model_name = self.net_generator.get_std_conv_net(
                latent_dim)
        elif arch == "deep_conv":
            self.model, self.model_name = self.net_generator.get_deep_conv_net(
                latent_dim)
        elif arch == "std_conv_merge":
            self.model, self.model_name = self.net_generator.get_std_conv_merge_net(
                latent_dim)
        elif arch == "deep_conv_merge":
            self.model, self.model_name = self.net_generator.get_deep_conv_merge_net(
                latent_dim)
        elif arch == "vgg_19_true":
            self.model, self.model_name = self.net_generator.get_vgg_19_image_net(
                latent_dim, trainable=True)
        elif arch == "vgg_19_false":
            self.model, self.model_name = self.net_generator.get_vgg_19_image_net(
                latent_dim, trainable=False)

        self.data_generator = gen_data.DataGen(
            data_path=
            "/home/johannes/Documents/master_data/jkummert_master_thesis/rwth/rwth-phoenix-full-corpus-images/",
            corpus_path=
            "/home/johannes/Documents/master_data/jkummert_master_thesis/rwth/rwth-phoenix-full-20120323.corpus"
        )
        self.data_generator.load_from_file(data_location, data_name)
        #self.data_generator.compute_pca_of_image_set()
        #self.data_generator.load_from_file(data_location, data_name)
        #self.data_generator.split_testset(0.1)
        self.path = model_path
コード例 #4
0
def test_data_generation():
    data_generator = gen_data.DataGen(
        data_path=
        '/home/johannes/Documents/master_data/jkummert_master_thesis/rwth/rwth-phoenix-full-corpus-images',
        corpus_path=
        '/home/johannes/Documents/master_data/jkummert_master_thesis/rwth/rwth-phoenix-full-20120323.corpus'
    )
    e_input, d_input, d_output = data_generator.read_path()
    print("Encoder Input")
    print(e_input[0].shape)
    print(e_input[0])
    print("Decoder Input")
    print(d_input[0].shape)
    print(d_input[0])
    print("Decoder Output")
    print(d_output[0].shape)
    print(d_output[0])
    e_input_b, d_input_b, d_output_b = data_generator.create_batch(50)
    print("Encoder Input Batch")
    print(e_input_b.shape)
    print("Decoder Input")
    print(d_input_b.shape)
    print("Decoder Output")
    print(d_output_b.shape)