(self, C)
| 28 | class Solver(object): |
| 29 | |
| 30 | def __init__(self, C): |
| 31 | config = edict(C.config['common']) |
| 32 | ginfo = C.ginfo |
| 33 | if 'out_dir' in C.config: |
| 34 | self.out_dir = C.config['out_dir']+'/' |
| 35 | else: |
| 36 | self.out_dir = "" |
| 37 | |
| 38 | if 'expname' in C.config: |
| 39 | self.tb_path = '{}events/{}'.format(self.out_dir, C.config['expname']) |
| 40 | self.ckpt_path = '{}checkpoints/{}'.format(self.out_dir, C.config['expname']) |
| 41 | self.logs_path = '{}logs/{}'.format(self.out_dir, C.config['expname']) |
| 42 | else: |
| 43 | save_path = config.get('save_path', os.path.dirname(C.config_file)) |
| 44 | self.save_path = save_path |
| 45 | self.tb_path = '{}/events'.format(save_path) |
| 46 | self.ckpt_path = '{}/checkpoints'.format(save_path) |
| 47 | self.logs_path = '{}/logs'.format(save_path) |
| 48 | if C.rank == 0: |
| 49 | os.makedirs(self.tb_path, exist_ok=True) |
| 50 | os.makedirs(self.ckpt_path, exist_ok=True) |
| 51 | os.makedirs(self.logs_path, exist_ok=True) |
| 52 | # self.tb_logger = SummaryWriter(self.tb_path) |
| 53 | project_name = config.get('project_name', os.path.dirname(C.config_file).split('/')[-1]) |
| 54 | # import pdb;pdb.set_trace() |
| 55 | self.tb_logger = SummaryWriter(log_dir=self.tb_path,name=C.config['expname'],project=project_name) |
| 56 | else: |
| 57 | while not os.path.exists(self.logs_path): |
| 58 | time.sleep(1) |
| 59 | |
| 60 | if ginfo.task_rank == 0: |
| 61 | self.logger = create_logger('global_logger', '{}/log_task_{}.txt'.format(self.logs_path, ginfo.task_id)) |
| 62 | |
| 63 | self.clip_grad_backbone = config.get('clip_grad_backbone', 0.0) |
| 64 | self.clip_grad_neck = config.get('clip_grad_neck', 0.0) |
| 65 | self.clip_grad_decoder = config.get('clip_grad_decoder', 0.0) |
| 66 | self.sync = config.get('sync', False) |
| 67 | |
| 68 | self.fix_bn = config.get('fix_bn', False) |
| 69 | |
| 70 | self.last_iter = -1 |
| 71 | # self.feature_dim = config.model['kwargs']['feature_dim'] |
| 72 | # self.feature_dim = config['feature_dim'] |
| 73 | self.C = C |
| 74 | self.config = config |
| 75 | self.ginfo = ginfo |
| 76 | |
| 77 | # for auto_denan |
| 78 | self.autodenan = self.config.get('auto_denan', True) |
| 79 | if not self.autodenan and self.C.rank == 0: |
| 80 | self.logger.info('auto_denan disabled!') |
| 81 | self.last_state_dict = {} |
| 82 | self.last_optim_state_dict = {} |
| 83 | self.last_save_iter = -1 |
| 84 | |
| 85 | # for auto_alert |
| 86 | self.auto_alert = self.config.get('auto_alert', False) |
| 87 | if self.auto_alert and self.C.rank == 0: |
nothing calls this directly
no test coverage detected