From c0124938b3cad696fc198b1b96a39a37df372fda Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Wed, 25 Mar 2026 14:14:32 -0500 Subject: [PATCH] Tweaks (#22630) * fix stage overlay size * add audio filter config and load audio labels * remove add button from object and audio labels in settings * tests * update classification docs * tweak wording * don't require restart for timestamp_style changes * add optional i18n prefix for select widgets * use i18n enum prefix for timestamp position * add i18n for all presets --- .../object_classification.md | 13 +++- .../state_classification.md | 13 +++- frigate/config/camera/updater.py | 3 + frigate/config/config.py | 19 +++++- frigate/test/test_config.py | 61 ++++++++++++++++++- frigate/track/object_processing.py | 1 + web/public/locales/en/config/global.json | 2 +- web/public/locales/en/views/settings.json | 23 ++++++- .../config-form/section-configs/audio.ts | 10 +++ .../config-form/section-configs/objects.ts | 5 ++ .../section-configs/timestamp_style.ts | 5 +- .../theme/widgets/SelectWidget.tsx | 12 +++- web/src/views/live/LiveCameraView.tsx | 13 +++- 13 files changed, 168 insertions(+), 12 deletions(-) diff --git a/docs/docs/configuration/custom_classification/object_classification.md b/docs/docs/configuration/custom_classification/object_classification.md index caf05d8f3..7b5d73d75 100644 --- a/docs/docs/configuration/custom_classification/object_classification.md +++ b/docs/docs/configuration/custom_classification/object_classification.md @@ -102,8 +102,19 @@ If examples for some of your classes do not appear in the grid, you can continue ### Improving the Model +:::tip Diversity matters far more than volume + +Selecting dozens of nearly identical images is one of the fastest ways to degrade model performance. MobileNetV2 can overfit quickly when trained on homogeneous data — the model learns what *that exact moment* looked like rather than what actually defines the class. **This is why Frigate does not implement bulk training in the UI.** + +For more detail, see [Frigate Tip: Best Practices for Training Face and Custom Classification Models](https://github.com/blakeblackshear/frigate/discussions/21374). + +::: + +- **Start small and iterate**: Begin with a small, representative set of images per class. Models often begin working well with surprisingly few examples and improve naturally over time. +- **Favor hard examples**: When images appear in the Recent Classifications tab, prioritize images scoring below 90–100% or those captured under new lighting, weather, or distance conditions. +- **Avoid bulk training similar images**: Training large batches of images that already score 100% (or close) adds little new information and increases the risk of overfitting. +- **The wizard is just the starting point**: You don’t need to find and label every class upfront. Missing classes will naturally appear in Recent Classifications, and those images tend to be more valuable because they represent new conditions and edge cases. - **Problem framing**: Keep classes visually distinct and relevant to the chosen object types. -- **Data collection**: Use the model’s Recent Classification tab to gather balanced examples across times of day, weather, and distances. - **Preprocessing**: Ensure examples reflect object crops similar to Frigate’s boxes; keep the subject centered. - **Labels**: Keep label names short and consistent; include a `none` class if you plan to ignore uncertain predictions for sub labels. - **Threshold**: Tune `threshold` per model to reduce false assignments. Start at `0.8` and adjust based on validation. diff --git a/docs/docs/configuration/custom_classification/state_classification.md b/docs/docs/configuration/custom_classification/state_classification.md index c41d05439..3cadd9054 100644 --- a/docs/docs/configuration/custom_classification/state_classification.md +++ b/docs/docs/configuration/custom_classification/state_classification.md @@ -70,10 +70,21 @@ Once some images are assigned, training will begin automatically. ### Improving the Model +:::tip Diversity matters far more than volume + +Selecting dozens of nearly identical images is one of the fastest ways to degrade model performance. MobileNetV2 can overfit quickly when trained on homogeneous data — the model learns what *that exact moment* looked like rather than what actually defines the state. This often leads to models that work perfectly under the original conditions but become unstable when day turns to night, weather changes, or seasonal lighting shifts. **This is why Frigate does not implement bulk training in the UI.** + +For more detail, see [Frigate Tip: Best Practices for Training Face and Custom Classification Models](https://github.com/blakeblackshear/frigate/discussions/21374). + +::: + +- **Start small and iterate**: Begin with a small, representative set of images per class. Models often begin working well with surprisingly few examples and improve naturally over time. - **Problem framing**: Keep classes visually distinct and state-focused (e.g., `open`, `closed`, `unknown`). Avoid combining object identity with state in a single model unless necessary. - **Data collection**: Use the model's Recent Classifications tab to gather balanced examples across times of day and weather. - **When to train**: Focus on cases where the model is entirely incorrect or flips between states when it should not. There's no need to train additional images when the model is already working consistently. -- **Selecting training images**: Images scoring below 100% due to new conditions (e.g., first snow of the year, seasonal changes) or variations (e.g., objects temporarily in view, insects at night) are good candidates for training, as they represent scenarios different from the default state. Training these lower-scoring images that differ from existing training data helps prevent overfitting. Avoid training large quantities of images that look very similar, especially if they already score 100% as this can lead to overfitting. +- **Favor hard examples**: When images appear in the Recent Classifications tab, prioritize images scoring below 90–100% or those captured under new conditions (e.g., first snow of the year, seasonal changes, objects temporarily in view, insects at night). These represent scenarios different from the default state and help prevent overfitting. +- **Avoid bulk training similar images**: Training large batches of images that already score 100% (or close) adds little new information and increases the risk of overfitting. +- **The wizard is just the starting point**: You don't need to find and label every state upfront. Missing states will naturally appear in Recent Classifications, and those images tend to be more valuable because they represent new conditions and edge cases. ## Debugging Classification Models diff --git a/frigate/config/camera/updater.py b/frigate/config/camera/updater.py index 6474edf43..1965f3813 100644 --- a/frigate/config/camera/updater.py +++ b/frigate/config/camera/updater.py @@ -32,6 +32,7 @@ class CameraConfigUpdateEnum(str, Enum): face_recognition = "face_recognition" lpr = "lpr" snapshots = "snapshots" + timestamp_style = "timestamp_style" zones = "zones" @@ -133,6 +134,8 @@ class CameraConfigUpdateSubscriber: config.snapshots = updated_config elif update_type == CameraConfigUpdateEnum.onvif: config.onvif = updated_config + elif update_type == CameraConfigUpdateEnum.timestamp_style: + config.timestamp_style = updated_config elif update_type == CameraConfigUpdateEnum.zones: config.zones = updated_config diff --git a/frigate/config/config.py b/frigate/config/config.py index 19d0b73a3..d1b037509 100644 --- a/frigate/config/config.py +++ b/frigate/config/config.py @@ -25,6 +25,7 @@ from frigate.plus import PlusApi from frigate.util.builtin import ( deep_merge, get_ffmpeg_arg_list, + load_labels, ) from frigate.util.config import ( CURRENT_CONFIG_VERSION, @@ -40,7 +41,7 @@ from frigate.util.services import auto_detect_hwaccel from .auth import AuthConfig from .base import FrigateBaseModel from .camera import CameraConfig, CameraLiveConfig -from .camera.audio import AudioConfig +from .camera.audio import AudioConfig, AudioFilterConfig from .camera.birdseye import BirdseyeConfig from .camera.detect import DetectConfig from .camera.ffmpeg import FfmpegConfig @@ -473,7 +474,7 @@ class FrigateConfig(FrigateBaseModel): live: CameraLiveConfig = Field( default_factory=CameraLiveConfig, title="Live playback", - description="Settings used by the Web UI to control live stream resolution and quality.", + description="Settings to control the jsmpeg live stream resolution and quality. This does not affect restreamed cameras that use go2rtc for live view.", ) motion: Optional[MotionConfig] = Field( default=None, @@ -671,6 +672,12 @@ class FrigateConfig(FrigateBaseModel): detector_config.model = model self.detectors[key] = detector_config + all_audio_labels = { + label + for label in load_labels("/audio-labelmap.txt", prefill=521).values() + if label + } + for name, camera in self.cameras.items(): modified_global_config = global_config.copy() @@ -791,6 +798,14 @@ class FrigateConfig(FrigateBaseModel): camera_config.review.genai.enabled ) + if camera_config.audio.filters is None: + camera_config.audio.filters = {} + + audio_keys = all_audio_labels + audio_keys = audio_keys - camera_config.audio.filters.keys() + for key in audio_keys: + camera_config.audio.filters[key] = AudioFilterConfig() + # Add default filters object_keys = camera_config.objects.track if camera_config.objects.filters is None: diff --git a/frigate/test/test_config.py b/frigate/test/test_config.py index 61184c769..132be131f 100644 --- a/frigate/test/test_config.py +++ b/frigate/test/test_config.py @@ -10,7 +10,7 @@ from ruamel.yaml.constructor import DuplicateKeyError from frigate.config import BirdseyeModeEnum, FrigateConfig from frigate.const import MODEL_CACHE_DIR from frigate.detectors import DetectorTypeEnum -from frigate.util.builtin import deep_merge +from frigate.util.builtin import deep_merge, load_labels class TestConfig(unittest.TestCase): @@ -288,6 +288,65 @@ class TestConfig(unittest.TestCase): frigate_config = FrigateConfig(**config) assert "dog" in frigate_config.cameras["back"].objects.filters + def test_default_audio_filters(self): + config = { + "mqtt": {"host": "mqtt"}, + "audio": {"listen": ["speech", "yell"]}, + "cameras": { + "back": { + "ffmpeg": { + "inputs": [ + {"path": "rtsp://10.0.0.1:554/video", "roles": ["detect"]} + ] + }, + "detect": { + "height": 1080, + "width": 1920, + "fps": 5, + }, + } + }, + } + + frigate_config = FrigateConfig(**config) + all_audio_labels = { + label + for label in load_labels("/audio-labelmap.txt", prefill=521).values() + if label + } + + assert all_audio_labels.issubset( + set(frigate_config.cameras["back"].audio.filters.keys()) + ) + + def test_override_audio_filters(self): + config = { + "mqtt": {"host": "mqtt"}, + "cameras": { + "back": { + "ffmpeg": { + "inputs": [ + {"path": "rtsp://10.0.0.1:554/video", "roles": ["detect"]} + ] + }, + "detect": { + "height": 1080, + "width": 1920, + "fps": 5, + }, + "audio": { + "listen": ["speech", "yell"], + "filters": {"speech": {"threshold": 0.9}}, + }, + } + }, + } + + frigate_config = FrigateConfig(**config) + assert "speech" in frigate_config.cameras["back"].audio.filters + assert frigate_config.cameras["back"].audio.filters["speech"].threshold == 0.9 + assert "babbling" in frigate_config.cameras["back"].audio.filters + def test_inherit_object_filters(self): config = { "mqtt": {"host": "mqtt"}, diff --git a/frigate/track/object_processing.py b/frigate/track/object_processing.py index 1a15e27ee..3fae8da6f 100644 --- a/frigate/track/object_processing.py +++ b/frigate/track/object_processing.py @@ -81,6 +81,7 @@ class TrackedObjectProcessor(threading.Thread): CameraConfigUpdateEnum.motion, CameraConfigUpdateEnum.objects, CameraConfigUpdateEnum.remove, + CameraConfigUpdateEnum.timestamp_style, CameraConfigUpdateEnum.zones, ], ) diff --git a/web/public/locales/en/config/global.json b/web/public/locales/en/config/global.json index e653818fa..7ca564ee6 100644 --- a/web/public/locales/en/config/global.json +++ b/web/public/locales/en/config/global.json @@ -752,7 +752,7 @@ }, "live": { "label": "Live playback", - "description": "Settings used by the Web UI to control live stream resolution and quality.", + "description": "Settings to control the jsmpeg live stream resolution and quality. This does not affect restreamed cameras that use go2rtc for live view.", "streams": { "label": "Live stream names", "description": "Mapping of configured stream names to restream/go2rtc names used for live playback." diff --git a/web/public/locales/en/views/settings.json b/web/public/locales/en/views/settings.json index 4109b4821..e5c2c7851 100644 --- a/web/public/locales/en/views/settings.json +++ b/web/public/locales/en/views/settings.json @@ -825,6 +825,12 @@ "area": "Area" } }, + "timestampPosition": { + "tl": "Top left", + "tr": "Top right", + "bl": "Bottom left", + "br": "Bottom right" + }, "users": { "title": "Users", "management": { @@ -1342,7 +1348,22 @@ "preset-nvidia": "NVIDIA GPU", "preset-jetson-h264": "NVIDIA Jetson (H.264)", "preset-jetson-h265": "NVIDIA Jetson (H.265)", - "preset-rkmpp": "Rockchip RKMPP" + "preset-rkmpp": "Rockchip RKMPP", + "preset-http-jpeg-generic": "HTTP JPEG (Generic)", + "preset-http-mjpeg-generic": "HTTP MJPEG (Generic)", + "preset-http-reolink": "HTTP - Reolink Cameras", + "preset-rtmp-generic": "RTMP (Generic)", + "preset-rtsp-generic": "RTSP (Generic)", + "preset-rtsp-restream": "RTSP - Restream from go2rtc", + "preset-rtsp-restream-low-latency": "RTSP - Restream from go2rtc (Low Latency)", + "preset-rtsp-udp": "RTSP - UDP", + "preset-rtsp-blue-iris": "RTSP - Blue Iris", + "preset-record-generic": "Record (Generic, no audio)", + "preset-record-generic-audio-copy": "Record (Generic + Copy Audio)", + "preset-record-generic-audio-aac": "Record (Generic + Audio to AAC)", + "preset-record-mjpeg": "Record - MJPEG Cameras", + "preset-record-jpeg": "Record - JPEG Cameras", + "preset-record-ubiquiti": "Record - Ubiquiti Cameras" } }, "cameraInputs": { diff --git a/web/src/components/config-form/section-configs/audio.ts b/web/src/components/config-form/section-configs/audio.ts index 740d76f78..a112fa0db 100644 --- a/web/src/components/config-form/section-configs/audio.ts +++ b/web/src/components/config-form/section-configs/audio.ts @@ -19,6 +19,16 @@ const audio: SectionConfigOverrides = { hiddenFields: ["enabled_in_config"], advancedFields: ["min_volume", "max_not_heard", "num_threads"], uiSchema: { + filters: { + "ui:options": { + expandable: false, + }, + }, + "filters.*": { + "ui:options": { + additionalPropertyKeyReadonly: true, + }, + }, listen: { "ui:widget": "audioLabels", }, diff --git a/web/src/components/config-form/section-configs/objects.ts b/web/src/components/config-form/section-configs/objects.ts index bf5f6c350..e30ddf9d9 100644 --- a/web/src/components/config-form/section-configs/objects.ts +++ b/web/src/components/config-form/section-configs/objects.ts @@ -29,6 +29,11 @@ const objects: SectionConfigOverrides = { ], advancedFields: ["genai"], uiSchema: { + filters: { + "ui:options": { + expandable: false, + }, + }, "filters.*.min_area": { "ui:options": { suppressMultiSchema: true, diff --git a/web/src/components/config-form/section-configs/timestamp_style.ts b/web/src/components/config-form/section-configs/timestamp_style.ts index 2f51b2416..e43373c26 100644 --- a/web/src/components/config-form/section-configs/timestamp_style.ts +++ b/web/src/components/config-form/section-configs/timestamp_style.ts @@ -4,12 +4,13 @@ const timestampStyle: SectionConfigOverrides = { base: { sectionDocs: "/configuration/reference", restartRequired: [], - fieldOrder: ["position", "format", "color", "thickness"], + fieldOrder: ["position", "format", "thickness", "color"], hiddenFields: ["effect", "enabled_in_config"], advancedFields: [], uiSchema: { position: { "ui:size": "xs", + "ui:options": { enumI18nPrefix: "timestampPosition" }, }, format: { "ui:size": "xs", @@ -17,7 +18,7 @@ const timestampStyle: SectionConfigOverrides = { }, }, global: { - restartRequired: ["position", "format", "color", "thickness", "effect"], + restartRequired: [], }, camera: { restartRequired: [], diff --git a/web/src/components/config-form/theme/widgets/SelectWidget.tsx b/web/src/components/config-form/theme/widgets/SelectWidget.tsx index d5047e959..46c2d0701 100644 --- a/web/src/components/config-form/theme/widgets/SelectWidget.tsx +++ b/web/src/components/config-form/theme/widgets/SelectWidget.tsx @@ -1,5 +1,6 @@ // Select Widget - maps to shadcn/ui Select import type { WidgetProps } from "@rjsf/utils"; +import { useTranslation } from "react-i18next"; import { Select, SelectContent, @@ -21,9 +22,18 @@ export function SelectWidget(props: WidgetProps) { schema, } = props; + const { t } = useTranslation(["views/settings"]); const { enumOptions = [] } = options; + const enumI18nPrefix = options["enumI18nPrefix"] as string | undefined; const fieldClassName = getSizedFieldClassName(options, "sm"); + const getLabel = (option: { value: unknown; label: string }) => { + if (enumI18nPrefix) { + return t(`${enumI18nPrefix}.${option.value}`); + } + return option.label; + }; + return (