Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: 'module' object is not callable #133

Open
hessaAlawwad opened this issue Jan 26, 2025 · 0 comments
Open

TypeError: 'module' object is not callable #133

hessaAlawwad opened this issue Jan 26, 2025 · 0 comments

Comments

@hessaAlawwad
Copy link

Hello,

I am trying to do the following:

from imagebind import data
from imagebind.models import imagebind_model
from imagebind.models.imagebind_model import ModalityType

def getEmbeddingVector(inputs):
     with torch.no_grad():
         embedding = imagebind_model(inputs)
     for key, value in embedding.items():
         vec = value.reshape(-1)
         return(vec)

def imageToEmbedding(path, device):
     inputs = { ModalityType.VISION: data.load_and_transform_vision_data(path, device)  }
     vec = getEmbeddingVector(inputs)
     return(vec)

def textToEmbedding(txt, device):
     text_list = [txt]
     inputs = {ModalityType.TEXT: data.load_and_transform_text(text_list, device)}
     vec = getEmbeddingVector(inputs)
     return(vec)

    
if __name__ == "__main__":
    device = "cuda:0" if torch.cuda.is_available() else "mps" if torch.backends.mps.is_available() else "cpu"
    imagebind = imagebind_model.imagebind_huge(pretrained=False)
    checkpoint_path = "~/.checkpoints/imagebind_huge.pth"
    imagebind.load_state_dict(torch.load(checkpoint_path, map_location=device, weights_only=True))
    imagebind.eval()
    imagebind.to(device)

    txt_list = ['This is a cat']
    textToEmbedding(txt_list, device)

but I am getting the following error:

Traceback (most recent call last):
  File "~/jtr_tqa.py", line 442, in <module>
    textToEmbedding(txt_list, device)
  File "~/jtr_tqa.py", line 69, in textToEmbedding
    vec = getEmbeddingVector(inputs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/jtr_tqa.py", line 54, in getEmbeddingVector
    embedding = imagebind_model(inputs)
                ^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'module' object is not callable

please help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant