Esempio n. 1
0
def main(config, process):

    # load all data
    print('Loading data')
    num_words, embedding_matrix, train_data, valid_data, test_data = loadData(
        config)

    assert config['model'] == 'baseline'
    print('config:')
    print(json.dumps(config, indent=2))

    init(config['stage1'])
    if process == 'train':
        train(config, num_words, embedding_matrix, train_data, valid_data)
    if process == 'test':
        test(config, num_words, embedding_matrix, test_data)
    if process == 'eval':
        evaluate(config)

    return True


if __name__ == "__main__":

    try:
        params = json.load(open('config.json'))
    except FileNotFoundError:
        params = create_config()

    main(params)
Esempio n. 2
0
    isprune = True

    # Load VGG16 model for extracting features for images in data. Save the
    # extracted features
    base_model = VGG16(weights='imagenet', include_top=True)
    model = Model(input=base_model.input,
                  output=base_model.get_layer('fc2').output)
    model.summary()

    print('loaded VGG model...')
    for proc in process:
        img_feats, storynoimg = main_func(datadir, proc, model, isprune)

        with open(datadir + proc + '/' + proc + '_imgfeat.json', 'w') as JITE:
            json.dump(img_feats, JITE)
        with open(datadir + proc + '/' + proc + '_missingstory.json',
                  'w') as JITE:
            json.dump(storynoimg, JITE)
    return True


if __name__ == '__main__':
    #organize "Story in sequence" of VIST dataset as story x sequence

    try:
        config = json.load(open('config.json'))
    except FileNotFoundError:
        config = configAll.create_config()

    main(config)