FasterRCNN源码解析(八)——ROIheads部分

本文详细解析FasterRCNN中ROIheads部分,包括TwoMLPHead和FastRCNNPredictor。在TwoMLPHead中,对经过RoIPooling的特征进行全连接层处理。FastRCNNPredictor则利用TwoMLPHead的输出预测目标类别和边界框。在正向传播过程中,涉及样本筛选、Multi-scale RoIAlign、损失计算,并在训练和验证模式下有不同的操作。
摘要由CSDN通过智能技术生成

FasterRCNN源码解析(八)——ROIheads部分

本节所对应的部分有
在这里插入图片描述
在我们的faster_rcnn_framework.py中的FasterRCNN类中,有实例化ROIheads部分

# 将roi pooling, box_head以及box_predictor结合在一起
        roi_heads = RoIHeads(
            # box
            box_roi_pool, box_head, box_predictor, # 1对应图中ROIpooling 2 对应TwoMLPHead层 3 对应图中FastRCNNPredictor
            box_fg_iou_thresh, box_bg_iou_thresh, # 正负样本阈值0.5 0.5
            box_batch_size_per_image, box_positive_fraction, # 512  0.25
            bbox_reg_weights, # 超参数
            box_score_thresh, box_nms_thresh, box_detections_per_img) # 进行后处理的一些  阈值

在我们res50+FPN backbone中,box_roi_pool

box_roi_pool = MultiScaleRoIAlign(
                featmap_names=['0', '1', '2', '3'],  # 在哪些特征层进行roi pooling
                output_size=[7, 7],
                sampling_ratio=2)

box_head

			resolution = box_roi_pool.output_size[0]  # 默认等于7
            representation_size = 1024
            box_head = TwoMLPHead(
                out_channels * resolution ** 2,
                representation_size
            )

box_predictor

# 在box_head的输出上预测部分
        if box_predictor is None:
            representation_size = 1024
            box_predictor = FastRCNNPredictor(
                representation_size,
                num_classes)

一、TwoMLPHead

class 
  • 3
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值