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