Skip to content

Commit

Permalink
compatible with new config
Browse files Browse the repository at this point in the history
  • Loading branch information
youqingxiaozhua committed Jan 22, 2024
1 parent 17a886c commit a3ffe2e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions mmpretrain/apis/model.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright (c) OpenMMLab. All rights reserved.
import copy
import inspect
import fnmatch
import os.path as osp
import re
Expand Down Expand Up @@ -207,8 +208,12 @@ def get_model(model: Union[str, Config],
dataset_meta = {'classes': checkpoint['meta']['CLASSES']}

if len(dataset_meta) == 0 and 'test_dataloader' in config:
from mmpretrain.registry import DATASETS
dataset_class = DATASETS.get(config.test_dataloader.dataset.type)
# compatible with new config
if inspect.isclass(config.test_dataloader.dataset.type):
dataset_class = config.test_dataloader.dataset.type
else:
from mmpretrain.registry import DATASETS
dataset_class = DATASETS.get(config.test_dataloader.dataset.type)
dataset_meta = getattr(dataset_class, 'METAINFO', {})

if device_map is not None:
Expand Down

0 comments on commit a3ffe2e

Please sign in to comment.