backbone = build_backbone(backbone) if neck is not None: self.neck = build_neck(neck) self.bbox_head = build_head(bbox_head) def forward_train(---): # 先运行backbone+neck进行特征提取 x = self.extract_feat(img) #对head进行forward train,输出loss losses = self.bbox_head.forward_...
在train.py中,通过build_detector来构建模型, python tools/train.py configs/pascal_voc/faster_rcnn_r50_fpn_1x_voc0712.py 1. build_detector的定义如下,最后通过build_from_cfg来构建模型,这里看到了让人困惑的Registry. from mmdet.cv_core.utils import Registry, build_from_cfg from torch import nn B...
builder.py依据mmcv.utils中的build_from_cfg定义了build_backbone,build_detector,build_head, build_...
backbone, neck=None, rpn_head=None, roi_head=None, train_cfg=None, test_cfg=None, pretrained=None): super(TwoStageDetector, self).__init__() self.backbone=build_backbone(backbone)ifneckisnotNone: self.neck=build_neck(neck)ifrpn_headisnotNone: rpn_train_cfg= train_cfg.rpniftrain_cfgi...
return build(cfg, BACKBONES) ##mmdet/utils/registry.py 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...
所以build_detector()函数的作用就是根据dict中的type找到对应的类,然后使用dict中传入的参数来对类进行初始化操作,并返回这个类的句柄。 # 下面两行调用是等价的 model = build_detector(Config{type='RetinaNet', backbone=xxx, neck=xxx, bbox_head=xxx}) model = RetinaNet(backbone=xxx, neck=xxx, bbox...
先看主要模型model,这里指定了backbone的结构,init_cfg为默认参数,后续载入模型会将其进行覆盖。 后面是train_pipeline和test_pipeline,定义了数据预处理的各种方式。 最后看第一行的_base_,这里相当于引用了另一个文件./faster_rcnn_r50_fpn_1x_coco.py的内容 ...
backbone, neck=None, rpn_head=None, roi_head=None, train_cfg=None, test_cfg=None, pretrained=None): super(TwoStageDetector, self).__init__() self.backbone=build_backbone(backbone)ifneckisnotNone: self.neck=build_neck(neck)ifrpn_headisnotNone: ...
解读数据集载入流程 根据配置文件构建数据集。配置文件内含标注文件路径、类别、类别ID、图片信息路径等信息,其中包含coco变量,存储标注信息,如类别与图片归类、框框与图片归类、图片信息等。另有meta变量,存储环境信息、配置文件名称与完整配置;model变量则构建backbone、neck、roi_head、rpn_head等网络层...
这里可以这样理解,之前backbone的输出是多层的特征图,这里对每层的输出用不同的ConvModule来处理,再统一channel数,就完成了高低层特征的融合。可能比较绕,结合代码就比较好理解了。 下面是forward函数部分代码。 # build lateralslaterals=[lateral_conv(inputs[i+self.start_level])fori,lateral_convinenumerate(self...