diff --git a/frigate/db/sqlitevecq.py b/frigate/db/sqlitevecq.py index d630e1ddf..ccb75ae54 100644 --- a/frigate/db/sqlitevecq.py +++ b/frigate/db/sqlitevecq.py @@ -29,10 +29,6 @@ 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; @@ -40,11 +36,8 @@ class SqliteVecQueueDatabase(SqliteQueueDatabase): self.execute_sql(""" DROP TABLE vec_thumbnails; """) - self.execute_sql(""" - DROP TABLE vec_faces; - """) - def create_embeddings_tables(self, face_recognition: bool) -> None: + def create_embeddings_tables(self) -> None: """Create vec0 virtual table for embeddings""" self.execute_sql(""" CREATE VIRTUAL TABLE IF NOT EXISTS vec_thumbnails USING vec0( @@ -58,11 +51,3 @@ 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[512] distance_metric=cosine - ); - """) diff --git a/frigate/embeddings/embeddings.py b/frigate/embeddings/embeddings.py index 255b72cb2..12c99c93b 100644 --- a/frigate/embeddings/embeddings.py +++ b/frigate/embeddings/embeddings.py @@ -68,7 +68,7 @@ class Embeddings: self.requestor = InterProcessRequestor() # Create tables if they don't exist - self.db.create_embeddings_tables(self.config.face_recognition.enabled) + self.db.create_embeddings_tables() models = [ "jinaai/jina-clip-v1-text_model_fp16.onnx", @@ -126,22 +126,6 @@ class Embeddings: device="GPU" if config.semantic_search.model_size == "large" else "CPU", ) - self.face_embedding = None - - if self.config.face_recognition.enabled: - self.face_embedding = GenericONNXEmbedding( - model_name="facenet", - model_file="facenet.onnx", - download_urls={ - "facenet.onnx": "https://github.com/NickM-27/facenet-onnx/releases/download/v1.0/facenet.onnx", - "facedet.onnx": "https://github.com/opencv/opencv_zoo/raw/refs/heads/main/models/face_detection_yunet/face_detection_yunet_2023mar_int8.onnx", - }, - model_size="large", - model_type=ModelTypeEnum.face, - requestor=self.requestor, - device="GPU", - ) - self.lpr_detection_model = None self.lpr_classification_model = None self.lpr_recognition_model = None @@ -277,40 +261,12 @@ class Embeddings: return embeddings - def embed_face(self, label: str, thumbnail: bytes, upsert: bool = False) -> ndarray: - embedding = self.face_embedding(thumbnail)[0] - - if upsert: - rand_id = "".join( - random.choices(string.ascii_lowercase + string.digits, k=6) - ) - id = f"{label}-{rand_id}" - - # write face to library - folder = os.path.join(FACE_DIR, label) - file = os.path.join(folder, f"{id}.webp") - os.makedirs(folder, exist_ok=True) - - # save face image - with open(file, "wb") as output: - output.write(thumbnail) - - self.db.execute_sql( - """ - INSERT OR REPLACE INTO vec_faces(id, face_embedding) - VALUES(?, ?) - """, - (id, serialize(embedding)), - ) - - return embedding - def reindex(self) -> None: logger.info("Indexing tracked object embeddings...") self.db.drop_embeddings_tables() logger.debug("Dropped embeddings tables.") - self.db.create_embeddings_tables(self.config.face_recognition.enabled) + self.db.create_embeddings_tables() logger.debug("Created embeddings tables.") # Delete the saved stats file