mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-05-05 13:07:44 +03:00
Add face recognitions per second
This commit is contained in:
parent
68eb0d1fb4
commit
378f830152
@ -955,7 +955,7 @@ class LicensePlateProcessingMixin:
|
|||||||
"""
|
"""
|
||||||
Update inference metrics.
|
Update inference metrics.
|
||||||
"""
|
"""
|
||||||
self.metrics.alpr_pps.value = (self.metrics.alpr_pps.value * 9 + duration) / 10
|
self.metrics.alpr_speed.value = (self.metrics.alpr_speed.value * 9 + duration) / 10
|
||||||
|
|
||||||
def _generate_plate_event(self, camera: str, plate: str, plate_score: float) -> str:
|
def _generate_plate_event(self, camera: str, plate: str, plate_score: float) -> str:
|
||||||
"""Generate a unique ID for a plate event based on camera and text."""
|
"""Generate a unique ID for a plate event based on camera and text."""
|
||||||
|
|||||||
@ -24,6 +24,7 @@ from frigate.data_processing.common.face.model import (
|
|||||||
FaceNetRecognizer,
|
FaceNetRecognizer,
|
||||||
FaceRecognizer,
|
FaceRecognizer,
|
||||||
)
|
)
|
||||||
|
from frigate.util.builtin import EventsPerSecond
|
||||||
from frigate.util.image import area
|
from frigate.util.image import area
|
||||||
|
|
||||||
from ..types import DataProcessorMetrics
|
from ..types import DataProcessorMetrics
|
||||||
@ -51,6 +52,7 @@ class FaceRealTimeProcessor(RealTimeProcessorApi):
|
|||||||
self.requires_face_detection = "face" not in self.config.objects.all_objects
|
self.requires_face_detection = "face" not in self.config.objects.all_objects
|
||||||
self.person_face_history: dict[str, list[tuple[str, float, int]]] = {}
|
self.person_face_history: dict[str, list[tuple[str, float, int]]] = {}
|
||||||
self.recognizer: FaceRecognizer | None = None
|
self.recognizer: FaceRecognizer | None = None
|
||||||
|
self.faces_per_second = EventsPerSecond()
|
||||||
|
|
||||||
download_path = os.path.join(MODEL_CACHE_DIR, "facedet")
|
download_path = os.path.join(MODEL_CACHE_DIR, "facedet")
|
||||||
self.model_files = {
|
self.model_files = {
|
||||||
@ -103,6 +105,7 @@ class FaceRealTimeProcessor(RealTimeProcessorApi):
|
|||||||
score_threshold=0.5,
|
score_threshold=0.5,
|
||||||
nms_threshold=0.3,
|
nms_threshold=0.3,
|
||||||
)
|
)
|
||||||
|
self.faces_per_second.start()
|
||||||
|
|
||||||
def __detect_face(
|
def __detect_face(
|
||||||
self, input: np.ndarray, threshold: float
|
self, input: np.ndarray, threshold: float
|
||||||
@ -152,6 +155,8 @@ class FaceRealTimeProcessor(RealTimeProcessorApi):
|
|||||||
|
|
||||||
def process_frame(self, obj_data: dict[str, any], frame: np.ndarray):
|
def process_frame(self, obj_data: dict[str, any], frame: np.ndarray):
|
||||||
"""Look for faces in image."""
|
"""Look for faces in image."""
|
||||||
|
self.metrics.face_rec_fps.value = self.faces_per_second.eps()
|
||||||
|
|
||||||
if not self.config.cameras[obj_data["camera"]].face_recognition.enabled:
|
if not self.config.cameras[obj_data["camera"]].face_recognition.enabled:
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -251,6 +256,7 @@ class FaceRealTimeProcessor(RealTimeProcessorApi):
|
|||||||
max(0, face_box[0]) : min(frame.shape[1], face_box[2]),
|
max(0, face_box[0]) : min(frame.shape[1], face_box[2]),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
self.faces_per_second.update()
|
||||||
res = self.recognizer.classify(face_frame)
|
res = self.recognizer.classify(face_frame)
|
||||||
|
|
||||||
if not res:
|
if not res:
|
||||||
|
|||||||
@ -9,6 +9,7 @@ class DataProcessorMetrics:
|
|||||||
image_embeddings_speed: Synchronized
|
image_embeddings_speed: Synchronized
|
||||||
text_embeddings_speed: Synchronized
|
text_embeddings_speed: Synchronized
|
||||||
face_rec_speed: Synchronized
|
face_rec_speed: Synchronized
|
||||||
|
face_rec_fps: Synchronized
|
||||||
alpr_speed: Synchronized
|
alpr_speed: Synchronized
|
||||||
yolov9_lpr_speed: Synchronized
|
yolov9_lpr_speed: Synchronized
|
||||||
|
|
||||||
@ -16,6 +17,7 @@ class DataProcessorMetrics:
|
|||||||
self.image_embeddings_speed = mp.Value("d", 0.01)
|
self.image_embeddings_speed = mp.Value("d", 0.01)
|
||||||
self.text_embeddings_speed = mp.Value("d", 0.01)
|
self.text_embeddings_speed = mp.Value("d", 0.01)
|
||||||
self.face_rec_speed = mp.Value("d", 0.01)
|
self.face_rec_speed = mp.Value("d", 0.01)
|
||||||
|
self.face_rec_fps = mp.Value("d", 0.0)
|
||||||
self.alpr_speed = mp.Value("d", 0.01)
|
self.alpr_speed = mp.Value("d", 0.01)
|
||||||
self.yolov9_lpr_speed = mp.Value("d", 0.01)
|
self.yolov9_lpr_speed = mp.Value("d", 0.01)
|
||||||
|
|
||||||
|
|||||||
@ -305,8 +305,8 @@ def stats_snapshot(
|
|||||||
stats["embeddings"]["face_recognition_speed"] = round(
|
stats["embeddings"]["face_recognition_speed"] = round(
|
||||||
embeddings_metrics.face_rec_speed.value * 1000, 2
|
embeddings_metrics.face_rec_speed.value * 1000, 2
|
||||||
)
|
)
|
||||||
stats["embeddings"]["face_recognition_rps"] = round(
|
stats["embeddings"]["face_recognition_fps"] = round(
|
||||||
embeddings_metrics.face_rec_rps, 2
|
embeddings_metrics.face_rec_speed.value, 2
|
||||||
)
|
)
|
||||||
|
|
||||||
if config.lpr.enabled:
|
if config.lpr.enabled:
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import { Skeleton } from "@/components/ui/skeleton";
|
|||||||
import { ThresholdBarGraph } from "@/components/graph/SystemGraph";
|
import { ThresholdBarGraph } from "@/components/graph/SystemGraph";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { CameraLineGraph } from "@/components/graph/CameraGraph";
|
||||||
|
|
||||||
type FeatureMetricsProps = {
|
type FeatureMetricsProps = {
|
||||||
lastUpdated: number;
|
lastUpdated: number;
|
||||||
@ -102,15 +103,26 @@ export default function FeatureMetrics({
|
|||||||
{embeddingInferenceTimeSeries.map((series) => (
|
{embeddingInferenceTimeSeries.map((series) => (
|
||||||
<div className="rounded-lg bg-background_alt p-2.5 md:rounded-2xl">
|
<div className="rounded-lg bg-background_alt p-2.5 md:rounded-2xl">
|
||||||
<div className="mb-5 capitalize">{series.name}</div>
|
<div className="mb-5 capitalize">{series.name}</div>
|
||||||
<ThresholdBarGraph
|
{series.name.endsWith("Speed") ? (
|
||||||
key={series.name}
|
<ThresholdBarGraph
|
||||||
graphId={`${series.name}-inference`}
|
key={series.name}
|
||||||
name={series.name}
|
graphId={`${series.name}-inference`}
|
||||||
unit="ms"
|
name={series.name}
|
||||||
threshold={EmbeddingThreshold}
|
unit="ms"
|
||||||
updateTimes={updateTimes}
|
threshold={EmbeddingThreshold}
|
||||||
data={[series]}
|
updateTimes={updateTimes}
|
||||||
/>
|
data={[series]}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<CameraLineGraph
|
||||||
|
key={series.name}
|
||||||
|
graphId={`${series.name}-fps`}
|
||||||
|
dataLabels={["Recognitions Per Second"]}
|
||||||
|
unit=""
|
||||||
|
updateTimes={updateTimes}
|
||||||
|
data={[series]}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</>
|
</>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user