实施 Faster R-CNN 对象检测算法时出错

Error while implenting the Faster R-CNN Object detection algorithm

我正在尝试实施 Faster R-CNN 对象检测算法,但出现异常错误。 尝试在此 colab tutorial I had an error in the loss_dict = model(images, targets)which is mentioned here 中调用 train_one_epoch 函数时。 我遇到的确切错误是:

    101         cell_anchors = self.cell_anchors
    102         assert cell_anchors is not None
--> 103         assert len(grid_sizes) == len(strides) == len(cell_anchors)
    104 
    105         for size, stride, base_anchors in zip(

AssertionError:

有人有想法吗?提前致谢!

最后,我解决了这个问题,只是通过在 Faster R-CNN 函数中添加调整 AnchorGenerator 的大小及其对应的纵横比

ft_anchor_generator = AnchorGenerator(
    sizes=((32, 64, 128),), aspect_ratios=((0.5, 1.0, 2.0),)
)
ft_model = FasterRCNN(
    backbone=ft_backbone,
    num_classes=num_classes,
    rpn_anchor_generator=ft_anchor_generator)