vinid commited on
Commit
21847fd
1 Parent(s): af14fe8

Upload plip_support.py

Browse files
Files changed (1) hide show
  1. plip_support.py +9 -0
plip_support.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ import clip
2
+ import torch
3
+
4
+
5
+
6
+
7
+ def embed_text(plip, text, device="cpu"):
8
+ idx = clip.tokenize([text], truncate=True).to(device)
9
+ return plip.encode_text(idx).detach().cpu().numpy()[0]