FeaturePyramidNetwork¶
- class torchvision.ops.FeaturePyramidNetwork(in_channels_list: List[int], out_channels: int, extra_blocks: Optional[ExtraFPNBlock] = None, norm_layer: Optional[Callable[[...], Module]] = None)[source]¶
一个模块,用于在一组特征图之上添加 FPN。这基于论文《用于目标检测的特征金字塔网络》。
特征图目前应按深度递增的顺序排列。
模型的输入应为 OrderedDict[Tensor] 类型,其中包含将添加 FPN 的特征图。
- 参数:
示例
>>> m = torchvision.ops.FeaturePyramidNetwork([10, 20, 30], 5) >>> # get some dummy data >>> x = OrderedDict() >>> x['feat0'] = torch.rand(1, 10, 64, 64) >>> x['feat2'] = torch.rand(1, 20, 16, 16) >>> x['feat3'] = torch.rand(1, 30, 8, 8) >>> # compute the FPN on top of x >>> output = m(x) >>> print([(k, v.shape) for k, v in output.items()]) >>> # returns >>> [('feat0', torch.Size([1, 5, 64, 64])), >>> ('feat2', torch.Size([1, 5, 16, 16])), >>> ('feat3', torch.Size([1, 5, 8, 8]))]
- forward(x: Dict[str, Tensor]) Dict[str, Tensor] [source]¶
计算一组特征图的 FPN。
- 参数:
x (OrderedDict[Tensor]) – 每个特征层的特征图。
- 返回:
- 经过 FPN 层处理后的特征图。
它们按分辨率从高到低排序。
- 返回类型:
results (OrderedDict[Tensor])