MCPcopy Create free account
hub / github.com/alinlab/SelfPatch / InterpConv

Class InterpConv

segmentation/backbones/unet.py:151–221  ·  view source on GitHub ↗

Interpolation upsample module in decoder for UNet. This module uses interpolation to upsample feature map in the decoder of UNet. It consists of one interpolation upsample layer and one convolutional layer. It can be one interpolation upsample layer followed by one convolutional lay

Source from the content-addressed store, hash-verified

149
150@UPSAMPLE_LAYERS.register_module()
151class InterpConv(nn.Module):
152 """Interpolation upsample module in decoder for UNet.
153
154 This module uses interpolation to upsample feature map in the decoder
155 of UNet. It consists of one interpolation upsample layer and one
156 convolutional layer. It can be one interpolation upsample layer followed
157 by one convolutional layer (conv_first=False) or one convolutional layer
158 followed by one interpolation upsample layer (conv_first=True).
159
160 Args:
161 in_channels (int): Number of input channels.
162 out_channels (int): Number of output channels.
163 with_cp (bool): Use checkpoint or not. Using checkpoint will save some
164 memory while slowing down the training speed. Default: False.
165 norm_cfg (dict | None): Config dict for normalization layer.
166 Default: dict(type='BN').
167 act_cfg (dict | None): Config dict for activation layer in ConvModule.
168 Default: dict(type='ReLU').
169 conv_cfg (dict | None): Config dict for convolution layer.
170 Default: None.
171 conv_first (bool): Whether convolutional layer or interpolation
172 upsample layer first. Default: False. It means interpolation
173 upsample layer followed by one convolutional layer.
174 kernel_size (int): Kernel size of the convolutional layer. Default: 1.
175 stride (int): Stride of the convolutional layer. Default: 1.
176 padding (int): Padding of the convolutional layer. Default: 1.
177 upsample_cfg (dict): Interpolation config of the upsample layer.
178 Default: dict(
179 scale_factor=2, mode='bilinear', align_corners=False).
180 """
181
182 def __init__(self,
183 in_channels,
184 out_channels,
185 with_cp=False,
186 norm_cfg=dict(type='BN'),
187 act_cfg=dict(type='ReLU'),
188 *,
189 conv_cfg=None,
190 conv_first=False,
191 kernel_size=1,
192 stride=1,
193 padding=0,
194 upsample_cfg=dict(
195 scale_factor=2, mode='bilinear', align_corners=False)):
196 super(InterpConv, self).__init__()
197
198 self.with_cp = with_cp
199 conv = ConvModule(
200 in_channels,
201 out_channels,
202 kernel_size=kernel_size,
203 stride=stride,
204 padding=padding,
205 conv_cfg=conv_cfg,
206 norm_cfg=norm_cfg,
207 act_cfg=act_cfg)
208 upsample = Upsample(**upsample_cfg)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected