fixed open-clip-torch version

This commit is contained in:
VjumpKunG
2025-12-26 14:56:04 +07:00
parent a42ff77a7b
commit eb6597beba
2 changed files with 3 additions and 4 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ av
opencv-python
easydict
einops
open-clip-torch
open-clip-torch==2.20.0
fairscale
torchsde
pytorch-lightning
+2 -3
View File
@@ -1,6 +1,7 @@
# Copyright (c) Alibaba, Inc. and its affiliates.
import os
from functools import wraps
import numpy as np
import open_clip
@@ -60,9 +61,7 @@ class FrozenOpenCLIPEmbedder(nn.Module):
x = self.model.token_embedding(text)
x = x + self.model.positional_embedding
x = x.permute(1, 0, 2)
# Fix for PyTorch compatibility: use None for attn_mask to avoid shape mismatch errors
# The causal masking will be handled internally by the attention mechanism
x = self.text_transformer_forward(x, attn_mask=None)
x = self.text_transformer_forward(x, attn_mask=self.model.attn_mask)
x = x.permute(1, 0, 2)
x = self.model.ln_final(x)
return x