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

Method __init__

semantic_sam/backbone/focal.py:214–262  ·  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
        )

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

__init__Method · 0.45

Tested by

no test coverage detected