def loadOfficialTestSpecs(args, restoreModel, restoreModelPath, config=None): if config is None: config = CNNGPUConfig(load=True, args=args) testReader = TestProcessor(qnFile=config.testOfficialDevQns, imgPathsFile=config.testOfficialImgPaths, config=config) model = LSTMCNNModel(config) model.loadTrainedModel(restoreModel, restoreModelPath) filename = 'toSubmit{}.json'.format(restoreModelPath.split('/')[-2]) model.runTest(testReader, filename) model.destruct() return config
def loadOfficialTest(args): if args.config == 'CPU': config = CNNLapConfig(load=True, args=args) elif args.config == 'GPU': config = CNNGPUConfig(load=True, args=args) testReader = TestProcessor(qnFile=config.testOfficialDevQns, imgFile=config.testOfficialImgPaths, config=config) model = LSTMCNNModel(config) model.loadTrainedModel(config.restoreModel, config.restoreModelPath) model.runTest(testReader, config.testOfficialResultFile) model.destruct() testReader.destruct()
def loadOfficialTest(args, restoreModel=None, restoreModelPath=None): if args.config == 'CPU': config = CNNLapConfig(load=True, args=args) elif args.config == 'GPU': config = CNNGPUConfig(load=True, args=args) testReader = TestProcessor(qnFile=config.testOfficialDevQns, imgFile=config.testOfficialImgPaths, config=config) model = LSTMCNNModel(config) model.loadTrainedModel(restoreModel, restoreModelPath) model.runTest(testReader, '25AprLSTMCNNSubmission.json') model.destruct() testReader.destruct()
def runValTest(args): #Val set's split -- test print('Running Val Test') if args.config == 'CPU': config = CNNLapConfig(load=True, args=args) elif args.config == 'GPU': config = CNNGPUConfig(load=True, args=args) valTestReader = InputProcessor(config.testAnnotFile, config.rawQnValTestFile, config.valImgPaths, config, is_training=False) model = LSTMCNNModel(config) model.loadTrainedModel(config.restoreModel, config.restoreModelPath) model.runPredict(valTestReader, config.csvResults) model.destruct() valTestReader.destruct()
def runtrain(args): if args.config == 'CPU': config = CNNLapConfig(load=True, args=args) elif args.config == 'GPU': config = CNNGPUConfig(load=True, args=args) trainReader = InputProcessor(config.trainAnnotFile, config.rawQnTrain, config.trainImgPaths, config, is_training=True) valReader = InputProcessor(config.valAnnotFile, config.rawQnValTestFile, config.valImgPaths, config, is_training=False) model = LSTMCNNModel(config) model.construct() model.train(trainReader, valReader, config.logFile) model.destruct()