基于mmdetection框架
1.mmcv\cnn\builder.py:
注册一个创建模型的方式(这里是根据配置文件)
MODELS = Registry('model', build_func=build_model_from_cfg)
2.mmdet\models\builder.py:
DETECTORS = MODELS,
创建检测器入口
DETECTORS.build_detector(cfg, train_cfg=None, test_cfg=None)
3.DETECTORS.build( cfg, default_args=dict(train_cfg=train_cfg, test_cfg=test_cfg))
根据cfg配置文件创建检测器
4.build(self, args, **kwargs)--->self.build_func(args, **kwargs, registry=self) (注册时赋值build_func=build_model_from_cfg)
5.build_model_from_cfg(cfg, registry, default_args=None)-->build_from_cfg(cfg, registry, default_args)
6.第5步创建模型后,执行train_detector训练检测器模型
functional.py
更多:https://www.rdshx.cn/Video