retinanet之anchor
1.综述
anchor即目标检测的先验框,retinanet的anchor有scales和ratios,根据每个pyramid_levels生成三个scales,三个ratios,然后形成九种先验框。
scales:anchor的大小(宽)
ratios:anchor的宽高比
2.参数:pyramid_levels, strides, sizes, ratios, scales
class Anchors(nn.Module):
def __init__(self, pyramid_levels=None, strides=None, sizes=None, ratios=None, scales=None):
super(Anchors, self).__init__()
if pyramid_levels is None:
self.pyramid_levels = [3, 4, 5, 6, 7]
if strides is None:
self.strides = [2 ** x for x in self.pyramid_levels]
if sizes is None:
self.sizes = [2 ** (x + 2) for x in self.pyramid_levels]
if ratios is None:
self.ratios = np.array([0.5, 1, 2])
if scales is None:
self.scales = np.array([2 ** 0, 2 ** (1.0 / 3.0), 2 ** (2.0 / 3.0)])
pyramid_level:feature map标号,对应resnet的p3层到p7层
strides:滑窗的步长
size:窗口的宽
ratios:宽高比
scales:面积比例