Disable dual patchnorm to support latest open_clip_torch

This commit is contained in:
kijai
2024-03-17 20:13:59 +02:00
parent 6630d27dcd
commit 30ad69fb91
2 changed files with 11 additions and 11 deletions
+10 -10
View File
@@ -343,17 +343,17 @@ class FrozenOpenCLIPImageEmbedderV2(AbstractEncoder):
x = self.preprocess(x)
# to patches - whether to use dual patchnorm - https://arxiv.org/abs/2302.01327v1
if self.model.visual.input_patchnorm:
#if self.model.visual.input_patchnorm:
# einops - rearrange(x, 'b c (h p1) (w p2) -> b (h w) (c p1 p2)')
x = x.reshape(x.shape[0], x.shape[1], self.model.visual.grid_size[0], self.model.visual.patch_size[0], self.model.visual.grid_size[1], self.model.visual.patch_size[1])
x = x.permute(0, 2, 4, 1, 3, 5)
x = x.reshape(x.shape[0], self.model.visual.grid_size[0] * self.model.visual.grid_size[1], -1)
x = self.model.visual.patchnorm_pre_ln(x)
x = self.model.visual.conv1(x)
else:
x = self.model.visual.conv1(x) # shape = [*, width, grid, grid]
x = x.reshape(x.shape[0], x.shape[1], -1) # shape = [*, width, grid ** 2]
x = x.permute(0, 2, 1) # shape = [*, grid ** 2, width]
# x = x.reshape(x.shape[0], x.shape[1], self.model.visual.grid_size[0], self.model.visual.patch_size[0], self.model.visual.grid_size[1], self.model.visual.patch_size[1])
# x = x.permute(0, 2, 4, 1, 3, 5)
# x = x.reshape(x.shape[0], self.model.visual.grid_size[0] * self.model.visual.grid_size[1], -1)
# x = self.model.visual.patchnorm_pre_ln(x)
# x = self.model.visual.conv1(x)
#else:
x = self.model.visual.conv1(x) # shape = [*, width, grid, grid]
x = x.reshape(x.shape[0], x.shape[1], -1) # shape = [*, width, grid ** 2]
x = x.permute(0, 2, 1) # shape = [*, grid ** 2, width]
# class embeddings and positional embeddings
x = torch.cat(
+1 -1
View File
@@ -6,5 +6,5 @@ pytorch_lightning>=1.8.3
tqdm>=4.65.0
transformers>=4.25.1
timm
open_clip_torch==2.12.0
open_clip_torch>=2.12.0
kornia