def load_meta_data(cfg): """ Set the meta directories: |--self._opt.output_dir: |--models: |--self._opt.model_id: |--opt_train.txt or opt_test.txt Returns: meta_data (EasyDict): the meta directories, it contains the followings: --checkpoints_dir: """ output_dir = cfg.output_dir meta_data = EasyDict() meta_data["checkpoints_dir"] = mkdir( os.path.join(output_dir, "models", cfg.model_id)) meta_data["personalized_ckpt_path"] = os.path.join( meta_data["checkpoints_dir"], "personalized.pth") meta_data["root_primitives_dir"] = mkdir( os.path.join(cfg.output_dir, "primitives")) meta_data["opt_path"] = os.path.join(meta_data["checkpoints_dir"], "opts.txt") if "src_path" in cfg: src_inputs = parse_src_input(cfg.src_path) root_primitives_dir = meta_data["root_primitives_dir"] meta_src = [] for meta_inp in src_inputs: meta_proc = MetaProcess(meta_inp, root_primitives_dir) meta_src.append(meta_proc) meta_data["meta_src"] = meta_src if "ref_path" in cfg: ref_inputs = parse_ref_input(cfg.ref_path) root_primitives_dir = meta_data["root_primitives_dir"] meta_ref = [] for meta_inp in ref_inputs: meta_proc = MetaProcess(meta_inp, root_primitives_dir) meta_ref.append(meta_proc) meta_data["meta_ref"] = meta_ref return meta_data
def test_06_parse_ref_with_warning(self): """ ref_input = "/path1" Returns: """ ref_input = "/path1,/audio1,pose_fc?=300|" \ "/path2,/audio2,pose_fc?=200" ref_meta_gt = [ meta_info.RefMetaInputInfo(path="/path1", name="path1", pose_fc=300), meta_info.RefMetaInputInfo(path="/path2", name="path2", pose_fc=200) ] ref_meta_parse = meta_info.parse_ref_input(ref_input) for meta_gt, meta_parse in zip(ref_meta_gt, ref_meta_parse): self.assertEqual(meta_gt == meta_parse, True)
def test_03_parse_ref_only_one_path(self): """ ref_input = "/path1" Returns: """ ref_input = "/path1" ref_meta_gt = [ meta_info.RefMetaInputInfo(path="/path1", name="path1") ] ref_meta_parse = meta_info.parse_ref_input(ref_input) for meta_gt, meta_parse in zip(ref_meta_gt, ref_meta_parse): # print(meta_gt) # print(meta_parse) self.assertEqual(meta_gt == meta_parse, True)
def test_02_parse_ref_only_path(self): """ test the ref_input with only path case. Returns: """ ref_input = "/path1|/path2" ref_meta_gt = [ meta_info.RefMetaInputInfo(path="/path1", name="path1"), meta_info.RefMetaInputInfo(path="/path2", name="path2") ] ref_meta_parse = meta_info.parse_ref_input(ref_input) for meta_gt, meta_parse in zip(ref_meta_gt, ref_meta_parse): # print(meta_gt) # print(meta_parse) self.assertEqual(meta_gt == meta_parse, True)
def test_01_parse_ref_full(self): """ test the full ref_input case. Returns: """ ref_input = "path?=/path1,name?=name1,audio?=/audio1,fps?=30,pose_fc?=300,cam_fc?=100|" \ "path?=/path2,name?=name2,audio?=/audio2,fps?=25,pose_fc?=200,cam_fc?=50" ref_meta_gt = [ meta_info.RefMetaInputInfo(path="/path1", name="name1", audio="/audio1", fps=30, pose_fc=300, cam_fc=100), meta_info.RefMetaInputInfo(path="/path2", name="name2", audio="/audio2", fps=25, pose_fc=200, cam_fc=50) ] ref_meta_parse = meta_info.parse_ref_input(ref_input) for meta_gt, meta_parse in zip(ref_meta_gt, ref_meta_parse): # print(meta_gt) # print(meta_parse) self.assertEqual(meta_gt == meta_parse, True)
def test_04_parse_ref_missing_key_value(self): """ ref_input = "/path1" Returns: """ ref_input = "path?=/path1,audio?=/audio1,pose_fc?=300|" \ "path?=/path2,audio?=/audio2,pose_fc?=200" ref_meta_gt = [ meta_info.RefMetaInputInfo(path="/path1", name="path1", audio="/audio1", pose_fc=300), meta_info.RefMetaInputInfo(path="/path2", name="path2", audio="/audio2", pose_fc=200) ] ref_meta_parse = meta_info.parse_ref_input(ref_input) for meta_gt, meta_parse in zip(ref_meta_gt, ref_meta_parse): # print(meta_gt) # print(meta_parse) self.assertEqual(meta_gt == meta_parse, True)