MinkEngine based 3D sparse conv neck. Actually here we implement both the sparse 3D FPN and a head. The neck and the head can not be simply separated as pruning score on the i-th level of FPN requires classification scores from i+1-th level of the head. Args: num_classes (i
| 19 | |
| 20 | @MODELS.register_module() |
| 21 | class MinkNeck(BaseModule): |
| 22 | """MinkEngine based 3D sparse conv neck. |
| 23 | |
| 24 | Actually here we implement both the sparse 3D FPN and a head. The neck and |
| 25 | the head can not be simply separated as pruning score on the i-th level |
| 26 | of FPN requires classification scores from i+1-th level of the head. |
| 27 | |
| 28 | Args: |
| 29 | num_classes (int): Number of classes. |
| 30 | in_channels (tuple(int)): Number of channels in input tensors. |
| 31 | out_channels (int): Number of channels in the neck output tensors. |
| 32 | voxel_size (float): Voxel size in meters. |
| 33 | pts_prune_threshold (int): Pruning threshold on each feature level. |
| 34 | train_cfg (dict, optional): Config for train stage. Defaults to None. |
| 35 | test_cfg (dict, optional): Config for test stage. Defaults to None. |
| 36 | init_cfg (dict, optional): Config for weight initialization. |
| 37 | Defaults to None. |
| 38 | """ |
| 39 | |
| 40 | def __init__( |
| 41 | self, |
| 42 | num_classes: int, # 1 |
| 43 | in_channels: Tuple[int], |
| 44 | out_channels: int, |
| 45 | voxel_size: float, |
| 46 | pts_prune_threshold: int, |
| 47 | train_cfg: Optional[dict] = None, |
| 48 | test_cfg: Optional[dict] = None, |
| 49 | init_cfg: Optional[dict] = None): |
| 50 | super(MinkNeck, self).__init__(init_cfg) |
| 51 | if ME is None: |
| 52 | raise ImportError( |
| 53 | 'Please follow `get_started.md` to install MinkowskiEngine.`') |
| 54 | self.voxel_size = voxel_size |
| 55 | self.pts_prune_threshold = pts_prune_threshold |
| 56 | self.train_cfg = train_cfg |
| 57 | self.test_cfg = test_cfg |
| 58 | self._init_layers(in_channels, out_channels, num_classes) |
| 59 | |
| 60 | @staticmethod |
| 61 | def _make_block(in_channels: int, out_channels: int) -> nn.Module: |
| 62 | """Construct Conv-Norm-Act block. |
| 63 | |
| 64 | Args: |
| 65 | in_channels (int): Number of input channels. |
| 66 | out_channels (int): Number of output channels. |
| 67 | |
| 68 | Returns: |
| 69 | torch.nn.Module: With corresponding layers. |
| 70 | """ |
| 71 | return nn.Sequential( |
| 72 | ME.MinkowskiConvolution(in_channels, |
| 73 | out_channels, |
| 74 | kernel_size=3, |
| 75 | dimension=3), |
| 76 | ME.MinkowskiBatchNorm(out_channels), ME.MinkowskiELU()) |
| 77 | |
| 78 | @staticmethod |
nothing calls this directly
no outgoing calls
no test coverage detected