• mmdetection3d


    https://mmdetection3d.readthedocs.io/zh_CN/latest/user_guides/data_pipeline.html

    https://betheme.net/houduan/31648.html?action=onClick

    Examples:
            >>> # define a registry
            >>> MODELS = Registry('models')
            >>> # registry the `ResNet` to `MODELS`
            >>> @MODELS.register_module()
            >>> class ResNet:
            >>>     pass
            >>> # build model from `MODELS`
            >>> resnet = MODELS.build(dict(type='ResNet'))
            >>> @MODELS.register_module()
            >>> def resnet50():
            >>>     pass
            >>> resnet = MODELS.build(dict(type='resnet50'))
    
            >>> # hierarchical registry
            >>> DETECTORS = Registry('detectors', parent=MODELS, scope='det')
            >>> @DETECTORS.register_module()
            >>> class FasterRCNN:
            >>>     pass
            >>> fasterrcnn = DETECTORS.build(dict(type='FasterRCNN'))
    
            >>> # add locations to enable auto import
            >>> DETECTORS = Registry('detectors', parent=MODELS,
            >>>     scope='det', locations=['det.models.detectors'])
            >>> # define this class in 'det.models.detectors'
            >>> @DETECTORS.register_module()
            >>> class MaskRCNN:
            >>>     pass
            >>> # The registry will auto import det.models.detectors.MaskRCNN
            >>> fasterrcnn = DETECTORS.build(dict(type='det.MaskRCNN'))
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31

    /root/miniconda3/lib/python3.8/site-packages/mmengine/registry/registry.py

    Examples:
                >>> # define a registry
                >>> MODELS = Registry('models')
                >>> # register `ResNet` to `MODELS`
                >>> @MODELS.register_module()
                >>> class ResNet:
                >>>     pass
                >>> resnet_cls = MODELS.get('ResNet')
    
                >>> # hierarchical registry
                >>> DETECTORS = Registry('detector', parent=MODELS, scope='det')
                >>> # `ResNet` does not exist in `DETECTORS` but `get` method
                >>> # will try to search from its parents or ancestors
                >>> resnet_cls = DETECTORS.get('ResNet')
                >>> CLASSIFIER = Registry('classifier', parent=MODELS, scope='cls')
                >>> @CLASSIFIER.register_module()
                >>> class MobileNet:
                >>>     pass
                >>> # `get` from its sibling registries
                >>> mobilenet_cls = DETECTORS.get('cls.MobileNet')
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20

    build model:

    model = MODELS.build(cfg.model)
    def build(self, cfg: dict, *args, **kwargs) -> Any:
            """Build an instance.
    
            Build an instance by calling :attr:`build_func`.
    
            Args:
                cfg (dict): Config dict needs to be built.
    
            Returns:
                Any: The constructed object.
    
            Examples:
                >>> from mmengine import Registry
                >>> MODELS = Registry('models')
                >>> @MODELS.register_module()
                >>> class ResNet:
                >>>     def __init__(self, depth, stages=4):
                >>>         self.depth = depth
                >>>         self.stages = stages
                >>> cfg = dict(type='ResNet', depth=50)
                >>> model = MODELS.build(cfg)
            """
            return self.build_func(cfg, *args, **kwargs, registry=self)
    
    def build_model_from_cfg(
        cfg: Union[dict, ConfigDict, Config],
        registry: Registry,
        default_args: Optional[Union[dict, 'ConfigDict', 'Config']] = None
    ) -> 'nn.Module':
        """Build a PyTorch model from config dict(s). Different from
        ``build_from_cfg``, if cfg is a list, a ``nn.Sequential`` will be built.
    
        Args:
            cfg (dict, list[dict]): The config of modules, which is either a config
                dict or a list of config dicts. If cfg is a list, the built
                modules will be wrapped with ``nn.Sequential``.
            registry (:obj:`Registry`): A registry the module belongs to.
            default_args (dict, optional): Default arguments to build the module.
                Defaults to None.
    
        Returns:
            nn.Module: A built nn.Module.
        """
        from ..model import Sequential
        if isinstance(cfg, list):
            modules = [
                build_from_cfg(_cfg, registry, default_args) for _cfg in cfg
            ]
            return Sequential(*modules)
        else:
            return build_from_cfg(cfg, registry, default_args)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
  • 相关阅读:
    软件测试 -- 入门 3 软件测试与质量
    Raft协议浅析
    Java SE 9 模块化示例
    C++11之空指针-nullptr
    【目录】RV1103/RV1106开发记录
    146.LRU缓存--hash-双链表
    正厚软件 | jdk的安装和环境变量配置总结
    Pyecharts数据可视化(一)
    关于fastdds相关问题
    linux 基础命令 cd /xxx 和 cd xxx 的区别
  • 原文地址:https://blog.csdn.net/phily123/article/details/133976836