1
0
mirror of https://github.com/osmarks/meme-search-engine.git synced 2024-09-21 10:09:36 +00:00
meme-search-engine/load_embedding.py

14 lines
463 B
Python
Raw Normal View History

2024-05-22 19:17:13 +00:00
import numpy as np
import sqlite3
import base64
#db = sqlite3.connect("/srv/mse/data.sqlite3")
db = sqlite3.connect("data.sqlite3")
db.row_factory = sqlite3.Row
name = input("Name: ")
url = input("Embedding search URL: ")
data = base64.urlsafe_b64decode(url.removeprefix("https://mse.osmarks.net/?e="))
arr = np.frombuffer(data, dtype=np.float16).copy()
db.execute("INSERT OR REPLACE INTO predefined_embeddings VALUES (?, ?)", (name, arr.tobytes()))
db.commit()