MCPcopy Create free account
hub / github.com/SLDGroup/MERIT / CASCADE_Add

Class CASCADE_Add

lib/decoders.py:188–266  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

186
187
188class CASCADE_Add(nn.Module):
189 def __init__(self, channels=[512,320,128,64]):
190 super(CASCADE_Add,self).__init__()
191
192 self.Conv_1x1 = nn.Conv2d(channels[0],channels[0],kernel_size=1,stride=1,padding=0)
193 self.ConvBlock4 = conv_block(ch_in=channels[0], ch_out=channels[0])
194
195 self.Up3 = up_conv(ch_in=channels[0],ch_out=channels[1])
196 self.AG3 = Attention_block(F_g=channels[1],F_l=channels[1],F_int=channels[2])
197 self.ConvBlock3 = conv_block(ch_in=channels[1], ch_out=channels[1])
198
199 self.Up2 = up_conv(ch_in=channels[1],ch_out=channels[2])
200 self.AG2 = Attention_block(F_g=channels[2],F_l=channels[2],F_int=channels[3])
201 self.ConvBlock2 = conv_block(ch_in=channels[2], ch_out=channels[2])
202
203 self.Up1 = up_conv(ch_in=channels[2],ch_out=channels[3])
204 self.AG1 = Attention_block(F_g=channels[3],F_l=channels[3],F_int=int(channels[3]/2))
205 self.ConvBlock1 = conv_block(ch_in=channels[3], ch_out=channels[3])
206
207 self.CA4 = ChannelAttention(channels[0])
208 self.CA3 = ChannelAttention(channels[1])
209 self.CA2 = ChannelAttention(channels[2])
210 self.CA1 = ChannelAttention(channels[3])
211
212 self.SA = SpatialAttention()
213
214 def forward(self,x, skips):
215
216 d4 = self.Conv_1x1(x)
217
218 # CAM4
219 d4 = self.CA4(d4)*d4
220 d4 = self.SA(d4)*d4
221 d4 = self.ConvBlock4(d4)
222
223 # upconv3
224 d3 = self.Up3(d4)
225
226 # AG3
227 x3 = self.AG3(g=d3,x=skips[0])
228
229 # aggregate 3
230 d3 = d3 + x3
231
232 # CAM3
233 d3 = self.CA3(d3)*d3
234 d3 = self.SA(d3)*d3
235 d3 = self.ConvBlock3(d3)
236
237 # upconv2
238 d2 = self.Up2(d3)
239
240 # AG2
241 x2 = self.AG2(g=d2,x=skips[1])
242
243 # aggregate 2
244 d2 = d2 + x2
245

Callers 6

__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected