Hugging Face
Models
Datasets
Spaces
Posts
Docs
Enterprise
Pricing
Log In
Sign Up
Spaces:
vinid
/
webplip
like
28
Runtime error
App
Files
Files
Community
12
795ab43
webplip
/
plip_support.py
vinid
Upload plip_support.py
21847fd
almost 2 years ago
raw
Copy download link
history
blame
Safe
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
]