File size: 187 Bytes
21847fd
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
import clip
import torch




def embed_text(plip, text, device="cpu"):
    idx = clip.tokenize([text], truncate=True).to(device)
    return plip.encode_text(idx).detach().cpu().numpy()[0]