mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-20 13:54:36 +01:00
Face recognition backend (#14495)
* Add basic config and face recognition table * Reconfigure updates processing to handle face * Crop frame to face box * Implement face embedding calculation * Get matching face embeddings * Add support face recognition based on existing faces * Use arcface face embeddings instead of generic embeddings model * Add apis for managing faces * Implement face uploading API * Build out more APIs * Add min area config * Handle larger images * Add more debug logs * fix calculation * Reduce timeout * Small tweaks * Use webp images * Use facenet model
This commit is contained in:
committed by
Blake Blackshear
parent
0e1139a7a4
commit
aa19ec3ddb
@@ -29,6 +29,10 @@ class SqliteVecQueueDatabase(SqliteQueueDatabase):
|
||||
ids = ",".join(["?" for _ in event_ids])
|
||||
self.execute_sql(f"DELETE FROM vec_descriptions WHERE id IN ({ids})", event_ids)
|
||||
|
||||
def delete_embeddings_face(self, face_ids: list[str]) -> None:
|
||||
ids = ",".join(["?" for _ in face_ids])
|
||||
self.execute_sql(f"DELETE FROM vec_faces WHERE id IN ({ids})", face_ids)
|
||||
|
||||
def drop_embeddings_tables(self) -> None:
|
||||
self.execute_sql("""
|
||||
DROP TABLE vec_descriptions;
|
||||
@@ -36,8 +40,11 @@ class SqliteVecQueueDatabase(SqliteQueueDatabase):
|
||||
self.execute_sql("""
|
||||
DROP TABLE vec_thumbnails;
|
||||
""")
|
||||
self.execute_sql("""
|
||||
DROP TABLE vec_faces;
|
||||
""")
|
||||
|
||||
def create_embeddings_tables(self) -> None:
|
||||
def create_embeddings_tables(self, face_recognition: bool) -> None:
|
||||
"""Create vec0 virtual table for embeddings"""
|
||||
self.execute_sql("""
|
||||
CREATE VIRTUAL TABLE IF NOT EXISTS vec_thumbnails USING vec0(
|
||||
@@ -51,3 +58,11 @@ class SqliteVecQueueDatabase(SqliteQueueDatabase):
|
||||
description_embedding FLOAT[768] distance_metric=cosine
|
||||
);
|
||||
""")
|
||||
|
||||
if face_recognition:
|
||||
self.execute_sql("""
|
||||
CREATE VIRTUAL TABLE IF NOT EXISTS vec_faces USING vec0(
|
||||
id TEXT PRIMARY KEY,
|
||||
face_embedding FLOAT[128] distance_metric=cosine
|
||||
);
|
||||
""")
|
||||
|
||||
Reference in New Issue
Block a user