MCPcopy Create free account
hub / github.com/thygate/stable-diffusion-webui-depthmap-script / PatchEmbed

Class PatchEmbed

dmidas/backbones/next_vit.py:106–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104
105
106class PatchEmbed(nn.Module):
107 def __init__(self,
108 in_channels,
109 out_channels,
110 stride=1):
111 super(PatchEmbed, self).__init__()
112 norm_layer = partial(nn.BatchNorm2d, eps=NORM_EPS)
113 if stride == 2:
114 self.avgpool = nn.AvgPool2d((2, 2), stride=2, ceil_mode=True, count_include_pad=False)
115 self.conv = nn.Conv2d(in_channels, out_channels, kernel_size=1, stride=1, bias=False)
116 self.norm = norm_layer(out_channels)
117 elif in_channels != out_channels:
118 self.avgpool = nn.Identity()
119 self.conv = nn.Conv2d(in_channels, out_channels, kernel_size=1, stride=1, bias=False)
120 self.norm = norm_layer(out_channels)
121 else:
122 self.avgpool = nn.Identity()
123 self.conv = nn.Identity()
124 self.norm = nn.Identity()
125
126 def forward(self, x):
127 return self.norm(self.conv(self.avgpool(x)))
128
129
130class MHCA(nn.Module):

Callers 2

__init__Method · 0.70
__init__Method · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected