()
| 85 | return transl_new, focal_ref_xy |
| 86 | |
| 87 | def main(): |
| 88 | args = parse_args() |
| 89 | cudnn.benchmark = True |
| 90 | |
| 91 | # init config |
| 92 | time_str = datetime.datetime.now().strftime('%Y%m%d_%H%M%S') |
| 93 | root_dir = Path(__file__).resolve().parent.parent |
| 94 | config_path = osp.join('./pretrained_models', args.ckpt_name, 'config_base.py') |
| 95 | cfg = Config.load_config(config_path) |
| 96 | checkpoint_path = osp.join('./pretrained_models', args.ckpt_name, f'{args.ckpt_name}.pth.tar') |
| 97 | img_folder = osp.join(root_dir, 'demo', 'input_frames', args.file_name) |
| 98 | output_folder = osp.join(root_dir, 'demo', 'output_frames', args.file_name) |
| 99 | os.makedirs(output_folder, exist_ok=True) |
| 100 | exp_name = f'inference_{args.file_name}_{args.ckpt_name}_{time_str}' |
| 101 | |
| 102 | new_config = { |
| 103 | "model": { |
| 104 | "pretrained_model_path": checkpoint_path, |
| 105 | }, |
| 106 | "log":{ |
| 107 | 'exp_name': exp_name, |
| 108 | 'log_dir': osp.join(root_dir, 'outputs', exp_name, 'log'), |
| 109 | } |
| 110 | } |
| 111 | cfg.update_config(new_config) |
| 112 | cfg.prepare_log() |
| 113 | |
| 114 | # init human models |
| 115 | smpl_x = SMPLX(cfg.model.human_model_path) |
| 116 | |
| 117 | # init tester |
| 118 | demoer = Tester(cfg) |
| 119 | demoer.logger.info(f"Using 1 GPU.") |
| 120 | demoer.logger.info(f'Inference [{args.file_name}] with [{cfg.model.pretrained_model_path}].') |
| 121 | demoer._make_model() |
| 122 | |
| 123 | # init detector |
| 124 | bbox_model = getattr(cfg.inference.detection, "model_path", |
| 125 | './pretrained_models/yolov8x.pt') |
| 126 | detector = YOLO(bbox_model) |
| 127 | |
| 128 | start = int(args.start) |
| 129 | end = int(args.end) + 1 |
| 130 | |
| 131 | # [NEW] Initialize result container |
| 132 | all_results = { |
| 133 | 'global_orient': [], |
| 134 | 'body_pose': [], |
| 135 | 'transl': [], |
| 136 | 'focal_length': [], |
| 137 | 'focal_length_xy': [], |
| 138 | 'width': [], |
| 139 | 'height': [], |
| 140 | 'princpt': [], |
| 141 | } |
| 142 | |
| 143 | for frame in tqdm(range(start, end)): |
| 144 |
no test coverage detected