()
| 71 | |
| 72 | |
| 73 | def main(): |
| 74 | args = parse_args() |
| 75 | |
| 76 | cfg = mmcv.Config.fromfile(args.config) |
| 77 | if args.cfg_options is not None: |
| 78 | cfg.merge_from_dict(args.cfg_options) |
| 79 | # set cudnn_benchmark |
| 80 | if cfg.get('cudnn_benchmark', False): |
| 81 | torch.backends.cudnn.benchmark = True |
| 82 | cfg.data.test.test_mode = True |
| 83 | |
| 84 | # init distributed env first, since logger depends on the dist info. |
| 85 | if args.launcher == 'none': |
| 86 | distributed = False |
| 87 | else: |
| 88 | distributed = True |
| 89 | init_dist(args.launcher, **cfg.dist_params) |
| 90 | |
| 91 | # build the dataloader |
| 92 | dataset = build_dataset(cfg.data.test) |
| 93 | # the extra round_up data will be removed during gpu/cpu collect |
| 94 | data_loader = build_dataloader( |
| 95 | dataset, |
| 96 | samples_per_gpu=cfg.data.samples_per_gpu, |
| 97 | workers_per_gpu=cfg.data.workers_per_gpu, |
| 98 | dist=distributed, |
| 99 | shuffle=False, |
| 100 | round_up=False) |
| 101 | |
| 102 | # build the model and load checkpoint |
| 103 | cfg.model.model.waypoint = True |
| 104 | model = build_architecture(cfg.model) |
| 105 | fp16_cfg = cfg.get('fp16', None) |
| 106 | if fp16_cfg is not None: |
| 107 | wrap_fp16_model(model) |
| 108 | load_checkpoint(model, args.checkpoint, map_location='cpu') |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | # Compute the translation requirement |
| 114 | |
| 115 | import numpy as np |
| 116 | |
| 117 | phys_mode = args.physmode |
| 118 | phys_setting = 'kit' if 'kit' in args.config else 'human' |
| 119 | |
| 120 | if phys_setting == 'kit': |
| 121 | mean_path = 'data/datasets/kit_pml/mean.npy' |
| 122 | std_path = 'data/datasets/kit_pml/std.npy' |
| 123 | else: |
| 124 | mean_path = 'data/datasets/human_pml3d/mean.npy' |
| 125 | std_path = 'data/datasets/human_pml3d/std.npy' |
| 126 | mean = np.load(mean_path) |
| 127 | std = np.load(std_path) |
| 128 | |
| 129 | x_mean, x_std, y_mean, y_std = mean[0], std[0], mean[1], std[1] |
| 130 |
no test coverage detected