[Fix] check for CLASSES in checkpoint meta (#207)

- check for CLASSES in checkpoint meta when key meta does not exists
pull/220/head
agim-a 2021-04-15 10:19:23 -04:00 committed by GitHub
parent 1cde6f6e65
commit 3affc481c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -36,7 +36,7 @@ def init_model(config, checkpoint=None, device='cuda:0', options=None):
if checkpoint is not None:
map_loc = 'cpu' if device == 'cpu' else None
checkpoint = load_checkpoint(model, checkpoint, map_location=map_loc)
if 'CLASSES' in checkpoint['meta']:
if 'CLASSES' in checkpoint.get('meta', {}):
model.CLASSES = checkpoint['meta']['CLASSES']
else:
from mmcls.datasets import ImageNet

View File

@ -111,7 +111,7 @@ def main():
wrap_fp16_model(model)
checkpoint = load_checkpoint(model, args.checkpoint, map_location='cpu')
if 'CLASSES' in checkpoint['meta']:
if 'CLASSES' in checkpoint.get('meta', {}):
CLASSES = checkpoint['meta']['CLASSES']
else:
from mmcls.datasets import ImageNet