示例#1
0
    question_generator = QuestionGenerationModel(datasets, logger,
                                                 hidden_units, dropout)
    question_generator.input_shape = image_embedding_dim

    # Calculate image features and store them if save is True
    obj_dir = os.path.join('data', dataset, 'obj')
    if not os.path.exists(obj_dir):
        os.makedirs(obj_dir)

    train_imagefeat_dict_name = os.path.join(obj_dir,
                                             'train_imagefeat_dict.pkl')
    test_imagefeat_dict_name = os.path.join(obj_dir, 'test_imagefeat_dict.pkl')
    dev_imagefeat_dict_name = os.path.join(obj_dir, 'dev_imagefeat_dict.pkl')

    if os.path.exists(test_imagefeat_dict_name):
        datasets.test_image_id_imagefeat_dict = load_obj(
            test_imagefeat_dict_name)
    datasets.load_test_data()

    # Set this variable to True if you want to save the image features
    save = False

    if save:
        save_obj(datasets.test_image_id_imagefeat_dict,
                 test_imagefeat_dict_name)
    if is_training == 'YES':

        if os.path.exists(train_imagefeat_dict_name):
            datasets.train_image_id_imagefeat_dict = load_obj(
                train_imagefeat_dict_name)

        # Validation part of pipeline is commented out to speedup training process