此页面由 AI 自动翻译。查看英文原版
最后更新

本页目录

  • 类
  • CSPDownBlock
  • CSPUpBlock
  • PANDownBlockBase
  • PANUpBlockBase
  • RepDownBlock
  • RepUpBlock
Claude CodeCodexCursor
Luxonis 智能体工具包为你常用的编程智能体加载 Luxonis 上下文与技能,更快地基于 OAK 开发应用。
安装工具包
最后更新
Python API: luxonis_train.nodes.necks.reppan_neck.blocksRepPAN neck 的上采样和下采样块。

类

CSPDownBlock

RepPANNeck 的自下而上融合步骤,带有一个 CSP 块。编码块是一个 CSPStackRepBlock,它将连接映射到 out_channels。当 block 为 "CSPStackRepBlock" 时,RepPANNeck 使用此步骤,如 "m" 和 "l" 变体所示。

方法

init
Python
1def __init__(in_channels: int, downsample_out_channels: int, in_channels_next: int, out_channels: int, n_repeats: int, e: float):
初始化下采样层和 CSP 块。参数
  • in_channels (int): 精细输入的通道数。
  • downsample_out_channels (int): 下采样卷积后的通道数。
  • in_channels_next (int): 横向输入的通道数,该步骤将其连接。
  • out_channels (int): 输出通道数。
  • n_repeats (int): 控制 CSPStackRepBlock 中 RepVGG 风格块的数量。每个 BottleRep 包含两个,因此堆栈有 max(1, n_repeats // 2) 个 BottleRep 块和 2 * max(1, n_repeats // 2) 个 RepVGG 风格块。
  • e (float): CSPStackRepBlock 的两条路径中 out_channels 的分数。

CSPUpBlock

RepPANNeck 的自上而下融合步骤,带有一个 CSP 块。编码块是一个 CSPStackRepBlock,它将连接映射到 out_channels。当 block 为 "CSPStackRepBlock" 时,RepPANNeck 使用此步骤,如 "m" 和 "l" 变体所示。

方法

init
Python
1def __init__(in_channels: int, in_channels_next: int, out_channels: int, n_repeats: int, e: float):
初始化上采样层和 CSP 块。参数
  • in_channels (int): 粗略输入的通道数。
  • in_channels_next (int): 更精细输入的通道数,该步骤将其连接。
  • out_channels (int): 输出通道数。
  • n_repeats (int): 控制 CSPStackRepBlock 中 RepVGG 风格块的数量。每个 BottleRep 包含两个,因此堆栈有 max(1, n_repeats // 2) 个 BottleRep 块和 2 * max(1, n_repeats // 2) 个 RepVGG 风格块。
  • e (float): CSPStackRepBlock 的两条路径中 out_channels 的分数。

PANDownBlockBase

RepPANNeck 的自下而上融合步骤的基类。一个 3x3 ConvBlock,步长为 2,填充为 1,带批量归一化和 ReLU,将精细输入的高度和宽度减半。奇数尺寸向上取整。该块将结果与横向输入沿通道轴连接,并对其运行 encode_block。子类选择 encode_block。

方法

init
Python
1def __init__(in_channels: int, downsample_out_channels: int, encode_block: nn.Module):
初始化下采样卷积。参数
  • in_channels (int): 精细输入的通道数。
  • downsample_out_channels (int): 下采样卷积后的通道数。
  • encode_block (nn.Module): 在连接上运行的块。其输入具有 downsample_out_channels 加上横向输入的通道数。
forward
Python
1def forward(x0: Tensor, x1: Tensor) -> Tensor:
下采样精细图并将其与横向图融合。参数
  • x0 (Tensor): 形状为 [B, in_channels, H, W] 的精细图。
  • x1 (Tensor): 形状为 [B, C1, H / 2, W / 2] 的横向图。奇数 H 或 W 向上取整。在子类中,C1 是 in_channels_next。
返回
  • Tensor: encode_block 的输出。在子类中,其形状为 [B, out_channels, H / 2, W / 2]。

属性

downsample
encode_block

PANUpBlockBase

RepPANNeck 的自上而下融合步骤的基类。一个 1x1 ConvBlock,带批量归一化和 ReLU,将粗略输入映射到 out_channels。然后,一个步长为 2 的 2x2 转置卷积将高度和宽度加倍。该块将结果与更精细的输入沿通道轴连接,并对其运行 encode_block。子类选择 encode_block。

方法

init
Python
1def __init__(in_channels: int, out_channels: int, encode_block: nn.Module):
构建 1x1 卷积和上采样层。参数
  • in_channels (int): 粗略输入的通道数。
  • out_channels (int): 1x1 卷积后的通道数。上采样层保持此数量。
  • encode_block (nn.Module): 在连接上运行的块。其输入具有 out_channels 加上更精细输入的通道数。
forward
Python
1def forward(x0: Tensor, x1: Tensor) -> tuple[Tensor, Tensor]:
上采样粗略图并将其与更精细图融合。参数
  • x0 (Tensor): 形状为 [B, in_channels, H, W] 的粗略图。
  • x1 (Tensor): 形状为 [B, C1, 2 * H, 2 * W] 的更精细图。在子类中,C1 是 in_channels_next。
返回
  • tuple[Tensor, Tensor]: 元组 (conv_out, out)。conv_out 是 1x1 卷积的输出,形状为 [B, out_channels, H, W]。RepPANNeck 将其作为横向输入提供给自下而上步骤。out 是 encode_block 的输出。在子类中,out 的形状为 [B, out_channels, 2 * H, 2 * W]。

属性

conv
encode_block
upsample

RepDownBlock

RepPANNeck 的自下而上融合步骤,带 RepVGG 风格块。编码块是 n_repeats 个 GeneralReparameterizableBlock 层的 BlockRepeater。第一层将连接映射到 out_channels。其他层保持该数量。当 block 为 "RepBlock" 时,RepPANNeck 使用此步骤,如 "n" 和 "s" 变体所示。

方法

init
Python
1def __init__(in_channels: int, downsample_out_channels: int, in_channels_next: int, out_channels: int, n_repeats: int):
初始化下采样层和 RepVGG 风格堆栈。参数
  • in_channels (int): 精细输入的通道数。
  • downsample_out_channels (int): 下采样卷积后的通道数。
  • in_channels_next (int): 横向输入的通道数,该步骤将其连接。
  • out_channels (int): 输出通道数。
  • n_repeats (int): GeneralReparameterizableBlock 层的数量。小于 1 的值仍会构建一层。

RepUpBlock

RepPANNeck 的自上而下融合步骤,带 RepVGG 风格块。编码块是 n_repeats 个 GeneralReparameterizableBlock 层的 BlockRepeater。第一层将连接映射到 out_channels。其他层保持该数量。当 block 为 "RepBlock" 时,RepPANNeck 使用此步骤,如 "n" 和 "s" 变体所示。

方法

init
Python
1def __init__(in_channels: int, in_channels_next: int, out_channels: int, n_repeats: int):
初始化上采样层和 RepVGG 风格堆栈。参数
  • in_channels (int): 粗略输入的通道数。
  • in_channels_next (int): 更精细输入的通道数,该步骤将其连接。
  • out_channels (int): 输出通道数。
  • n_repeats (int): GeneralReparameterizableBlock 层的数量。小于 1 的值仍会构建一层。