from .net_utils import * from .util import * def load_checkpoint(model, ckpt_path): checkpoint = torch.load(ckpt_path) if 'model' in checkpoint: checkpoint = checkpoint['model'] if 'state_dict' in checkpoint: checkpoint = checkpoint['state_dict'] ckpt = {} for k, v in checkpoint.items(): if k.startswith('module.'): ckpt[k[7:]] = v else: ckpt[k] = v model.load_state_dict(ckpt,strict=False) #strict=False by nami