vis4d.op.layer.csp_layer

Cross Stage Partial Layer.

Modified from mmdetection (https://github.com/open-mmlab/mmdetection).

Classes

CSPLayer(in_channels, out_channels[, ...])

Cross Stage Partial Layer.

DarknetBottleneck(in_channels, out_channels)

The basic bottleneck block used in Darknet.

class CSPLayer(in_channels, out_channels, expand_ratio=0.5, num_blocks=1, add_identity=True)[source]

Cross Stage Partial Layer.

Parameters:
  • in_channels (int) – The input channels of the CSP layer.

  • out_channels (int) – The output channels of the CSP layer.

  • expand_ratio (float, optional) – Ratio to adjust the number of channels of the hidden layer. Defaults to 0.5.

  • num_blocks (int, optional) – Number of blocks. Defaults to 1.

  • add_identity (bool, optional) – Whether to add identity in blocks. Defaults to True.

Init.

forward(features)[source]

Forward pass.

Parameters:

features (torch.Tensor) – Input features.

Return type:

Tensor

class DarknetBottleneck(in_channels, out_channels, expansion=0.5, add_identity=True)[source]

The basic bottleneck block used in Darknet.

Each ResBlock consists of two Conv blocks and the input is added to the final output. Each block is composed of Conv, BN, and SiLU. The first convolutional layer has filter size of 1x1 and the second one has filter size of 3x3.

Parameters:
  • in_channels (int) – The input channels of this Module.

  • out_channels (int) – The output channels of this Module.

  • expansion (float, optional) – The kernel size of the convolution. Defaults to 0.5.

  • add_identity (bool, optional) – Whether to add identity to the output. Defaults to True.

Init.

forward(features)[source]

Forward pass.

Parameters:

features (torch.Tensor) – Input features.

Return type:

Tensor