webplip / plip_support.py
vinid's picture
Upload plip_support.py
21847fd
raw
history blame
187 Bytes
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]