MCPcopy Create free account
hub / github.com/MotrixLab/ADHMR / load_model

Method load_model

HMR-Scorer/common/base.py:143–158  ·  view source on GitHub ↗
(self, model, optimizer)

Source from the content-addressed store, hash-verified

141 self.logger.info("Write snapshot into {}".format(file_path))
142
143 def load_model(self, model, optimizer):
144 if cfg.pretrained_model_path is not None:
145 ckpt_path = cfg.pretrained_model_path
146 ckpt = torch.load(ckpt_path, map_location=torch.device('cpu')) # solve CUDA OOM error in DDP
147 model.load_state_dict(ckpt['network'], strict=False)
148 self.logger.info('Load checkpoint from {}'.format(ckpt_path))
149 if not hasattr(cfg, 'start_over') or cfg.start_over:
150 start_epoch = 0
151 else:
152 optimizer.load_state_dict(ckpt['optimizer'])
153 start_epoch = ckpt['epoch'] + 1
154 self.logger.info(f'Load optimizer, start from{start_epoch}')
155 else:
156 start_epoch = 0
157
158 return start_epoch, model, optimizer
159
160 def load_scorer_model(self, model_score, optimizer, ema_score=None):
161 if cfg.pretrained_scorer_model_path is not None:

Callers

nothing calls this directly

Calls 3

infoMethod · 0.80
loadMethod · 0.45
load_state_dictMethod · 0.45

Tested by

no test coverage detected