MCPcopy Create free account
hub / github.com/VCIP-RGBD/DFormer / __init__

Method __init__

mmseg/models/utils/embed.py:105–174  ·  view source on GitHub ↗
(
        self,
        in_channels=3,
        embed_dims=768,
        conv_type="Conv2d",
        kernel_size=16,
        stride=None,
        padding="corner",
        dilation=1,
        bias=True,
        norm_cfg=None,
        input_size=None,
        init_cfg=None,
    )

Source from the content-addressed store, hash-verified

103 """
104
105 def __init__(
106 self,
107 in_channels=3,
108 embed_dims=768,
109 conv_type="Conv2d",
110 kernel_size=16,
111 stride=None,
112 padding="corner",
113 dilation=1,
114 bias=True,
115 norm_cfg=None,
116 input_size=None,
117 init_cfg=None,
118 ):
119 super(PatchEmbed, self).__init__(init_cfg=init_cfg)
120
121 self.embed_dims = embed_dims
122 if stride is None:
123 stride = kernel_size
124
125 kernel_size = to_2tuple(kernel_size)
126 stride = to_2tuple(stride)
127 dilation = to_2tuple(dilation)
128
129 if isinstance(padding, str):
130 self.adap_padding = AdaptivePadding(
131 kernel_size=kernel_size, stride=stride, dilation=dilation, padding=padding
132 )
133 # disable the padding of conv
134 padding = 0
135 else:
136 self.adap_padding = None
137 padding = to_2tuple(padding)
138
139 self.projection = build_conv_layer(
140 dict(type=conv_type),
141 in_channels=in_channels,
142 out_channels=embed_dims,
143 kernel_size=kernel_size,
144 stride=stride,
145 padding=padding,
146 dilation=dilation,
147 bias=bias,
148 )
149
150 if norm_cfg is not None:
151 self.norm = build_norm_layer(norm_cfg, embed_dims)[1]
152 else:
153 self.norm = None
154
155 if input_size:
156 input_size = to_2tuple(input_size)
157 # `init_out_size` would be used outside to
158 # calculate the num_patches
159 # when `use_abs_pos_embed` outside
160 self.init_input_size = input_size
161 if self.adap_padding:
162 pad_h, pad_w = self.adap_padding.get_pad_shape(input_size)

Callers 2

__init__Method · 0.45
__init__Method · 0.45

Calls 2

AdaptivePaddingClass · 0.85
get_pad_shapeMethod · 0.80

Tested by

no test coverage detected