Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError: 'PointSetAnchorDetector is not in the detector registry' #77

Open
VIROBO-15 opened this issue Dec 15, 2020 · 0 comments
Open

Comments

@VIROBO-15
Copy link

VIROBO-15 commented Dec 15, 2020

def build_from_cfg(cfg, registry, default_args=None):
"""Build a module from config dict.

Args:
    cfg (dict): Config dict. It should at least contain the key "type".
    registry (:obj:`Registry`): The registry to search the type from.
    default_args (dict, optional): Default initialization arguments.

Returns:
    object: The constructed object.
"""
if not isinstance(cfg, dict):
    raise TypeError(f'cfg must be a dict, but got {type(cfg)}')
if 'type' not in cfg:
    if default_args is None or 'type' not in default_args:
        raise KeyError(
            '`cfg` or `default_args` must contain the key "type", '
            f'but got {cfg}\n{default_args}')
if not isinstance(registry, Registry):
    raise TypeError('registry must be an mmcv.Registry object, '
                    f'but got {type(registry)}')
if not (isinstance(default_args, dict) or default_args is None):
    raise TypeError('default_args must be a dict or None, '
                    f'but got {type(default_args)}')

args = cfg.copy()

if default_args is not None:
    for name, value in default_args.items():
        args.setdefault(name, value)

obj_type = args.pop('type')
if is_str(obj_type):
    obj_cls = registry.get(obj_type)
    if obj_cls is None:
        raise KeyError(
            f'{obj_type} is not in the {registry.name} registry')
elif inspect.isclass(obj_type):
    obj_cls = obj_type
else:
    raise TypeError(
        f'type must be a str or valid type, but got {type(obj_type)}')

return obj_cls(**args)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant