FeaturePyramidNetwork¶
- class torchvision.ops.FeaturePyramidNetwork(in_channels_list: list[int], out_channels: int, extra_blocks: Optional[ExtraFPNBlock] = None, norm_layer: Optional[Callable[[...], Module]] = None)[源代码]¶
一个在特征图集合之上添加 FPN 的模块。该模块基于 “Feature Pyramid Network for Object Detection”。
目前假定特征图按深度递增顺序排列。
模型的输入预计为一个 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, torch.Tensor]) dict[str, torch.Tensor] [源代码]¶
计算一组特征图的 FPN。
- 参数:
x (OrderedDict[Tensor]) – 每个特征级别的特征图。
- 返回:
- FPN 层之后的特征图。
它们按分辨率从高到低排序。
- 返回类型:
results (OrderedDict[Tensor])