NVR with realtime local object detection for IP cameras
TypeScript aicameragoogle-coralhome-assistanthome-automationhomeautomationmqttnvrobject-detectionrealtimertsptensorflow
Fixes (#18139)
Josh Hawkinsf39ddbc00d7b
diff --git a/docs/docs/configuration/face_recognition.md b/docs/docs/configuration/face_recognition.mdindex bd97b394c4..7a4cde5589 100644--- a/docs/docs/configuration/face_recognition.md+++ b/docs/docs/configuration/face_recognition.md@@ -137,6 +137,15 @@ This can happen for a few different reasons, but this is usually an indicator th- When you provide images with different poses, lighting, and expressions, the algorithm extracts features that are consistent across those variations.- By training on a diverse set of images, the algorithm becomes less sensitive to minor variations and noise in the input image.+Review your face collections and remove most of the unclear or low-quality images. Then, use the **Reprocess** button on each face in the **Train** tab to evaluate how the changes affect recognition scores.++Avoid training on images that already score highly, as this can lead to over-fitting. Instead, focus on relatively clear images that score lower - ideally with different lighting, angles, and conditions—to help the model generalize more effectively.++### Frigate misidentified a face. Can I tell it that a face is "not" a specific person?++No, face recognition does not support negative training (i.e., explicitly telling it who someone is _not_). Instead, the best approach is to improve the training data by using a more diverse and representative set of images for each person.+For more guidance, refer to the section above on improving recognition accuracy.+### I see scores above the threshold in the train tab, but a sub label wasn't assigned?The Frigate considers the recognition scores across all recognition attempts for each person object. The scores are continually weighted based on the area of the face, and a sub label will only be assigned to person if a person is confidently recognized consistently. This avoids cases where a single high confidence recognition would throw off the results.diff --git a/docs/docs/configuration/semantic_search.md b/docs/docs/configuration/semantic_search.mdindex bf7a49ca85..80fce29583 100644--- a/docs/docs/configuration/semantic_search.md+++ b/docs/docs/configuration/semantic_search.md@@ -19,7 +19,7 @@ For best performance, 16GB or more of RAM and a dedicated GPU are recommended.## Configuration-Semantic Search is disabled by default, and must be enabled in your config file or in the UI's Settings page before it can be used. Semantic Search is a global configuration setting.+Semantic Search is disabled by default, and must be enabled in your config file or in the UI's Classification Settings page before it can be used. Semantic Search is a global configuration setting.```yamlsemantic_search:@@ -29,9 +29,9 @@ semantic_search::::tip-The embeddings database can be re-indexed from the existing tracked objects in your database by adding `reindex: True` to your `semantic_search` configuration or by toggling the switch on the Search Settings page in the UI and restarting Frigate. Depending on the number of tracked objects you have, it can take a long while to complete and may max out your CPU while indexing. Make sure to turn the UI's switch off or set the config back to `False` before restarting Frigate again.+The embeddings database can be re-indexed from the existing tracked objects in your database by pressing the "Reindex" button in the Classification Settings in the UI or by adding `reindex: True` to your `semantic_search` configuration and restarting Frigate. Depending on the number of tracked objects you have, it can take a long while to complete and may max out your CPU while indexing.-If you are enabling Semantic Search for the first time, be advised that Frigate does not automatically index older tracked objects. You will need to enable the `reindex` feature in order to do that.+If you are enabling Semantic Search for the first time, be advised that Frigate does not automatically index older tracked objects. You will need to reindex as described above.:::@@ -72,7 +72,7 @@ For most users, especially native English speakers, the V1 model remains the rec:::note-Switching between V1 and V2 requires reindexing your embeddings. To do this, set `reindex: True` in your Semantic Search configuration and restart Frigate. The embeddings from V1 and V2 are incompatible, and failing to reindex will result in incorrect search results.+Switching between V1 and V2 requires reindexing your embeddings. The embeddings from V1 and V2 are incompatible, and failing to reindex will result in incorrect search results.:::diff --git a/docs/docs/configuration/snapshots.md b/docs/docs/configuration/snapshots.mdindex e6c2609135..815e301baa 100644--- a/docs/docs/configuration/snapshots.md+++ b/docs/docs/configuration/snapshots.md@@ -5,7 +5,7 @@ title: SnapshotsFrigate can save a snapshot image to `/media/frigate/clips` for each object that is detected named as `<camera>-<id>.jpg`. They are also accessible [via the api](../integrations/api/event-snapshot-events-event-id-snapshot-jpg-get.api.mdx)-For users with Frigate+ enabled, snapshots are accessible in the UI in the Frigate+ pane to allow for quick submission to the Frigate+ service.+Snapshots are accessible in the UI in the Explore pane. This allows for quick submission to the Frigate+ service.To only save snapshots for objects that enter a specific zone, [see the zone docs](./zones.md#restricting-snapshots-to-specific-zones)diff --git a/docs/docs/frigate/hardware.md b/docs/docs/frigate/hardware.mdindex 0d3780782f..bf54de5b90 100644--- a/docs/docs/frigate/hardware.md+++ b/docs/docs/frigate/hardware.md@@ -143,9 +143,10 @@ Inference speeds will vary greatly depending on the GPU and the model used.With the [rocm](../configuration/object_detectors.md#amdrocm-gpu-detector) detector Frigate can take advantage of many discrete AMD GPUs.-| Name | YOLOv9 Inference Time | YOLO-NAS Inference Time |-| -------- | --------------------- | ------------------------- |-| AMD 780M | ~ 14 ms | 320: ~ 30 ms 640: ~ 60 ms |+| Name | YOLOv9 Inference Time | YOLO-NAS Inference Time |+| --------- | --------------------- | ------------------------- |+| AMD 780M | ~ 14 ms | 320: ~ 30 ms 640: ~ 60 ms |+| AMD 8700G | | 320: ~ 20 ms 640: ~ 40 ms |## Community Supported Detectorsdiff --git a/frigate/comms/mqtt.py b/frigate/comms/mqtt.pyindex 3168135186..e487b30ee8 100644--- a/frigate/comms/mqtt.py+++ b/frigate/comms/mqtt.py@@ -213,6 +213,8 @@ class MqttClient(Communicator): # type: ignore[misc]"motion_contour_area","birdseye","birdseye_mode",+ "review_alerts",+ "review_detections",]for name in self.config.cameras.keys():diff --git a/frigate/data_processing/common/license_plate/mixin.py b/frigate/data_processing/common/license_plate/mixin.pyindex b622394915..e94c1b5648 100644--- a/frigate/data_processing/common/license_plate/mixin.py+++ b/frigate/data_processing/common/license_plate/mixin.py@@ -1552,6 +1552,12 @@ class LicensePlateProcessingMixin:(base64.b64encode(encoded_img).decode("ASCII"), id, camera),)+ if id not in self.detected_license_plates:+ if camera not in self.camera_current_cars:+ self.camera_current_cars[camera] = []++ self.camera_current_cars[camera].append(id)+self.detected_license_plates[id] = {"plate": top_plate,"char_confidences": top_char_confidences,@@ -1564,7 +1570,7 @@ class LicensePlateProcessingMixin:def handle_request(self, topic, request_data) -> dict[str, any] | None:return- def expire_object(self, object_id: str):+ def expire_object(self, object_id: str, camera: str):if object_id in self.detected_license_plates:self.detected_license_plates.pop(object_id)diff --git a/frigate/data_processing/real_time/api.py b/frigate/data_processing/real_time/api.pyindex 1ba01d5da7..3d8e735c1c 100644--- a/frigate/data_processing/real_time/api.py+++ b/frigate/data_processing/real_time/api.py@@ -50,10 +50,11 @@ class RealTimeProcessorApi(ABC):pass@abstractmethod- def expire_object(self, object_id: str) -> None:+ def expire_object(self, object_id: str, camera: str) -> None:"""Handle objects that are no longer detected.Args:object_id (str): id of object that is no longer detected.+ camera (str): name of camera that object was detected on.Returns:None.diff --git a/frigate/data_processing/real_time/bird.py b/frigate/data_processing/real_time/bird.pyindex ea181d6c35..7fd2a5edbe 100644--- a/frigate/data_processing/real_time/bird.py+++ b/frigate/data_processing/real_time/bird.py@@ -152,6 +152,6 @@ class BirdRealTimeProcessor(RealTimeProcessorApi):def handle_request(self, topic, request_data):return None- def expire_object(self, object_id):+ def expire_object(self, object_id, camera):if object_id in self.detected_birds:self.detected_birds.pop(object_id)diff --git a/frigate/data_processing/real_time/face.py b/frigate/data_processing/real_time/face.pyindex a7e1a63ba1..6936e3ea1b 100644--- a/frigate/data_processing/real_time/face.py+++ b/frigate/data_processing/real_time/face.py@@ -54,6 +54,7 @@ class FaceRealTimeProcessor(RealTimeProcessorApi):self.face_detector: cv2.FaceDetectorYN = Noneself.requires_face_detection = "face" not in self.config.objects.all_objectsself.person_face_history: dict[str, list[tuple[str, float, int]]] = {}+ self.camera_current_people: dict[str, list[str]] = {}self.recognizer: FaceRecognizer | None = Noneself.faces_per_second = EventsPerSecond()self.inference_speed = InferenceSpeed(self.metrics.face_rec_speed)@@ -282,9 +283,13 @@ class FaceRealTimeProcessor(RealTimeProcessorApi):if id not in self.person_face_history:self.person_face_history[id] = []+ if camera not in self.camera_current_people:+ self.camera_current_people[camera] = []+self.person_face_history[id].append((sub_label, score, face_frame.shape[0] * face_frame.shape[1]))+ self.camera_current_people[camera].append(id)(weighted_sub_label, weighted_score) = self.weighted_average(self.person_face_history[id])@@ -420,10 +425,25 @@ class FaceRealTimeProcessor(RealTimeProcessorApi):)shutil.move(current_file, new_file)- def expire_object(self, object_id: str):+ def expire_object(self, object_id: str, camera: str):if object_id in self.person_face_history:self.person_face_history.pop(object_id)+ if object_id in self.camera_current_people.get(camera, []):+ self.camera_current_people[camera].remove(object_id)++ if len(self.camera_current_people[camera]) == 0:+ self.requestor.send_data(+ "tracked_object_update",+ json.dumps(+ {+ "type": TrackedObjectUpdateTypesEnum.face,+ "name": None,+ "camera": camera,+ }+ ),+ )+def weighted_average(self, results_list: list[tuple[str, float, int]], max_weight: int = 4000):diff --git a/frigate/data_processing/real_time/license_plate.py b/frigate/data_processing/real_time/license_plate.pyindex 8649680733..13596057d0 100644--- a/frigate/data_processing/real_time/license_plate.py+++ b/frigate/data_processing/real_time/license_plate.py@@ -1,5 +1,6 @@"""Handle processing images for face detection and recognition."""+import jsonimport loggingimport numpy as np@@ -13,6 +14,7 @@ from frigate.data_processing.common.license_plate.mixin import (from frigate.data_processing.common.license_plate.model import (LicensePlateModelRunner,)+from frigate.types import TrackedObjectUpdateTypesEnumfrom ..types import DataProcessorMetricsfrom .api import RealTimeProcessorApi@@ -36,6 +38,7 @@ class LicensePlateRealTimeProcessor(LicensePlateProcessingMixin, RealTimeProcessself.lpr_config = config.lprself.config = configself.sub_label_publisher = sub_label_publisher+ self.camera_current_cars: dict[str, list[str]] = {}super().__init__(config, metrics)def process_frame(@@ -50,6 +53,22 @@ class LicensePlateRealTimeProcessor(LicensePlateProcessingMixin, RealTimeProcessdef handle_request(self, topic, request_data) -> dict[str, any] | None:return- def expire_object(self, object_id: str):+ def expire_object(self, object_id: str, camera: str):if object_id in self.detected_license_plates:self.detected_license_plates.pop(object_id)++ if object_id in self.camera_current_cars.get(camera, []):+ self.camera_current_cars[camera].remove(object_id)++ if len(self.camera_current_cars[camera]) == 0:+ self.requestor.send_data(+ "tracked_object_update",+ json.dumps(+ {+ "type": TrackedObjectUpdateTypesEnum.lpr,+ "name": None,+ "plate": None,+ "camera": camera,+ }+ ),+ )diff --git a/frigate/embeddings/maintainer.py b/frigate/embeddings/maintainer.pyindex f62a5476b8..487d5dbc40 100644--- a/frigate/embeddings/maintainer.py+++ b/frigate/embeddings/maintainer.py@@ -359,7 +359,7 @@ class EmbeddingMaintainer(threading.Thread):# expire in realtime processorsfor processor in self.realtime_processors:- processor.expire_object(event_id)+ processor.expire_object(event_id, camera)if updated_db:try:diff --git a/web/public/locales/en/common.json b/web/public/locales/en/common.jsonindex 9532bcb691..56aa659e65 100644--- a/web/public/locales/en/common.json+++ b/web/public/locales/en/common.json@@ -60,6 +60,10 @@"12hour": "MMM d, h:mm aaa","24hour": "MMM d, HH:mm"},+ "formattedTimestampMonthDayYear": {+ "12hour": "MMM d, yyyy",+ "24hour": "MMM d, yyyy"+ },"formattedTimestampMonthDayYearHourMinute": {"12hour": "MMM d yyyy, h:mm aaa","24hour": "MMM d yyyy, HH:mm"diff --git a/web/public/locales/en/components/dialog.json b/web/public/locales/en/components/dialog.jsonindex 3e77b9f03c..8b2dc0b880 100644--- a/web/public/locales/en/components/dialog.json+++ b/web/public/locales/en/components/dialog.json@@ -98,6 +98,10 @@"title": "Confirm Delete","desc": {"selected": "Are you sure you want to delete all recorded video associated with this review item?<br /><br />Hold the <em>Shift</em> key to bypass this dialog in the future."+ },+ "toast": {+ "success": "Video footage associated with the selected review items has been deleted successfully.",+ "error": "Failed to delete: {{error}}"}},"button": {diff --git a/web/public/locales/en/views/faceLibrary.json b/web/public/locales/en/views/faceLibrary.jsonindex 50f2f587d2..bb5f7e9e0d 100644--- a/web/public/locales/en/views/faceLibrary.json+++ b/web/public/locales/en/views/faceLibrary.json@@ -68,6 +68,7 @@"dropInstructions": "Drag and drop an image here, or click to select","maxSize": "Max size: {{size}}MB"},+ "nofaces": "No faces available","readTheDocs": "Read the documentation","trainFaceAs": "Train Face as:","trainFace": "Train Face",diff --git a/web/public/locales/en/views/settings.json b/web/public/locales/en/views/settings.jsonindex 62ad98f359..d5f9e140df 100644--- a/web/public/locales/en/views/settings.json+++ b/web/public/locales/en/views/settings.json@@ -268,7 +268,8 @@"allObjects": "All Objects","speedEstimation": {"title": "Speed Estimation",- "desc": "Enable speed estimation for objects in this zone. The zone must have exactly 4 points."+ "desc": "Enable speed estimation for objects in this zone. The zone must have exactly 4 points.",+ "docs": "Read the documentation"},"speedThreshold": {"title": "Speed Threshold ({{unit}})",diff --git a/web/src/components/filter/ReviewActionGroup.tsx b/web/src/components/filter/ReviewActionGroup.tsxindex f443729ce8..4db8a31c0e 100644--- a/web/src/components/filter/ReviewActionGroup.tsx+++ b/web/src/components/filter/ReviewActionGroup.tsx@@ -17,6 +17,7 @@ import {} from "../ui/alert-dialog";import useKeyboardListener from "@/hooks/use-keyboard-listener";import { Trans, useTranslation } from "react-i18next";+import { toast } from "sonner";type ReviewActionGroupProps = {selectedReviews: string[];@@ -41,11 +42,33 @@ export default function ReviewActionGroup({pullLatestData();}, [selectedReviews, setSelectedReviews, pullLatestData]);- const onDelete = useCallback(async () => {- await axios.post(`reviews/delete`, { ids: selectedReviews });- setSelectedReviews([]);- pullLatestData();- }, [selectedReviews, setSelectedReviews, pullLatestData]);+ const onDelete = useCallback(() => {+ axios+ .post(`reviews/delete`, { ids: selectedReviews })+ .then((resp) => {+ if (resp.status === 200) {+ toast.success(t("recording.confirmDelete.toast.success"), {+ position: "top-center",+ });+ setSelectedReviews([]);+ pullLatestData();+ }+ })+ .catch((error) => {+ const errorMessage =+ error.response?.data?.message ||+ error.response?.data?.detail ||+ "Unknown error";+ toast.error(+ t("recording.confirmDelete.toast.error", {+ error: errorMessage,+ }),+ {+ position: "top-center",+ },+ );+ });+ }, [selectedReviews, setSelectedReviews, pullLatestData, t]);const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);const [bypassDialog, setBypassDialog] = useState(false);diff --git a/web/src/components/settings/ZoneEditPane.tsx b/web/src/components/settings/ZoneEditPane.tsxindex 5e86817321..2df97c29ec 100644--- a/web/src/components/settings/ZoneEditPane.tsx+++ b/web/src/components/settings/ZoneEditPane.tsx@@ -30,6 +30,8 @@ import { flattenPoints, interpolatePoints } from "@/utils/canvasUtil";import ActivityIndicator from "../indicators/activity-indicator";import { getAttributeLabels } from "@/utils/iconUtil";import { Trans, useTranslation } from "react-i18next";+import { Link } from "react-router-dom";+import { LuExternalLink } from "react-icons/lu";type ZoneEditPaneProps = {polygons?: Polygon[];@@ -669,6 +671,17 @@ export default function ZoneEditPane({</div><FormDescription>{t("masksAndZones.zones.speedEstimation.desc")}+ <div className="mt-2 flex items-center text-primary">+ <Link+ to="https://docs.frigate.video/configuration/zones#speed-estimation"+ target="_blank"+ rel="noopener noreferrer"+ className="inline"+ >+ {t("masksAndZones.zones.speedEstimation.docs")}+ <LuExternalLink className="ml-2 inline-flex size-3" />+ </Link>+ </div></FormDescription><FormMessage /></FormItem>diff --git a/web/src/lib/const.ts b/web/src/lib/const.tsindex bd16d8c39e..b4d94d28ad 100644--- a/web/src/lib/const.ts+++ b/web/src/lib/const.ts@@ -11,4 +11,5 @@ export const supportedLanguageKeys = ["zh-CN","yue-Hant","ru",+ "uk",];diff --git a/web/src/pages/FaceLibrary.tsx b/web/src/pages/FaceLibrary.tsxindex d5ba4c26e4..921f8d5324 100644--- a/web/src/pages/FaceLibrary.tsx+++ b/web/src/pages/FaceLibrary.tsx@@ -390,10 +390,10 @@ export default function FaceLibrary() {</div>)}</div>- {pageToggle && faceImages.length === 0 && pageToggle !== "train" ? (+ {pageToggle && faceImages?.length === 0 && pageToggle !== "train" ? (<div className="absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 flex-col items-center justify-center text-center"><LuFolderCheck className="size-16" />- No faces available+ {t("nofaces")}</div>) : (pageToggle &&diff --git a/web/src/views/recording/RecordingView.tsx b/web/src/views/recording/RecordingView.tsxindex 344fd8caad..9e38503d11 100644--- a/web/src/views/recording/RecordingView.tsx+++ b/web/src/views/recording/RecordingView.tsx@@ -819,7 +819,7 @@ function Timeline({className={`${isDesktop? `${timelineType == "timeline" ? "w-[100px]" : "w-60"} no-scrollbar overflow-y-auto`- : "overflow-hidden portrait:flex-grow landscape:w-[20%]"+ : `overflow-hidden portrait:flex-grow ${timelineType == "timeline" ? "landscape:w-[100px]" : "landscape:w-[175px]"} `} relative`}><div className="pointer-events-none absolute inset-x-0 top-0 z-20 h-[30px] w-full bg-gradient-to-b from-secondary to-transparent"></div>@@ -855,7 +855,7 @@ function Timeline({<divclassName={cn("scrollbar-container grid h-auto grid-cols-1 gap-4 overflow-auto p-4",- isMobile && "sm:grid-cols-2",+ isMobile && "sm:portrait:grid-cols-2",)}>{mainCameraReviewItems.length === 0 ? (diff --git a/web/src/views/system/StorageMetrics.tsx b/web/src/views/system/StorageMetrics.tsxindex 2f41f2c921..2a7e98828f 100644--- a/web/src/views/system/StorageMetrics.tsx+++ b/web/src/views/system/StorageMetrics.tsx@@ -71,7 +71,7 @@ export default function StorageMetrics({const timeFormat = config?.ui.time_format === "24hour" ? "24hour" : "12hour";const format = useMemo(() => {- return t(`time.formattedTimestampMonthDayYearHourMinute.${timeFormat}`, {+ return t(`time.formattedTimestampMonthDayYear.${timeFormat}`, {ns: "common",});}, [t, timeFormat]);