コード例 #1
0
def parse_args():
    """
    args for training.
    """
    parser = argparse.ArgumentParser(description='finetune the supernet')
    # general
    parser.add_argument('--cfg',
                        type=str,
                        default='experiments/train/Ocean.yaml',
                        help='yaml configure file name')

    args, rest = parser.parse_known_args()
    # update config
    update_config(args.cfg)

    parser.add_argument('--gpus', type=str, help='gpus')
    parser.add_argument('--workers',
                        type=int,
                        help='num of dataloader workers')
    parser.add_argument('--CHECKPOINT_DIR', type=str, default='')
    parser.add_argument('--OUTPUT_DIR', type=str, default='')
    parser.add_argument('--path_name', type=str, required=True)
    parser.add_argument('--pretrain_dir', type=str, required=True)
    args = parser.parse_args()

    return args
コード例 #2
0
def parse_args():
    parser = argparse.ArgumentParser(description='Test localization network')

    # general
    parser.add_argument('--cfg',
                        help='experiment configure file name',
                        required=True,
                        type=str)
    args, rest = parser.parse_known_args()

    # update config
    update_config(args.cfg)

    # testing
    parser.add_argument('--gpus', help='gpus', type=str)
    parser.add_argument('--workers',
                        help='num of dataloader workers',
                        type=int)
    parser.add_argument('--dataDir', help='data path', type=str)
    parser.add_argument('--modelDir', help='model path', type=str)
    parser.add_argument('--logDir', help='log path', type=str)
    parser.add_argument('--split',
                        default='val',
                        required=True,
                        choices=['train', 'val', 'test'],
                        type=str)
    parser.add_argument('--verbose',
                        default=False,
                        action="store_true",
                        help='print progress bar')
    args = parser.parse_args()

    return args
コード例 #3
0
def parse_args():
    parser = argparse.ArgumentParser(description='Generate Data For RPSM')
    parser.add_argument('--cfg',
                        help='configuration file name',
                        required=True,
                        type=str)
    parser.add_argument('--heatmap',
                        help='heatmap file name',
                        required=True,
                        type=str)
    args, rest = parser.parse_known_args()
    update_config(args.cfg)

    parser.add_argument('--modelDir',
                        help='model directory',
                        type=str,
                        default='')
    parser.add_argument('--logDir', help='log directory', type=str, default='')
    parser.add_argument('--dataDir',
                        help='data directory',
                        type=str,
                        default='')
    parser.add_argument('--no-distortion',
                        help='wheter use no distortion data',
                        action='store_true')
    args = parser.parse_args()
    update_dir(args.modelDir, args.logDir, args.dataDir)
    return args
コード例 #4
0
def parse_args():
    parser = argparse.ArgumentParser(description='Keypoint detection')
    # general
    parser.add_argument('--cfg',
                        help='experiment configure file name',
                        required=True,
                        type=str)

    args, rest = parser.parse_known_args()
    # update config
    update_config(args.cfg)

    parser.add_argument('--model-file', help='model state file', type=str)
    parser.add_argument('--flip-test',
                        help='use flip test',
                        action='store_true')
    parser.add_argument('--post-process',
                        help='use post process',
                        action='store_true')
    parser.add_argument('--shift-heatmap',
                        help='shift heatmap',
                        action='store_true')
    parser.add_argument('--image-path',
                        help='image path',
                        default="/home/manhas/Pictures/crop_image/2.jpg")

    args = parser.parse_args()

    return args
コード例 #5
0
def parse_args():
    parser = argparse.ArgumentParser(description="Train keypoints network")
    # general
    parser.add_argument("--cfg",
                        help="experiment configure file name",
                        required=True,
                        type=str)

    args, rest = parser.parse_known_args()
    # update config
    update_config(args.cfg)

    # training
    parser.add_argument("--frequent",
                        help="frequency of logging",
                        default=config.PRINT_FREQ,
                        type=int)
    parser.add_argument("--gpus", help="gpus", type=str)
    parser.add_argument("--workers",
                        help="num of dataloader workers",
                        type=int)

    args = parser.parse_args()

    return args
コード例 #6
0
def parse_args():
    parser = argparse.ArgumentParser(description='Train keypoints network')
    # general
    parser.add_argument('--cfg',
                        help='experiment configure file name',
                        required=True,
                        type=str)

    args, rest = parser.parse_known_args()
    # update config
    update_config(args.cfg)

    # training
    parser.add_argument('--frequent',
                        help='frequency of logging',
                        default=config.PRINT_FREQ,
                        type=int)
    parser.add_argument('--gpus', help='gpus', type=str)
    parser.add_argument('--workers',
                        help='num of dataloader workers',
                        type=int)

    args = parser.parse_args()
    print(
        'final args !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
    )
    print(args)

    return args
コード例 #7
0
def parse_args():
    parser = argparse.ArgumentParser(description='Evaluate 3D Pose Estimation')
    parser.add_argument('--cfg',
                        help='configuration file name',
                        required=True,
                        type=str)
    args, rest = parser.parse_known_args()
    update_config(args.cfg)

    parser.add_argument('--modelDir',
                        help='model directory',
                        type=str,
                        default='')
    parser.add_argument('--logDir', help='log directory', type=str, default='')
    parser.add_argument('--dataDir',
                        help='data directory',
                        type=str,
                        default='')
    parser.add_argument('--withIMU',
                        help='use bone orientation in 3d',
                        type=lambda x:
                        (str(x).lower() in ['true', '1', 'yes']),
                        default=False)

    args = parser.parse_args()
    update_dir(args.modelDir, args.logDir, args.dataDir)
    return args
コード例 #8
0
ファイル: train.py プロジェクト: hbsz123/Tracking-Pipeline
def parse_args():
    parser = argparse.ArgumentParser(description='Train keypoints network')
    # general
    parser.add_argument('--cfg',
                        help='experiment configure file name',
                        required=True,
                        type=str)

    args, rest = parser.parse_known_args()
    # update config
    update_config(args.cfg)

    # training
    parser.add_argument('--frequent',
                        help='frequency of logging',
                        default=config.PRINT_FREQ,
                        type=int)
    parser.add_argument('--gpus', help='gpus', type=str)
    parser.add_argument('--workers',
                        help='num of dataloader workers',
                        type=int)
    parser.add_argument(
        '--model',
        help='pretraind model',
        type=str,
        default=
        '/export/home/lfy/zby/human-pose-estimation.pytorch/models/pytorch/pose_coco/pose_resnet_152_384x288.pth.tar'
    )

    args = parser.parse_args()

    return args
コード例 #9
0
def parse_args():
    parser = argparse.ArgumentParser(description='Evaluate 3D Pose Estimation')
    parser.add_argument(
        '--cfg', help='configuration file name', required=True, type=str)
    args, rest = parser.parse_known_args()
    update_config(args.cfg)
    return args
コード例 #10
0
ファイル: detect_pos.py プロジェクト: tutussss/lumbar_project
def parse_args():
    parser = argparse.ArgumentParser(description='Train keypoints network')
    # general
    parser.add_argument('--cfg',
                        help='experiment configure file name',
                        required=True,
                        type=str)

    args, rest = parser.parse_known_args()
    # update config
    update_config(args.cfg)

    # training
    parser.add_argument('--frequent',
                        help='frequency of logging',
                        default=config.PRINT_FREQ,
                        type=int)
    parser.add_argument('--model-file', help='model state file', type=str)
    parser.add_argument('--img-file',
                        help='input your test img',
                        type=str,
                        default='')
    args = parser.parse_args()

    return args
コード例 #11
0
def parse_args():
    parser = argparse.ArgumentParser(description='Train keypoints network')
    parser.add_argument(
        '--cfg', help='experiment configure file name', required=True, type=str)
    args, rest = parser.parse_known_args()
    update_config(args.cfg)

    parser.add_argument(
        '--frequent',
        help='frequency of logging',
        default=config.PRINT_FREQ,
        type=int)
    parser.add_argument('--gpus', help='gpus', type=str)
    parser.add_argument('--workers', help='num of dataloader workers', type=int)

    parser.add_argument(
        '--modelDir', help='model directory', type=str, default='')
    parser.add_argument('--logDir', help='log directory', type=str, default='')
    parser.add_argument(
        '--dataDir', help='data directory', type=str, default='')
    parser.add_argument(
        '--data-format', help='data format', type=str, default='')
    parser.add_argument(
        '--on-server-cluster', help='if training on cluster', action='store_true')
    parser.add_argument(
        '--iteration', help='the kth times of training', type=int, choices=range(1,10), default=1)
    parser.add_argument(
        '--no-distortion', help='wheter use no distortion data', action='store_true')
    args = parser.parse_args()
    update_dir(args.modelDir, args.logDir, args.dataDir)
    return args
コード例 #12
0
def parse_args():
    parser = argparse.ArgumentParser(description='Train keypoints network')
    # general
    parser.add_argument(
        '--cfg',
        help='experiment configure file name',
        default=
        '/home/gyh/human-pose-estimation/experiments/coco/resnet50/256x192_d256x3_adam_lr1e-3.yaml',
        type=str)

    args, rest = parser.parse_known_args()
    # update config
    update_config(args.cfg)

    # training
    parser.add_argument('--frequent',
                        help='frequency of logging',
                        default=config.PRINT_FREQ,
                        type=int)
    parser.add_argument('--gpus', help='gpus', type=str)
    parser.add_argument('--workers',
                        help='num of dataloader workers',
                        type=int)

    args = parser.parse_args()

    return args
コード例 #13
0
ファイル: train.py プロジェクト: Error-code404/WS-3DPE
def parse_args():
    parser = argparse.ArgumentParser(description='Train keypoints network')
    parser.add_argument(
        '--cfg', help='experiment configure file name', required=True, type=str)
    args, rest = parser.parse_known_args()
    update_config(args.cfg)

    parser.add_argument(
        '--frequent',
        help='frequency of logging',
        default=config.PRINT_FREQ,
        type=int)
    parser.add_argument('--gpus', help='gpus', type=str)
    parser.add_argument('--workers', help='num of dataloader workers', type=int)

    parser.add_argument(
        '--modelDir', help='model directory', type=str, default='')
    parser.add_argument('--logDir', help='log directory', type=str, default='')
    parser.add_argument(
        '--dataDir', help='data directory', type=str, default='')
    parser.add_argument(
        '--data-format', help='data format', type=str, default='')
    args = parser.parse_args()
    update_dir(args.modelDir, args.logDir, args.dataDir)
    return args
コード例 #14
0
def get_pose_model():
    args = GetArgs()
    update_config(args.cfg)
    reset_config(config, args)
    # load pose-hrnet MODEL
    pose_model = load_model(config)
    pose_model.cuda().eval()
    return pose_model
コード例 #15
0
def parse_args():
    parser = argparse.ArgumentParser(
        description='Test Recursive Pictorial Structure Model')
    parser.add_argument(
        '--cfg', help='experiment configure file name', required=True, type=str)
    args, rest = parser.parse_known_args()
    update_config(args.cfg)
    return args
コード例 #16
0
def parse_args():
    parser = argparse.ArgumentParser(description='Generate Data For RPSM')
    parser.add_argument(
        '--cfg', help='configuration file name', required=True, type=str)
    parser.add_argument(
        '--heatmap', help='heatmap file name', required=True, type=str)
    args, rest = parser.parse_known_args()
    update_config(args.cfg)
    return args
コード例 #17
0
ファイル: valid.py プロジェクト: t-kita/adafuse-3d-human-pose
def parse_args():
    parser = argparse.ArgumentParser(description='Train keypoints network')
    # general
    parser.add_argument('--cfg',
                        help='experiment configure file name',
                        required=True,
                        type=str)

    args, rest = parser.parse_known_args()
    # update config
    update_config(args.cfg)

    # training
    parser.add_argument('--frequent',
                        help='frequency of logging',
                        default=config.PRINT_FREQ,
                        type=int)
    parser.add_argument('--gpus', help='gpus', type=str)
    parser.add_argument(
        '--state',
        help='the state of model which is used to test (best or final)',
        default='best',
        type=str)
    parser.add_argument('--workers',
                        help='num of dataloader workers',
                        type=int)
    parser.add_argument('--model-file', help='model state file', type=str)
    parser.add_argument('--flip-test',
                        help='use flip test',
                        action='store_true')
    parser.add_argument('--post-process',
                        help='use post process',
                        action='store_true')
    parser.add_argument('--shift-heatmap',
                        help='shift heatmap',
                        action='store_true')

    # philly
    parser.add_argument('--modelDir',
                        help='model directory',
                        type=str,
                        default='')
    parser.add_argument('--logDir', help='log directory', type=str, default='')
    parser.add_argument('--dataDir',
                        help='data directory',
                        type=str,
                        default='')
    parser.add_argument('--data-format',
                        help='data format',
                        type=str,
                        default='')

    args = parser.parse_args()

    update_dir(args.modelDir, args.logDir, args.dataDir)

    return args
コード例 #18
0
def parse_args():
    parser = argparse.ArgumentParser(description='Train keypoints network')
    # general
    parser.add_argument('--cfg',
                        help='experiment configure file name',
                        required=True,
                        type=str)

    args, rest = parser.parse_known_args()
    # update config
    update_config(args.cfg)

    # training
    parser.add_argument('--frequent',
                        help='frequency of logging',
                        default=config.PRINT_FREQ,
                        type=int)
    parser.add_argument('--gpus', help='gpus', type=str)
    parser.add_argument('--workers',
                        help='num of dataloader workers',
                        type=int)
    parser.add_argument('--model-file', help='model state file', type=str)
    parser.add_argument('--use-detect-bbox',
                        help='use detect bbox',
                        action='store_true')
    parser.add_argument('--flip-test',
                        help='use flip test',
                        action='store_true')
    parser.add_argument('--post-process',
                        help='use post process',
                        action='store_true')
    parser.add_argument('--shift-heatmap',
                        help='shift heatmap',
                        action='store_true')
    parser.add_argument('--coco-bbox-file',
                        help='coco detection bbox file',
                        type=str)
    parser.add_argument('--nltype', help='type of nonlocal block', type=str)
    parser.add_argument('--spectrum_relu',
                        help='using spectrum_relu',
                        action="store_true")
    parser.add_argument(
        '--enc_no_ds',
        help='no downsampling in the last two layers of encoder',
        action="store_true")
    parser.add_argument('--enc_nl',
                        help='add nonlocal block at encoder',
                        action="store_true")
    parser.add_argument('--dec_nl',
                        help='add nonlocal block at decoder',
                        nargs='+',
                        type=int,
                        default=None)

    args = parser.parse_args()

    return args
コード例 #19
0
def parse_args():
    parser = argparse.ArgumentParser(description='Train keypoints network')
    parser.add_argument(
        '--cfg', help='experiment configure file name', required=True, type=str)

    args, rest = parser.parse_known_args()
    update_config(args.cfg)

    return args
コード例 #20
0
def parse_args():
    parser = argparse.ArgumentParser(
        description='Generate Pairwise Constraint for RPSM')
    parser.add_argument('--cfg',
                        help='experiment configure file name',
                        required=True,
                        type=str)
    args, rest = parser.parse_known_args()
    update_config(args.cfg)
    return args
コード例 #21
0
def parse_args():
    parser = argparse.ArgumentParser(description='Test Pseudo Labels')
    # Required Param
    parser.add_argument('--cfg',
                        help='experiment configure file name',
                        required=True,
                        type=str)
    parser.add_argument('--heatmap',
                        help='heatmap file name',
                        default='',
                        required=True,
                        type=str)
    args, rest = parser.parse_known_args()
    update_config(args.cfg)

    parser.add_argument('--confidence-thre',
                        help='max pixel error to accept inliers',
                        type=float)
    parser.add_argument('--ransac', help='use ransac', action='store_true')
    parser.add_argument('--inliers',
                        help='min support num of inliers',
                        type=int)
    parser.add_argument('--reproj-thre',
                        help='reprojection threshold to accept inliers',
                        type=int)
    parser.add_argument('--use-reproj',
                        help='use reprojected 2d as label',
                        action='store_true')
    parser.add_argument(
        '--loop',
        help='whether in loop training, only generate one pseudo_label',
        action='store_true')
    parser.add_argument('--no-distortion',
                        help='whether use no distortion data',
                        action='store_true')
    parser.add_argument('--net-layers',
                        help='network layers',
                        type=int,
                        default=50,
                        choices=[50, 152])

    parser.add_argument('--modelDir',
                        help='model directory',
                        type=str,
                        default='')
    parser.add_argument('--logDir', help='log directory', type=str, default='')
    parser.add_argument('--dataDir',
                        help='data directory',
                        type=str,
                        default='')
    args = parser.parse_args()
    update_dir(args.modelDir, args.logDir, args.dataDir)
    return args
コード例 #22
0
def parse_args():
    parser = argparse.ArgumentParser(description='Test Pseudo Labels')
    # Required Param
    parser.add_argument('--cfg',
                        help='experiment configure file name',
                        required=True,
                        type=str)
    args, rest = parser.parse_known_args()
    update_config(args.cfg)

    args = parser.parse_args()
    return args
コード例 #23
0
def get_two_model():
    args = GetArgs()
    update_config(args.cfg)
    reset_config(config, args)

    # load pose-hrnet MODEL
    pose_model = load_model(config)
    pose_model.cuda().eval()

    # load YoloV3 Model
    bbox_model = yolo_model()
    return bbox_model, pose_model
コード例 #24
0
ファイル: eval.py プロジェクト: zzzzlalala/cvToolkit
def parse_args():
    parser = argparse.ArgumentParser(description='Train keypoints network')
    # general
    parser.add_argument(
        '--cfg',
        help='experiment configure file name',
        #  required=True,
        default='experiments/coco/resnet50/384x288_d256x3_adam_lr1e-3.yaml',
        type=str)

    args, rest = parser.parse_known_args()
    # update config
    update_config(args.cfg)

    # training
    parser.add_argument('--frequent',
                        help='frequency of logging',
                        default=config.PRINT_FREQ,
                        type=int)
    parser.add_argument('--gpus', help='gpus', type=str)
    parser.add_argument('--workers',
                        help='num of dataloader workers',
                        type=int)
    parser.add_argument(
        '--model-file',
        help='model state file',
        default='models/pytorch/pose_resnet_50_384x288.pth.tar',
        type=str)
    parser.add_argument('--use-detect-bbox',
                        help='use detect bbox',
                        action='store_true')
    parser.add_argument('--flip-test',
                        help='use flip test',
                        action='store_true')
    parser.add_argument('--post-process',
                        help='use post process',
                        action='store_true')
    parser.add_argument('--shift-heatmap',
                        help='shift heatmap',
                        action='store_true')
    parser.add_argument('--coco-bbox-file',
                        help='coco detection bbox file',
                        type=str)
    parser.add_argument('--det-file',
                        dest='det_file',
                        default='',
                        help='json file include image path and bbox',
                        type=str)

    args = parser.parse_args()

    return args
コード例 #25
0
def main():
    parser = argparse.ArgumentParser(description='model training')
    parser.add_argument('--config_file', type=str, default=None, help='optional config file for training')
    parser.add_argument('--save_dir', type=str, default='checkpoints', help='save model directory')

    args = parser.parse_args()
    if args.config_file is not None:
        update_config(args.config_file)
    opt.misc.save_dir = args.save_dir
    #指定gpu
    os.environ['CUDA_VISIBLE_DEVICES'] = opt.train.gpus
    cudnn.benchmark = True
    train(args)
コード例 #26
0
    def __init__(self, cuda_id=0, fast_yolo=False):

        self.time_det = 0.0
        self.time_run = 0.0

        self.num_joints = 17
        self.target_kps = [5, 6, 7, 8, 9, 10]

        # Load yolo detection model
        print('Loading YOLO model..')
        if fast_yolo:
            self.det_model = Darknet('./AlphaPose/yolo/cfg/yolov3-tiny.cfg')
            self.det_model.load_weights(
                './AlphaPose/models/yolo/yolov3-tiny.weights')
        else:
            self.det_model = Darknet("./AlphaPose/yolo/cfg/yolov3.cfg")
            self.det_model.load_weights(
                './AlphaPose/models/yolo/yolov3.weights')

        self.det_model.cuda()
        self.det_model.eval()

        cfg_file = 'MSRAPose/experiments/coco/resnet50/256x192_d256x3_adam_lr1e-3.yaml'
        model_file = 'MSRAPose/models/pytorch/pose_coco/pose_resnet_50_256x192.pth.tar'

        # update config
        update_config(cfg_file)
        config.TEST.MODEL_FILE = model_file

        # cudnn related setting
        cudnn.benchmark = config.CUDNN.BENCHMARK
        torch.backends.cudnn.deterministic = config.CUDNN.DETERMINISTIC
        torch.backends.cudnn.enabled = config.CUDNN.ENABLED

        # load pre-trained model
        self.model = eval('models_msra.' + config.MODEL.NAME +
                          '.get_pose_net')(config, is_train=False)
        print('Loading MSRA pose model..')
        print('=> loading model from {}'.format(config.TEST.MODEL_FILE))
        self.model.load_state_dict(torch.load(config.TEST.MODEL_FILE))

        gpus = [int(i) for i in config.GPUS.split(',')]
        self.model = torch.nn.DataParallel(self.model, device_ids=gpus).cuda()
        self.model.eval()

        # image transform
        self.transform = transforms.Compose([
            transforms.ToTensor(),
            transforms.Normalize(mean=[0.485, 0.456, 0.406],
                                 std=[0.229, 0.224, 0.225]),
        ])
コード例 #27
0
def main():
    parser = argparse.ArgumentParser(description='reid model testing')
    parser.add_argument('--config_file', type=str, default=None,
                        help='Optional config file for params')
    parser.add_argument('--load_model', type=str, required=True,
                        help='load trained model for testing')

    args = parser.parse_args()
    if args.config_file is not None:
        update_config(args.config_file)

    os.environ["CUDA_VISIBLE_DEVICES"] = opt.network.gpus
    cudnn.benchmark = True
    test(args)
コード例 #28
0
def parse_args():
    parser = argparse.ArgumentParser(description='Train keypoints network')
    # general
    parser.add_argument('--cfg',
                        help='experiment configure file name',
                        required=True,
                        type=str)
    args, rest = parser.parse_known_args()
    # update config
    update_config(args.cfg)

    # training
    parser.add_argument('--frequent',
                        help='frequency of logging',
                        default=config.PRINT_FREQ,
                        type=int)
    parser.add_argument('--gpus',
                        help='gpus',
                        type=str)
    parser.add_argument('--workers',
                        help='num of dataloader workers',
                        type=int)
                        
    parser.add_argument('opts',
                        help="Modify config options using the command-line",
                        default=None,
                        nargs=argparse.REMAINDER)

    # philly
    parser.add_argument('--modelDir',
                        help='model directory',
                        type=str,
                        default='')
    parser.add_argument('--logDir',
                        help='log directory',
                        type=str,
                        default='')
    parser.add_argument('--dataDir',
                        help='data directory',
                        type=str,
                        default='')
    parser.add_argument('--prevModelDir',
                        help='prev Model directory',
                        type=str,
                        default='')

    args = parser.parse_args()

    return args
コード例 #29
0
def parse_args():
    parser = argparse.ArgumentParser(description='Train keypoints network')
    parser.add_argument('--cfg',
                        help='experiment configure file name',
                        required=True,
                        type=str)
    args, rest = parser.parse_known_args()
    update_config(args.cfg)

    parser.add_argument('--frequent',
                        help='frequency of logging',
                        default=config.PRINT_FREQ,
                        type=int)
    parser.add_argument('--gpus', help='gpus', type=str)
    parser.add_argument('--workers',
                        help='num of dataloader workers',
                        type=int)
    parser.add_argument('--cams', help='view/cam id to use', type=str)
    # parser.add_argument(
    #     '--ablation', help='heatmap_only, consistency_only, both', type=str)

    parser.add_argument('--modelDir',
                        help='model directory',
                        type=str,
                        default='')
    parser.add_argument('--logDir', help='log directory', type=str, default='')
    parser.add_argument('--dataDir',
                        help='data directory',
                        type=str,
                        default='')
    parser.add_argument('--data-format',
                        help='data format',
                        type=str,
                        default='')
    parser.add_argument('--runMode',
                        help='train or test',
                        type=str,
                        default='train')
    parser.add_argument('--modelFile',
                        help='model for test',
                        type=str,
                        default='0')
    parser.add_argument('--evaluate',
                        help='directly use provided model to evaluate results',
                        type=str2bool,
                        default='0')
    args = parser.parse_args()
    update_dir(args.modelDir, args.logDir, args.dataDir)
    return args
コード例 #30
0
def main():
    args = parse_args()
    # update config
    update_config(args.cfg)
    reset_config(config, args)
    # output dir path
    onnx_path = './models/onnx/'

    logger, final_output_dir, tb_log_dir = create_logger(
        config, args.cfg, 'convert')
    if not os.path.isdir(onnx_path):
        logger.info('Creating ' + onnx_path + 'folder...')
        os.makedirs(onnx_path)
    height = 0
    width = 0

    with open(args.cfg) as file:
        documents = yaml.load(file, Loader=yaml.FullLoader)
        height = documents['MODEL']['IMAGE_SIZE'][0]
        width = documents['MODEL']['IMAGE_SIZE'][1]

    # cudnn related setting
    cudnn.benchmark = config.CUDNN.BENCHMARK
    torch.backends.cudnn.deterministic = config.CUDNN.DETERMINISTIC
    torch.backends.cudnn.enabled = config.CUDNN.ENABLED

    model = eval('models.' + config.MODEL.NAME + '.get_pose_net')(
        config, is_train=False)

    logger.info('=> loading model from {}'.format(config.TEST.MODEL_FILE))
    filename = config.TEST.MODEL_FILE
    cuda_available = torch.cuda.is_available()
    model.load_state_dict(
        torch.load(
            config.TEST.MODEL_FILE,
            map_location=None if cuda_available else torch.device('cpu')))
    logger.info('=> Converting...')
    data = torch.zeros((1, 3, height, width))
    if cuda_available:
        model.cuda()
        data = data.cuda()
    model.float()
    head, filename = os.path.split(filename)
    if 'pth.tar' in filename:
        filename = filename[:-8]

    torch.onnx.export(model, data, onnx_path + filename + '.onnx')
    logger.info('=> Model saved as: ' + onnx_path + filename + '.onnx')
    logger.info('=> Done.')