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])