Hugging Face
Models
Datasets
Spaces
Posts
Docs
Solutions
Pricing
Log In
Sign Up
Spaces:
vinid
/
webplip
like
28
Runtime error
App
Files
Files
Community
12
dc3cb2a
webplip
/
plip_support.py
vinid
Upload plip_support.py
21847fd
over 1 year 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
]