From 67d096d580e15c9795964b3739b696c4595284d1 Mon Sep 17 00:00:00 2001 From: inter Date: Sun, 21 Sep 2025 20:18:53 +0800 Subject: [PATCH] Add File --- .../SemanticSeg/basic_blocks.py | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 pcdet/models/backbones_3d/focal_sparse_conv/SemanticSeg/basic_blocks.py diff --git a/pcdet/models/backbones_3d/focal_sparse_conv/SemanticSeg/basic_blocks.py b/pcdet/models/backbones_3d/focal_sparse_conv/SemanticSeg/basic_blocks.py new file mode 100644 index 0000000..de29b4b --- /dev/null +++ b/pcdet/models/backbones_3d/focal_sparse_conv/SemanticSeg/basic_blocks.py @@ -0,0 +1,65 @@ +import torch.nn as nn + +class BasicBlock1D(nn.Module): + + def __init__(self, in_channels, out_channels, **kwargs): + """ + Initializes convolutional block + Args: + in_channels: int, Number of input channels + out_channels: int, Number of output channels + **kwargs: Dict, Extra arguments for nn.Conv2d + """ + super().__init__() + self.in_channels = in_channels + self.out_channels = out_channels + self.conv = nn.Conv1d(in_channels=in_channels, + out_channels=out_channels, + **kwargs) + self.bn = nn.BatchNorm1d(out_channels) + self.relu = nn.ReLU(inplace=True) + + def forward(self, features): + """ + Applies convolutional block + Args: + features: (B, C_in, H, W), Input features + Returns: + x: (B, C_out, H, W), Output features + """ + x = self.conv(features) + x = self.bn(x) + x = self.relu(x) + return x + +class BasicBlock2D(nn.Module): + + def __init__(self, in_channels, out_channels, **kwargs): + """ + Initializes convolutional block + Args: + in_channels: int, Number of input channels + out_channels: int, Number of output channels + **kwargs: Dict, Extra arguments for nn.Conv2d + """ + super().__init__() + self.in_channels = in_channels + self.out_channels = out_channels + self.conv = nn.Conv2d(in_channels=in_channels, + out_channels=out_channels, + **kwargs) + self.bn = nn.BatchNorm2d(out_channels) + self.relu = nn.ReLU(inplace=True) + + def forward(self, features): + """ + Applies convolutional block + Args: + features: (B, C_in, H, W), Input features + Returns: + x: (B, C_out, H, W), Output features + """ + x = self.conv(features) + x = self.bn(x) + x = self.relu(x) + return x