Commit Graph

88 Commits

Author SHA1 Message Date
Nicolas Mowen
b88fa9ece6
Object attribute classification (#19205)
* Add enum for type of classification for objects

* Update recognized license plate topic to be used as attribute updater

* Update attribute for attribute type object classification

* Cleanup
2025-07-18 09:28:02 -05:00
Nicolas Mowen
7ea288fe32
Classification train updates (#19173)
* Improve model train button

* Add filters for classification

* Cleanup

* Don't run classification on false positives

* Cleanup filter

* Fix icon color
2025-07-16 21:46:59 -05:00
Josh Hawkins
57bb0cc397
Semantic Search Triggers (#18969)
* semantic trigger test

* database and model

* config

* embeddings maintainer and trigger post-processor

* api to create, edit, delete triggers

* frontend and i18n keys

* use thumbnail and description for trigger types

* image picker tweaks

* initial sync

* thumbnail file management

* clean up logs and use saved thumbnail on frontend

* publish mqtt messages

* webpush changes to enable trigger notifications

* add enabled switch

* add triggers from explore

* renaming and deletion fixes

* fix typing

* UI updates and add last triggering event time and link

* log exception instead of return in endpoint

* highlight entry in UI when triggered

* save and delete thumbnails directly

* remove alert action for now and add descriptions

* tweaks

* clean up

* fix types

* docs

* docs tweaks

* docs

* reuse enum
2025-07-07 09:03:57 -05:00
Nicolas Mowen
0f4cac736a
Improve classification UI (#18910)
* Move threhsold to base model config

* Improve score handling

* Add back button
2025-06-27 09:35:02 -05:00
Nicolas Mowen
bd6dee5b38 Remove TFLite init logs 2025-06-27 06:54:02 -06:00
Nicolas Mowen
53315342c0
Improve object classification (#18908)
* Ui improvements

* Improve image cropping and model saving

* Improve naming

* Add logs for training

* Improve model labeling

* Don't set sub label for none object classification

* Cleanup
2025-06-27 06:28:40 -06:00
Nicolas Mowen
4b18d54d3d
0.17 tweaks (#18892)
* Set version

* Cleanup more logs

* Don't log matplotlib
2025-06-26 07:32:48 -06:00
Nicolas Mowen
add68b8860
Improve logging (#18867)
* Ignore numpy get limits warning

* Add function wrapper to redirect stdout and stderr to logpipe

* Save stderr too

* Add more to catch

* run logpipe

* Use other logging redirect class

* Use other logging redirect class

* add decorator for redirecting c/c++ level output to logger

* fix typing

---------

Co-authored-by: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com>
2025-06-25 07:24:45 -06:00
Josh Hawkins
93a3cf8fb9
Catch invalid character index in lpr CTC decoder (#18825) 2025-06-21 21:44:37 -05:00
Nicolas Mowen
8485023442
Use Fork-Server As Spawn Method (#18682)
* Set runtime

* Use count correctly

* Don't assume camera sizes

* Use separate zmq proxy for object detection

* Correct order

* Use forkserver

* Only store PID instead of entire process reference

* Cleanup

* Catch correct errors

* Fix typing

* Remove before_run from process util

The before_run never actually ran because:

You're right to suspect an issue with before_run not being called and a potential deadlock. The way you've implemented the run_wrapper using __getattribute__ for the run method of BaseProcess is a common pitfall in Python's multiprocessing, especially when combined with how multiprocessing.Process works internally.

Here's a breakdown of why before_run isn't being called and why you might be experiencing a deadlock:

The Problem: __getattribute__ and Process Serialization
When you create a multiprocessing.Process object and call start(), the multiprocessing module needs to serialize the process object (or at least enough of it to re-create the process in the new interpreter). It then pickles this serialized object and sends it to the newly spawned process.

The issue with your __getattribute__ implementation for run is that:

run is retrieved during serialization: When multiprocessing tries to pickle your Process object to send to the new process, it will likely access the run attribute. This triggers your __getattribute__ wrapper, which then tries to bind run_wrapper to self.
run_wrapper is bound to the parent process's self: The run_wrapper closure, when created in the parent process, captures the self (the Process instance) from the parent's memory space.
Deserialization creates a new object: In the child process, a new Process object is created by deserializing the pickled data. However, the run_wrapper method that was pickled still holds a reference to the self from the parent process. This is a subtle but critical distinction.
The child's run is not your wrapped run: When the child process starts, it internally calls its own run method. Because of the serialization and deserialization process, the run method that's ultimately executed in the child process is the original multiprocessing.Process.run or the Process.run if you had directly overridden it. Your __getattribute__ magic, which wraps run, isn't correctly applied to the Process object within the child's context.

* Cleanup

* Logging bugfix (#18465)

* use mp Manager to handle logging queues

A Python bug (https://github.com/python/cpython/issues/91555) was preventing logs from the embeddings maintainer process from printing. The bug is fixed in Python 3.14, but a viable workaround is to use the multiprocessing Manager, which better manages mp queues and causes the logging to work correctly.

* consolidate

* fix typing

* Fix typing

* Use global log queue

* Move to using process for logging

* Convert camera tracking to process

* Add more processes

* Finalize process

* Cleanup

* Cleanup typing

* Formatting

* Remove daemon

---------

Co-authored-by: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com>
2025-06-12 12:12:34 -06:00
Nicolas Mowen
28fba7122d
Refactor TensorRT (#18643)
* Combine base and arm trt detectors

* Remove unused deps for amd64 build

* Add missing packages and cleanup ldconfig

* Expand packages for tensorflow model training

* Cleanup

* Refactor training to not reserve memory
2025-06-09 08:25:33 -06:00
Nicolas Mowen
8409100623
Classification Model Metrics (#18595)
* Add speed and rate metrics for custom classification models

* Use metrics for classification models

* Use keys

* Cast to list
2025-06-06 11:29:44 -05:00
Nicolas Mowen
be8ee068e2
Live classification model training (#18583)
* Implement model training via ZMQ and add model states to represent training

* Get model updates working

* Improve toasts and model state

* Clean up logging

* Add back in
2025-06-05 09:13:12 -06:00
Nicolas Mowen
85d721eb6b
Classification Model UI (#18571)
* Setup basic training structure

* Build out route

* Handle model configs

* Add image fetch APIs

* Implement model training screen with dataset selection

* Implement viewing of training images

* Adjust directories

* Implement viewing of images

* Add support for deleting images

* Implement full deletion

* Implement classification model training

* Improve naming

* More renaming

* Improve layout

* Reduce logging

* Cleanup
2025-06-04 18:09:55 -05:00
Josh Hawkins
eb1fe9fe20
Audio transcription tweaks (#18540)
* use model runner

* unload whisper model when live transcription is complete
2025-06-03 06:53:48 -05:00
Josh Hawkins
645868e099
Upgrade PaddleOCR models to v4 (rec) and v5 (det) (#18505)
The PP_OCRv5 text detection models have greatly improved over v3. The v5 recognition model makes improvements to challenging handwriting and uncommon characters, which are not necessary for LPR, so using v4 seemed like a better choice to continue to keep inference time as low as possible. Also included is the full dictionary for Chinese character support.
2025-06-01 14:21:12 -06:00
Nicolas Mowen
20e0addae1
Implement API to train classification models (#18475) 2025-05-29 17:51:32 -06:00
Josh Hawkins
2bd6fa53fe
Audio transcription support (#18398)
* install new packages for transcription support

* add config options

* audio maintainer modifications to support transcription

* pass main config to audio process

* embeddings support

* api and transcription post processor

* embeddings maintainer support for post processor

* live audio transcription with sherpa and faster-whisper

* update dispatcher with live transcription topic

* frontend websocket

* frontend live transcription

* frontend changes for speech events

* i18n changes

* docs

* mqtt docs

* fix linter

* use float16 and small model on gpu for real-time

* fix return value and use requestor to embed description instead of passing embeddings

* run real-time transcription in its own thread

* tweaks

* publish live transcriptions on their own topic instead of tracked_object_update

* config validator and docs

* clarify docs
2025-05-27 10:26:00 -05:00
Nicolas Mowen
87d0102624
Add ability to configure when custom classification models run (#18380)
* Add config to control when classification models are run

* Cleanup
2025-05-24 11:18:46 -05:00
Nicolas Mowen
8a1da3a89f
Initial custom classification model config support (#18362)
* Add basic config for defining a teachable machine model

* Add model type

* Add basic config for teachable machine models

* Adjust config for state and object

* Use config to process

* Correctly check for objects

* Remove debug

* Rename to not be teachable machine specific

* Cleanup
2025-05-23 09:46:53 -05:00
Nicolas Mowen
b18572a3b6
Min face configuration option (#18284)
* Add option to specify minimum face attempts for an object

* Set upper bound
2025-05-18 07:20:59 -05:00
Nicolas Mowen
f48356cbee
Fixes (#18245)
* Only check if an object is stationary to avoid mqtt snapshot

* docs heading tweak

* Add more API descriptions

* Add missing lib for new rocm onnxruntime whl

* Update inference times to reflect better rocm performance

* Cleanup resetting tracked object activity

* remove print

---------

Co-authored-by: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com>
2025-05-15 17:13:18 -05:00
Martin Weinelt
4d4d54d030
Fix various typing issues (#18187)
* Fix the `Any` typing hint treewide

There has been confusion between the Any type[1] and the any function[2]
in typing hints.

[1] https://docs.python.org/3/library/typing.html#typing.Any
[2] https://docs.python.org/3/library/functions.html#any

* Fix typing for various frame_shape members

Frame shapes are most likely defined by height and width, so a single int
cannot express that.

* Wrap gpu stats functions in Optional[]

These can return `None`, so they need to be `Type | None`, which is what
`Optional` expresses very nicely.

* Fix return type in get_latest_segment_datetime

Returns a datetime object, not an integer.

* Make the return type of FrameManager.write optional

This is necessary since the SharedMemoryFrameManager.write function can
return None.

* Fix total_seconds() return type in get_tz_modifiers

The function returns a float, not an int.

https://docs.python.org/3/library/datetime.html#datetime.timedelta.total_seconds

* Account for floating point results in to_relative_box

Because the function uses division the return types may either be int or
float.

* Resolve ruff deprecation warning

The config has been split into formatter and linter, and the global
options are deprecated.
2025-05-13 08:27:20 -06:00
Josh Hawkins
2c9bfaa49c
Fixes (#18176)
* Add camera name tooltip to previews in recording view

* Apply face area check to cv2 face detection

* Delete review thumbnails

* Don't import hailo until it is used

* Add comment

* Clean up camera name

* Filter out empty keys when updating yaml config

HA ingress seems to randomly add an equal sign to the PUT urls for updating the config from the UI. This fix prevents empty keys from being processed, but still allows empty values.

---------

Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>
2025-05-13 08:27:07 -06:00
Josh Hawkins
f39ddbc00d
Fixes (#18139)
* Catch error and show toast when failing to delete review items

* i18n keys

* add link to speed estimation docs in zone edit pane

* Implement reset of tracked object update for each camera

* Cleanup

* register mqtt callbacks for toggling alerts and detections

* clarify snapshots docs

* clarify semantic search reindexing

* add ukrainian

* adjust date granularity for last recording time

The api endpoint only returns granularity down to the day

* Add amd hardware

* fix crash in face library on initial start after enabling

* Fix recordings view for mobile landscape

The events view incorrectly was displaying two columns on landscape view and it only took up 20% of the screen width. Additionally, in landscape view the timeline was too wide (especially on iPads of various screen sizes) and would overlap the main video

* face rec overfitting instructions

* Clarify

* face docs

* clarify

* clarify

---------

Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>
2025-05-11 12:03:53 -06:00
Josh Hawkins
8094dd4075
Fixes (#18117)
* face library i18n fixes

* face library i18n fixes

* add ability to use ctrl/cmd S to save in the config editor

* Use datetime as ID

* Update metrics inference speed to start with 0 ms

* fix android formatted thumbnail

* ensure role is comma separated and stripped correctly

* improve face library deletion

- add a confirmation dialog
- add ability to select all / delete faces in collections

* Implement lazy loading for video previews

* Force GPU for large embedding model

* GPU is required

* settings i18n fixes

* Don't delete train tab

* webpush debugging logs

* Fix incorrectly copying zones

* copy path data

* Ensure that cache dir exists for Frigate+

* face docs update

* Add description to upload image step to clarify the image

* Clean up

---------

Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>
2025-05-09 07:36:44 -06:00
Josh Hawkins
ac8e647b92
Fixes (#18077)
* fix onvif reinitialization

* api docs: clarify usage of clip.mp4 endpoint

* Always show train tab

* Add description to API

* catch lpr model inference exceptions

* always apply motion mask when using yolov9 plate detection

* lpr faq

* fix incorrect focus when reopening search detail dialog on video tab

* only use keyboard listener in face library when train tab is active

---------

Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>
2025-05-07 16:31:24 -06:00
Josh Hawkins
1e079027ec
Assign requestor correctly (#17944) 2025-04-28 21:52:37 -05:00
Nicolas Mowen
4b4053d174
Add face and lpr to tracked object update topic (#17940)
* Send tracked object updates for face and license_plate objects

* Update docs

* Add to type enum

* Add camera to object description update

* Formatting

* Consolidate yue-Hant

* Add missing
2025-04-28 16:43:03 -06:00
Josh Hawkins
2610cfcfde
Classification config changes (#17892)
* Only auto-populate some config fields down to the camera level

- Don't populate LPR and face global-only settings down to the camera level
- Ensure LPR mixin uses camera level min_area
- Explicitly forbid extra config values for LPR and face

* lpr docs tweak

* remove extra text already in i18n key

* consistency
2025-04-24 07:30:10 -06:00
Josh Hawkins
14a32a6472
LPR tweaks (#17783)
* clarify docs

* improve debugging messages

* don't run any lpr postprocessing

* wording
2025-04-18 07:45:37 -06:00
Josh Hawkins
760ed25f0c
LPR improvements (#17716)
* add support for multi-line plates

* config for model size

* default to small model

* add license plate as attribute to motorcycle

* use model size

* docs

* attribute map

* i18n key fix
2025-04-15 09:40:12 -06:00
Josh Hawkins
664889d487
Small tweaks (#17651)
* clarify lpr

* add license plate icon and correctly format string
2025-04-11 06:48:16 -06:00
Josh Hawkins
921908fe33
LPR device selection (#17592)
* config changes

* use device

* docs

* docs

* reset state

* remove auto

* use device

* docs
2025-04-07 19:30:08 -06:00
Josh Hawkins
cb27bdb2f7
LPR fixes (#17588)
* docs

* docs

* docs

* docs

* fix box merging logic

* always run paddleocr models on cpu

* docs clarity

* fix docs

* docs
2025-04-07 15:25:46 -05:00
Josh Hawkins
348e728220
LPR improvements (#17549)
* auto select LPR model backend for inference

* docs update
2025-04-05 11:03:17 -05:00
Josh Hawkins
7917ec611a
LPR tweaks (#17536)
* Merge nearby horizontal boxes

* only publish to recognized plate field if object already has a sub label

* don't overwrite sub labels in any situation

* always publish sub label if it's a known plate
2025-04-04 12:42:49 -05:00
Nicolas Mowen
e94b24ec39
Face fixes (#17530)
* Catch - in name

* Add note about docs
2025-04-04 07:03:08 -06:00
Nicolas Mowen
207d1d2806
Face UI cleanup (#17472)
* Add note

* Sort by event id

* Fix reprocess causing shift

* Move event group to separate comp

* Handle selecting events

* implement event selection

* Implement selected handler

* handle right click

* Toggle ctrl + a

* Stop propogation

* Fix
2025-03-31 16:49:56 -05:00
Josh Hawkins
2920127ada
Dedicated LPR improvements (#17453)
* remove license plate from attributes for dedicated lpr cameras

* ensure we always have a color

* use frigate+ models with dedicated lpr cameras

* docs

* docs clarity

* docs enrichments

* use license_plate as object type
2025-03-30 07:43:24 -06:00
Nicolas Mowen
9e8b85a957
Implement enchrichments events per second graph (#17436)
* Cleanup existing naming

* Add face recognitions per second

* Add lpr fps

* Add all eps

* Clean up line graph

* Translations

* Change wording

* Fix incorrect access

* Don't require plates

* Add comment

* Fix
2025-03-28 18:13:35 -05:00
Nicolas Mowen
b14abffea3
Refactor face library page (#17424)
* Section faces by event id

* Make score keeping more robust

* layout improvements

* Cleanup dialog

* Fix clicking behavior

* Add view in explore option

* math.round

* Don't require events

* Cleanup

* Remove selection

* Don't require

* Change dialog size with snapshot

* Use filename as key

* fix key

* Rework layout for mobile

* Handle mobile landscape

* Fix train issue

* Match logic

* Move deletion logic

* Fix reprocessing

* Support creating a new face

* Translations

* Do sorting in frontend

* Adjust unknown

* Cleanup

* Set max limit to faces to recognize

* Fix sorting

* Fix
2025-03-28 13:52:12 -05:00
Josh Hawkins
37e0b9b904
LPR tweaks (#17428)
* fix snapshot when using dedicated lpr

* enhancement and debugging config

* docs
2025-03-28 06:29:11 -06:00
Nicolas Mowen
3f1b4438e4
Ensure landmark detector has a defualt value (#17420) 2025-03-27 13:41:22 -06:00
Josh Hawkins
6ec7d96ec9
remove LPR denoising (#17412) 2025-03-27 08:49:10 -06:00
Nicolas Mowen
a35146ab61
Various fixes (#17411)
* Remove initial requirement for history

* Clenaup conf

* Handle symlinks
2025-03-27 08:28:09 -06:00
Josh Hawkins
1233bc3a42
Miscellaneous fixes (#17406)
* add config validator for face and lpr

* more lpr docs tweaks

* fix object lifecycle point clicking for aspect ratios less than 16/9

* fix semantic search indexing i18n keys

* remove ability to set system language

* clarify debug output
2025-03-27 05:49:14 -06:00
Nicolas Mowen
36446ceded
Implement facenet tflite for small face recognition model (#17402) 2025-03-27 06:31:29 -05:00
Nicolas Mowen
ff34739f40
Face recognition bug fixes (#17401)
* Simplify normalization

* Fix confidence check
2025-03-26 19:43:10 -05:00
Nicolas Mowen
e6936c177b
Face model loading improvements (#17390)
* Don't assume landmark file is downloaded

* Rewrite build model task to be asynchronous so it doesn't block the pipeline

* Handle case where face recognition does not respond

* Cleanup

* Make daemon thread
2025-03-26 10:00:23 -06:00