File size: 413 Bytes
952a07a
de33293
952a07a
de33293
952a07a
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
import os
import pickle

# teste = pickle.load(open("df_to_search.pkl","rb"))
def calculate_similarity():
    image_features = embeddings[ModalityType.VISION]
    text_features = embeddings[ModalityType.TEXT]

    image_features /= image_features.norm(dim=-1, keepdim=True)
    text_features /= text_features.norm(dim=-1, keepdim=True)
    similarity = text_features.cpu().numpy() @ image_features.cpu().numpy().T