File size: 513 Bytes
b9e72b4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 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
|