) if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('--gpu', help='comma separated list of GPU(s) to use.') parser.add_argument('--data', help='ILSVRC dataset dir') parser.add_argument('--load', help='load model') parser.add_argument('-d', '--depth', help='resnet depth', type=int, default=50, choices=[50, 101]) parser.add_argument('--eval', action='store_true') args = parser.parse_args() DEPTH = args.depth if args.gpu: os.environ['CUDA_VISIBLE_DEVICES'] = args.gpu if args.eval: BATCH_SIZE = 128 # something that can run on one gpu ds = get_data('val') eval_on_ILSVRC12(Model(), get_model_loader(args.load), ds) sys.exit() logger.set_logger_dir( os.path.join('train_log', 'imagenet-resnet-se-d' + str(DEPTH))) config = get_config() if args.load: config.session_init = SaverRestore(args.load) SyncMultiGPUTrainerParameterServer(config).train()
parser = argparse.ArgumentParser() parser.add_argument('--gpu', help='comma separated list of GPU(s) to use.') parser.add_argument('--data', help='ILSVRC dataset dir') parser.add_argument('--load', help='load model') parser.add_argument('-d', '--depth', help='resnet depth', type=int, default=18, choices=[18, 34, 50, 101]) parser.add_argument('--eval', action='store_true') args = parser.parse_args() DEPTH = args.depth if args.gpu: os.environ['CUDA_VISIBLE_DEVICES'] = args.gpu if args.eval: BATCH_SIZE = 64 # something that can run on one gpu ds = get_data('val') eval_on_ILSVRC12(Model(), args.load, ds) sys.exit() logger.set_logger_dir( os.path.join('train_log', 'imagenet-resnet-se-d' + str(DEPTH))) config = get_config() if args.load: config.session_init = SaverRestore(args.load) SyncMultiGPUTrainerParameterServer(config).train()
type=int, choices=[50, 101, 152]) parser.add_argument('--input', help='an input image') parser.add_argument('--eval', help='ILSVRC dir to run validation on') args = parser.parse_args() assert args.input or args.eval, "Choose either input or eval!" if args.gpu: os.environ['CUDA_VISIBLE_DEVICES'] = args.gpu MODEL_DEPTH = args.depth param = np.load(args.load, encoding='latin1').item() resnet_param = {} for k, v in six.iteritems(param): try: newname = name_conversion(k) except: logger.error("Exception when processing caffe layer {}".format(k)) raise logger.info("Name Transform: " + k + ' --> ' + newname) resnet_param[newname] = v if args.eval: ds = ILSVRC12(args.eval, 'val', shuffle=False, dir_structure='train') ds = AugmentImageComponent(ds, get_inference_augmentor()) ds = BatchData(ds, 128, remainder=True) ds = PrefetchDataZMQ(ds, 1) eval_on_ILSVRC12(Model(), DictRestore(resnet_param), ds) else: run_test(resnet_param, args.input)