参考自
https://github.com/lufficc/SSD
https://github.com/eriklindernoren/PyTorch-YOLOv3
https://blog.csdn.net/BlowfishKing/article/details/80485006
https://zhuanlan.zhihu.com/p/63630903
1.对于特征的混合
首先看SSD的模型
class SSDDetector(nn.Module):
def __init__(self, cfg):
super().__init__()
self.cfg = cfg
self.backbone = build_backbone(cfg)
self.box_head = build_box_head(cfg)
def forward(self, images, targets=None):
features = self.backbone(images)
detections, detector_losses = self.box_head(features, targets)
if self.training:
return detector_losses
return detections
backbone以后直接接box_head了
看一下box_hea.py的代码
def cls_block(self, level, out_channels, boxes_per_location):
return nn.Conv2d(out_channels, boxes_per_location * self.cfg.MODEL.NUM_CLASSES, kernel_size=3, stride=1, padding=1)
def reg_block(self, level, out_channels, boxes_per_location):
return nn.Conv2d(out_channels, boxes_per_location * 4, kernel_size=3, stride=1, padding=1)
直接接头了,并没有做多尺度特征混合
再看一下YOLO V3的模型
elif module_def["type"] == "route":
layers = [int(x) for x in module_def["layers"].split(",")]
filters = sum([output_filters[1:][i] for i in layers])
modules.add_module(f"route_{module_i}", EmptyLayer())