MCPcopy Create free account
hub / github.com/UX-Decoder/Semantic-SAM / __init__

Method __init__

semantic_sam/backbone/focal_dw.py:223–273  ·  view source on GitHub ↗
(self,
                 dim,
                 depth,
                 mlp_ratio=4.,
                 drop=0.,
                 drop_path=0.,
                 norm_layer=nn.LayerNorm,
                 downsample=None,
                 focal_window=9, 
                 focal_level=2, 
                 use_conv_embed=False,     
                 use_postln=False,          
                 use_postln_in_modulation=False, 
                 scaling_modulator=False,
                 use_layerscale=False,                   
                 use_checkpoint=False, 
                 use_pre_norm=False, 
        )

Source from the content-addressed store, hash-verified

221 """
222
223 def __init__(self,
224 dim,
225 depth,
226 mlp_ratio=4.,
227 drop=0.,
228 drop_path=0.,
229 norm_layer=nn.LayerNorm,
230 downsample=None,
231 focal_window=9,
232 focal_level=2,
233 use_conv_embed=False,
234 use_postln=False,
235 use_postln_in_modulation=False,
236 scaling_modulator=False,
237 use_layerscale=False,
238 use_checkpoint=False,
239 use_pre_norm=False,
240 ):
241 super().__init__()
242 self.depth = depth
243 self.use_checkpoint = use_checkpoint
244
245 # build blocks
246 self.blocks = nn.ModuleList([
247 FocalModulationBlock(
248 dim=dim,
249 mlp_ratio=mlp_ratio,
250 drop=drop,
251 drop_path=drop_path[i] if isinstance(drop_path, list) else drop_path,
252 focal_window=focal_window,
253 focal_level=focal_level,
254 use_postln=use_postln,
255 use_postln_in_modulation=use_postln_in_modulation,
256 scaling_modulator=scaling_modulator,
257 use_layerscale=use_layerscale,
258 norm_layer=norm_layer)
259 for i in range(depth)])
260
261 # patch merging layer
262 if downsample is not None:
263 self.downsample = downsample(
264 patch_size=2,
265 in_chans=dim, embed_dim=2*dim,
266 use_conv_embed=use_conv_embed,
267 norm_layer=norm_layer,
268 is_stem=False,
269 use_pre_norm=use_pre_norm
270 )
271
272 else:
273 self.downsample = None
274
275 def forward(self, x, H, W):
276 """ Forward function.

Callers

nothing calls this directly

Calls 2

__init__Method · 0.45

Tested by

no test coverage detected