Add apis for managing faces

This commit is contained in:
Nicolas Mowen 2024-10-22 06:59:30 -06:00
parent 5c030fa460
commit a5b61d4c61
5 changed files with 34 additions and 3 deletions

View File

@ -0,0 +1,16 @@
"""Object classification APIs."""
import logging
from fastapi import APIRouter
from frigate.api.defs.tags import Tags
logger = logging.getLogger(__name__)
router = APIRouter(tags=[Tags.events])
@router.get("/faces")
def get_faces() -> None:
return None

View File

@ -10,4 +10,5 @@ class Tags(Enum):
review = "Review"
export = "Export"
events = "Events"
classification = "classification"
auth = "Auth"

View File

@ -11,7 +11,16 @@ from starlette_context import middleware, plugins
from starlette_context.plugins import Plugin
from frigate.api import app as main_app
from frigate.api import auth, event, export, media, notification, preview, review
from frigate.api import (
auth,
classification,
event,
export,
media,
notification,
preview,
review,
)
from frigate.api.auth import get_jwt_secret, limiter
from frigate.comms.event_metadata_updater import (
EventMetadataPublisher,
@ -91,6 +100,7 @@ def create_fastapi_app(
# Routes
# Order of include_router matters: https://fastapi.tiangolo.com/tutorial/path-params/#order-matters
app.include_router(auth.router)
app.include_router(classification.router)
app.include_router(review.router)
app.include_router(main_app.router)
app.include_router(preview.router)

View File

@ -116,7 +116,9 @@ class GenericONNXEmbedding:
# the onnx model has incorrect spatial mode
# set by default, update then save model.
print(f"download path is {download_path} and model type is {self.model_type}")
print(
f"download path is {download_path} and model type is {self.model_type}"
)
if download_path is not None and self.model_type == ModelTypeEnum.face:
fix_spatial_mode(download_path)

View File

@ -315,7 +315,9 @@ class EmbeddingMaintainer(threading.Thread):
face_frame = cv2.cvtColor(frame, cv2.COLOR_YUV2BGR_I420)
face_frame = face_frame[face_box[1] : face_box[3], face_box[0] : face_box[2]]
ret, jpg = cv2.imencode(".jpg", face_frame, [int(cv2.IMWRITE_JPEG_QUALITY), 100])
ret, jpg = cv2.imencode(
".jpg", face_frame, [int(cv2.IMWRITE_JPEG_QUALITY), 100]
)
if not ret:
return