(fp_blocks, in_channels, sa_in_channels, embed_dim=64, use_att=False,
dropout=0.1,
with_se=False, normalize=True, eps=0,
width_multiplier=1, voxel_resolution_multiplier=1)
| 131 | |
| 132 | |
| 133 | def create_pointnet2_fp_modules(fp_blocks, in_channels, sa_in_channels, embed_dim=64, use_att=False, |
| 134 | dropout=0.1, |
| 135 | with_se=False, normalize=True, eps=0, |
| 136 | width_multiplier=1, voxel_resolution_multiplier=1): |
| 137 | r, vr = width_multiplier, voxel_resolution_multiplier |
| 138 | |
| 139 | fp_layers = [] |
| 140 | c = 0 |
| 141 | for fp_idx, (fp_configs, conv_configs) in enumerate(fp_blocks): |
| 142 | fp_blocks = [] |
| 143 | out_channels = tuple(int(r * oc) for oc in fp_configs) |
| 144 | fp_blocks.append( |
| 145 | PointNetFPModule(in_channels=in_channels + sa_in_channels[-1 - fp_idx] + embed_dim, out_channels=out_channels) |
| 146 | ) |
| 147 | in_channels = out_channels[-1] |
| 148 | |
| 149 | if conv_configs is not None: |
| 150 | out_channels, num_blocks, voxel_resolution = conv_configs |
| 151 | out_channels = int(r * out_channels) |
| 152 | for p in range(num_blocks): |
| 153 | attention = (c+1) % 2 == 0 and c < len(fp_blocks) - 1 and use_att and p == 0 |
| 154 | if voxel_resolution is None: |
| 155 | block = SharedMLP |
| 156 | else: |
| 157 | block = functools.partial(PVConv, kernel_size=3, resolution=int(vr * voxel_resolution), attention=attention, |
| 158 | dropout=dropout, |
| 159 | with_se=with_se, with_se_relu=True, |
| 160 | normalize=normalize, eps=eps) |
| 161 | |
| 162 | fp_blocks.append(block(in_channels, out_channels)) |
| 163 | in_channels = out_channels |
| 164 | if len(fp_blocks) == 1: |
| 165 | fp_layers.append(fp_blocks[0]) |
| 166 | else: |
| 167 | fp_layers.append(nn.Sequential(*fp_blocks)) |
| 168 | |
| 169 | c += 1 |
| 170 | |
| 171 | return fp_layers, in_channels |
| 172 | |
| 173 | |
| 174 |
no test coverage detected