joe-siyuan-qiao / DetectoRS

DetectoRS: Detecting Objects with Recursive Feature Pyramid and Switchable Atrous Convolution
Apache License 2.0
1.13k stars 178 forks source link

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

Open VIROBO-15 opened 3 years ago

VIROBO-15 commented 3 years ago

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)