aboutsummaryrefslogtreecommitdiff
path: root/src/imgbeddings-api.py
diff options
context:
space:
mode:
authorLia Lenckowski <lialenck@protonmail.com>2023-09-07 01:37:34 +0200
committerLia Lenckowski <lialenck@protonmail.com>2023-09-07 01:37:34 +0200
commitc4b03717914e5c907f7f47dc2a85df6b57763c58 (patch)
tree926acc5e5497a0539ca18a936fc38029561e7417 /src/imgbeddings-api.py
parent51007f5b8ff6d5960ac034854ceae1ab15237b6a (diff)
downloadembeddings-sort-c4b03717914e5c907f7f47dc2a85df6b57763c58.tar
embeddings-sort-c4b03717914e5c907f7f47dc2a85df6b57763c58.tar.bz2
embeddings-sort-c4b03717914e5c907f7f47dc2a85df6b57763c58.tar.zst
add content embedder
Diffstat (limited to 'src/imgbeddings-api.py')
-rw-r--r--src/imgbeddings-api.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/imgbeddings-api.py b/src/imgbeddings-api.py
new file mode 100644
index 0000000..795c625
--- /dev/null
+++ b/src/imgbeddings-api.py
@@ -0,0 +1,15 @@
+from PIL import Image
+from imgbeddings import imgbeddings
+import sys
+import json as j
+#from itertools import batched # TODO das hier ab python 3.12
+
+b = imgbeddings()
+
+ems = []
+
+for f in sys.argv[1:]: # TODO this should be batched for faster ai stuff
+ im = Image.open(open(f, "rb"))
+ ems += [b.to_embeddings(im)]
+
+print(j.dumps([em[0].tolist() for em in ems]))