forked from blakeblackshear/frigate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update version * Face recognition backend (blakeblackshear#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 * Improve face recognition (blakeblackshear#14537) * Increase requirements for face to be set * Manage faces properly * Add basic docs * Simplify * Separate out face recognition frome semantic search * Update docs * Formatting * Fix access (blakeblackshear#14540) * Face detection (blakeblackshear#14544) * Add support for face detection * Add support for detecting faces during registration * Set body size to be larger * Undo * License plate recognition (ALPR) backend (blakeblackshear#14564) * Update version * Face recognition backend (blakeblackshear#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 * Improve face recognition (blakeblackshear#14537) * Increase requirements for face to be set * Manage faces properly * Add basic docs * Simplify * Separate out face recognition frome semantic search * Update docs * Formatting * Fix access (blakeblackshear#14540) * Face detection (blakeblackshear#14544) * Add support for face detection * Add support for detecting faces during registration * Set body size to be larger * Undo * Update version * Face recognition backend (blakeblackshear#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 * Improve face recognition (blakeblackshear#14537) * Increase requirements for face to be set * Manage faces properly * Add basic docs * Simplify * Separate out face recognition frome semantic search * Update docs * Formatting * Fix access (blakeblackshear#14540) * Face detection (blakeblackshear#14544) * Add support for face detection * Add support for detecting faces during registration * Set body size to be larger * Undo * initial foundation for alpr with paddleocr * initial foundation for alpr with paddleocr * initial foundation for alpr with paddleocr * config * config * lpr maintainer * clean up * clean up * fix processing * don't process for stationary cars * fix order * fixes * check for known plates * improved length and character by character confidence * model fixes and small tweaks * docs * placeholder for non frigate+ model lp detection --------- Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com> * Fix label check (blakeblackshear#14610) * Create config for parsing object * Use in maintainer * Prevent division by zero in lpr confidence checks (blakeblackshear#14615) * LPR improvements (blakeblackshear#14641) * Update facenet model (blakeblackshear#14647) * Use regular expressions for plate matching (blakeblackshear#14727) * Use SVC to normalize and classify faces for recognition (blakeblackshear#14835) * Add margin to detected faces for embeddings * Standardize pixel values for face input * Use SVC to classify faces * Clear classifier when new face is added * Formatting * Add dependency * Remove hardcoded face name * Fix check * Remove standardization --------- Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com> Co-authored-by: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com>
- Loading branch information
1 parent
ed9c678
commit 13a117d
Showing
26 changed files
with
1,803 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
id: face_recognition | ||
title: Face Recognition | ||
--- | ||
|
||
Face recognition allows people to be assigned names and when their face is recognized Frigate will assign the person's name as a sub label. This information is included in the UI, filters, as well as in notifications. | ||
|
||
Frigate has support for FaceNet to create face embeddings, which runs locally. Embeddings are then saved to Frigate's database. | ||
|
||
## Minimum System Requirements | ||
|
||
Face recognition works by running a large AI model locally on your system. Systems without a GPU will not run Face Recognition reliably or at all. | ||
|
||
## Configuration | ||
|
||
Face recognition is disabled by default and requires semantic search to be enabled, face recognition must be enabled in your config file before it can be used. Semantic Search and face recognition are global configuration settings. | ||
|
||
```yaml | ||
face_recognition: | ||
enabled: true | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
id: license_plate_recognition | ||
title: License Plate Recognition (LPR) | ||
--- | ||
|
||
Frigate can recognize license plates on vehicles and automatically add the detected characters as a `sub_label` to objects that are of type `car`. A common use case may be to read the license plates of cars pulling into a driveway or cars passing by on a street with a dedicated LPR camera. | ||
|
||
Users running a Frigate+ model should ensure that `license_plate` is added to the [list of objects to track](https://docs.frigate.video/plus/#available-label-types) either globally or for a specific camera. This will improve the accuracy and performance of the LPR model. | ||
|
||
LPR is most effective when the vehicle’s license plate is fully visible to the camera. For moving vehicles, Frigate will attempt to read the plate continuously, refining its detection and keeping the most confident result. LPR will not run on stationary vehicles. | ||
|
||
## Minimum System Requirements | ||
|
||
License plate recognition works by running AI models locally on your system. The models are relatively lightweight and run on your CPU. At least 4GB of RAM is required. | ||
|
||
## Configuration | ||
|
||
License plate recognition is disabled by default. Enable it in your config file: | ||
|
||
```yaml | ||
lpr: | ||
enabled: true | ||
``` | ||
## Advanced Configuration | ||
Several options are available to fine-tune the LPR feature. For example, you can adjust the `min_area` setting, which defines the minimum size in pixels a license plate must be before LPR runs. The default is 500 pixels. | ||
|
||
Additionally, you can define `known_plates` as strings or regular expressions, allowing Frigate to label tracked vehicles with custom sub_labels when a recognized plate is detected. This information is then accessible in the UI, filters, and notifications. | ||
|
||
```yaml | ||
lpr: | ||
enabled: true | ||
min_area: 500 | ||
known_plates: | ||
Wife's Car: | ||
- "ABC-1234" | ||
- "ABC-I234" | ||
Johnny: | ||
- "J*N-*234" # Using wildcards for H/M and 1/I | ||
Sally: | ||
- "[S5]LL-1234" # Matches SLL-1234 and 5LL-1234 | ||
``` | ||
|
||
In this example, "Wife's Car" will appear as the label for any vehicle matching the plate "ABC-1234." The model might occasionally interpret the digit 1 as a capital I (e.g., "ABC-I234"), so both variations are listed. Similarly, multiple possible variations are specified for Johnny and Sally. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
"""Object classification APIs.""" | ||
|
||
import logging | ||
|
||
from fastapi import APIRouter, Request, UploadFile | ||
from fastapi.responses import JSONResponse | ||
|
||
from frigate.api.defs.tags import Tags | ||
from frigate.embeddings import EmbeddingsContext | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
router = APIRouter(tags=[Tags.events]) | ||
|
||
|
||
@router.get("/faces") | ||
def get_faces(): | ||
return JSONResponse(content={"message": "there are faces"}) | ||
|
||
|
||
@router.post("/faces/{name}") | ||
async def register_face(request: Request, name: str, file: UploadFile): | ||
# if not file.content_type.startswith("image"): | ||
# return JSONResponse( | ||
# status_code=400, | ||
# content={ | ||
# "success": False, | ||
# "message": "Only an image can be used to register a face.", | ||
# }, | ||
# ) | ||
|
||
context: EmbeddingsContext = request.app.embeddings | ||
context.register_face(name, await file.read()) | ||
return JSONResponse( | ||
status_code=200, | ||
content={"success": True, "message": "Successfully registered face."}, | ||
) | ||
|
||
|
||
@router.delete("/faces") | ||
def deregister_faces(request: Request, body: dict = None): | ||
json: dict[str, any] = body or {} | ||
list_of_ids = json.get("ids", "") | ||
|
||
if not list_of_ids or len(list_of_ids) == 0: | ||
return JSONResponse( | ||
content=({"success": False, "message": "Not a valid list of ids"}), | ||
status_code=404, | ||
) | ||
|
||
context: EmbeddingsContext = request.app.embeddings | ||
context.delete_face_ids(list_of_ids) | ||
return JSONResponse( | ||
content=({"success": True, "message": "Successfully deleted faces."}), | ||
status_code=200, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.