def loadOfficialTest(args, restoreModel=None, restoreModelPath=None): #config = Attention_LapConfig(load=True, args) config = Attention_GPUConfig(load=True, args=args) testReader = TestProcessor(qnFile=config.testOfficialDevQns, imgFile=config.testOfficialImgFeatures, config=config) if args.att == 'qn': print('Attention over question and image model') model = QnAttentionModel(config) elif args.att == 'im': print('Attention over image model') model = ImageAttentionModel(config) if restoreModel is None: model.loadTrainedModel(config.restoreModel, config.restoreModelPath) else: model.loadTrainedModel(restoreModel, restoreModelPath) if restoreModelPath is None: testOfficialResultFile = config.testOfficialResultFile else: testOfficialResultFile = '{}AttSubmission.json'.format(restoreModelPath) model.runTest(testReader, testOfficialResultFile) testReader.destruct() print('Official test complete') return model
def runValTest(args): #Val set's split -- test print('Running Val Test') config = Attention_LapConfig(load=True, args=args) valTestReader = TestProcessor(qnFile=config.valTestQns, imgFile=config.valImgFile, config=config) #valTestReader = TrainProcessors(config.testAnnotFile, # config.rawQnValTestFile, # config.valImgFile, # config, # is_training=False) if args.att == 'qn': print('Attention over question and image model') model = QnAttentionModel(config) elif args.att == 'im': print('Attention over image model') model = ImageAttentionModel(config) model.loadTrainedModel(config.restoreQnImAttModel, config.restoreQnImAttModelPath) model.runTest(valTestReader, 'testResFile.json') model.destruct() valTestReader.destruct()