mirror of
https://github.com/MrSleeps/jellyfin-scene-search.git
synced 2026-11-18 07:51:27 +00:00
Persist frame captions in canonical database
This commit is contained in:
@@ -32,6 +32,9 @@ CREATE TABLE IF NOT EXISTS frames (
|
||||
timestamp_ms INTEGER NOT NULL,
|
||||
thumb_path TEXT NOT NULL,
|
||||
embedding_f16 BLOB NOT NULL,
|
||||
caption TEXT,
|
||||
caption_model TEXT,
|
||||
captioned_at TEXT,
|
||||
UNIQUE(media_id, frame_number)
|
||||
);
|
||||
|
||||
@@ -52,9 +55,22 @@ def connect(path: Path) -> Iterator[sqlite3.Connection]:
|
||||
con.close()
|
||||
|
||||
|
||||
def _ensure_frame_caption_columns(con: sqlite3.Connection) -> None:
|
||||
columns = {row["name"] for row in con.execute("PRAGMA table_info(frames)")}
|
||||
additions = {
|
||||
"caption": "TEXT",
|
||||
"caption_model": "TEXT",
|
||||
"captioned_at": "TEXT",
|
||||
}
|
||||
for name, sql_type in additions.items():
|
||||
if name not in columns:
|
||||
con.execute(f"ALTER TABLE frames ADD COLUMN {name} {sql_type}")
|
||||
|
||||
|
||||
def init_db(path: Path) -> None:
|
||||
with connect(path) as con:
|
||||
con.executescript(SCHEMA)
|
||||
_ensure_frame_caption_columns(con)
|
||||
|
||||
|
||||
def pack_vector(vector: np.ndarray) -> bytes:
|
||||
|
||||
Reference in New Issue
Block a user