无法在Faster RCNN中更改锚点

时间:2019-07-10 02:08:29

标签: pytorch faster-rcnn

我是pytorch的新手,我试图在pytorch的Faster RCNN网络中放置一些自定义锚。基本上,我使用的是resnet50主干,当我尝试放置锚点时,出现不匹配错误。

这是我的代码:

<StackLayout
        RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent,Property=Height,Factor=0.5,Constant=0}"
        RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width,Factor=1,Constant=0}">
    <Entry Text="pls input here" />

    <FlexLayout Direction="Row"
            AlignItems="Center"
            JustifyContent="SpaceEvenly">

        <Button Text="Button1" />
        <Button Text="Button2" />
        <Button Text="Button3" />
        <Button Text="Button4" />
        <Button Text="Button5" />

    </FlexLayout>

</StackLayout>

我得到的错误如下:形状'[1440000,-1]'对于大小为7674336的输入无效。

1 个答案:

答案 0 :(得分:0)

好的,在深入研究PyTorch Faster RCNN的源代码之后,我发现了它们如何初始化锚点:

anchor_sizes = ((32,), (64,), (128,), (256,), (512,))
            aspect_ratios = ((0.5, 1.0, 2.0),) * len(anchor_sizes)

rpn_anchor_generator = AnchorGenerator(
                anchor_sizes, aspect_ratios
            )

按照与我的自定义锚相同的模式,代码将为:

anchor_sizes = ((4,), (8,), (16,), (32,), (64,), (128,))
            aspect_ratios = ((0.5, 1.0, 2.0),) * len(anchor_sizes)

rpn_anchor_generator = AnchorGenerator(
                anchor_sizes, aspect_ratios
            )

它将起作用!