Exemple #1
0
    caption, qids, questions, answers = parseInputFile(params['inputFile'])
    idx = np.array(qids, dtype='int')
    #inputTestSel = data['testData'][0][idx]
    #targetTestSel = data['testData'][1][idx]
    imgids = qids
    #imgids = inputTestSel[:, 0, 0]
    inputTest = prep.combine(\
        prep.lookupQID(questions, data['questionDict'], maxlen), imgids)
    targetTest = prep.lookupAnsID(answers, data['ansDict'])
    questionTypeArray = data['questionTypeArray'][idx]

    print('Running models...')
    modelOutputs = ie.runAllModels(
                        inputTest, 
                        questionTypeArray, 
                        params['models'],
                        params['resultsFolder'],
                        params['dataset'],
                        params['dataFolder'])

    # Render
    if not os.path.exists(params['outputFolder']):
        os.makedirs(params['outputFolder'])
    if params['format'] == 'html':
        print('Rendering HTML...')
        pages = ir.renderHtml(
                    inputTest,
                    targetTest,
                    data['questionIdict'],
                    data['ansIdict'],
                    urlDict,
Exemple #2
0
        -k: Top K answers
        -dataset: DAQUAR/COCO-QA dataset
    """
    params = parseComparativeParams(sys.argv)

    print('Loading test data...')
    urlDict = loadImgUrl(params['dataset'], params['dataFolder'])
    data = it.loadDataset(params['dataFolder'])

    if len(params['models']) > 0:
        print('Running models...')
        singleModel = [params['models'][0]]
        modelOutputs = ie.runAllModels(
                        data['testData'][0], 
                        data['questionTypeArray'], 
                        singleModel, 
                        params['resultsFolder'],
                        params['dataset'],
                        params['dataFolder'])
    else:
        modelOutputs = None

    # Render
    print('Rendering HTML to %s' % params['outputFolder'])
    if not os.path.exists(params['outputFolder']):
        os.makedirs(params['outputFolder'])

    pages = renderHtml(
                data['testData'][0], 
                data['testData'][1], 
                data['questionIdict'],