| 78 | |
| 79 | |
| 80 | class Config(MMConfig): |
| 81 | def __init__(self, cfg_dict=None, cfg_text=None, filename=None): |
| 82 | super().__init__(cfg_dict, cfg_text, filename) |
| 83 | |
| 84 | def get_config_fromfile(self, config_path): |
| 85 | self.config_path = config_path |
| 86 | |
| 87 | cfg, _ = MMConfig._file2dict(self.config_path) |
| 88 | |
| 89 | self.merge_from_dict(cfg) |
| 90 | # #import ipdb;ipdb.set_trace() |
| 91 | # self.__dict__.update(dict(cfg)) |
| 92 | # # update dir |
| 93 | dir_dict = {} |
| 94 | exp_name = 'exps62' |
| 95 | time_str = datetime.datetime.now().strftime('%Y%m%d_%H%M%S') |
| 96 | dir_dict['cur_dir'] = osp.dirname(os.path.abspath(__file__)) |
| 97 | dir_dict['root_dir'] = osp.join(dir_dict['cur_dir'], '..') |
| 98 | dir_dict['output_dir'] = osp.join(dir_dict['root_dir'], exp_name) |
| 99 | dir_dict['result_dir'] = osp.join(dir_dict['output_dir'], 'result') |
| 100 | dir_dict['data_dir'] = osp.join(dir_dict['root_dir'], 'dataset') |
| 101 | dir_dict['human_model_path'] = osp.join('data/body_models') |
| 102 | self.merge_from_dict(dir_dict) |
| 103 | # |
| 104 | # ## add some paths to the system root dir |
| 105 | sys.path.insert(0, osp.join(self.root_dir, 'common')) |
| 106 | sys.path.insert(0, osp.join(self.root_dir, 'united-perception_utils')) |
| 107 | sys.path.insert(0, osp.join(self.cur_dir, 'humanbench_utils')) |
| 108 | sys.path.insert(0, osp.join(self.cur_dir, 'dinov2_utils')) |
| 109 | sys.path.insert(0, osp.join(self.cur_dir, 'lora_utils')) |
| 110 | sys.path.insert(0, osp.join(self.cur_dir, 'vit_adapter_utils')) |
| 111 | from util.dir import add_pypath |
| 112 | # add_pypath(osp.join(self.data_dir)) |
| 113 | for dataset in os.listdir('datasets'): |
| 114 | if dataset not in ['humandata.py', '__pycache__', 'dataset.py']: |
| 115 | add_pypath(osp.join(self.root_dir, 'data', dataset)) |
| 116 | add_pypath('datasets') |
| 117 | add_pypath(self.data_dir) |
| 118 | |
| 119 | def prepare_dirs(self, exp_name): |
| 120 | time_str = datetime.datetime.now().strftime('%Y%m%d_%H%M%S') |
| 121 | self.output_dir = osp.join(self.root_dir, f'{exp_name}_{time_str}') |
| 122 | self.model_dir = osp.join(self.output_dir, 'model_dump') |
| 123 | self.vis_dir = osp.join(self.output_dir, 'vis') |
| 124 | self.log_dir = osp.join(self.output_dir, 'log') |
| 125 | self.code_dir = osp.join(self.output_dir, 'code') |
| 126 | self.result_dir = osp.join(self.output_dir.split('/')[:-1]) |
| 127 | from util.dir import make_folder |
| 128 | make_folder(self.model_dir) |
| 129 | make_folder(self.vis_dir) |
| 130 | make_folder(self.log_dir) |
| 131 | make_folder(self.code_dir) |
| 132 | make_folder(self.result_dir) |
| 133 | |
| 134 | ## copy some code to log dir as a backup |
| 135 | copy_files = [ |
| 136 | 'main/train.py', 'main/test.py', 'common/base.py', 'main/OSX.py', |
| 137 | 'common/nets', 'main/OSX_WoDecoder.py', 'data/dataset.py', |