import mxnet as mx from mxnet import nd from mxnet import init from mxnet import gluon from lib.core.metric import MPJPEMetric from lib.core.loss import MeanSquareLoss from lib.core.loader import JointsDataIter from lib.core.network import get_net from lib.core.get_optimizer import get_optimizer from lib.dataset.hm36 import hm36, torso_head, limb_mid, limb_terminal from lib.utils import * from lib.net_module import * from config import config, gen_config, s_args, update_config_from_args config = update_config_from_args(config, s_args) def main(): # Parse config and mkdir output logger, final_Model_path = create_logger(config) config.final_Model_path = final_Model_path gen_config(os.path.join(final_Model_path, 'hyperParams.yaml')) logger.info('Training config:{}\n'.format(pprint.pformat(config))) # define context if config.useGPU: ctx = [mx.gpu(int(i)) for i in config.gpu.split(',')] logger.info("Using context:", ctx) # dataset, generate trainset/ validation set train_imdbs = []
import argparse import config if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("--host", "-H", default="127.0.0.1", help="webserver host") parser.add_argument("--port", "-p", default=5000, help="webserver host") parser.add_argument("--debug", "-v", action="store_true", help="run in debug mode") args = parser.parse_args() config.update_config_from_args(args) import logging logging.basicConfig( level=logging.INFO if not args.debug else logging.DEBUG, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", ) from my_wallet import app app.run(host=config.HOST, port=config.PORT, debug=config.DEBUG)
'--test_build', action='store_true', help='Test the current build with very small number of iterations') parser.add_argument('--sample_step', type=int) # Test configuration. # parser.add_argument('--test_iters', type=int, default=200000, help='test model from this step') # parser.add_argument('--mode', type=str, default='train', choices=['train', 'test']) args, other_args = parser.parse_known_args() args = vars(args) # Convert to dict init_cfg = config.cfg if args['load_dir']: cfg = load_config(args['load_dir']) config.update_config_from_args(cfg, args, other_args) config.update_config_for_load_dir(cfg, init_cfg, args['load_dir']) else: config.initialise_config(init_cfg) # Initialise some basic variables cfg = init_cfg set_seed(cfg.params.rand_seed) config.update_config(cfg, args, other_args) config.export_config(cfg) config.export_files(cfg) dev_id = cfg.params.cuda_device_id cfg.params.cuda_device_id = 'cuda:' + str(dev_id) if type( dev_id) is int else dev_id print(config.cfg2str(cfg))