Hugging Face
Models
Datasets
Spaces
Posts
Docs
Solutions
Pricing
Log In
Sign Up
Spaces:
vinid
/
webplip
like
28
Running
App
Files
Files
Community
12
7987133
webplip
/
plip_support.py
vinid
Upload plip_support.py
21847fd
over 1 year ago
raw
Copy download link
history
blame
No virus
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
]