(self, x)
| 38 | self.norm = norm_layer(embed_dim) if norm_layer else nn.Identity() |
| 39 | |
| 40 | def forward(self, x): |
| 41 | B, C, H, W = x.shape |
| 42 | _assert(H == self.img_size[0], f"Input image height ({H}) doesn't match model ({self.img_size[0]}).") |
| 43 | _assert(W == self.img_size[1], f"Input image width ({W}) doesn't match model ({self.img_size[1]}).") |
| 44 | x = self.proj(x) |
| 45 | if self.flatten: |
| 46 | x = x.flatten(2).transpose(1, 2) # BCHW -> BNC |
| 47 | x = self.norm(x) |
| 48 | return x |