keep Frigate+ model references when saving the models section

`/api/config` served a Frigate+ model's path as the resolved `/config/model_cache/<id>` file, and since the models list is saved whole, editing any model in the settings UI wrote that cache path back to the config in place of `plus://<id>`. After a restart the model loaded as a custom model with the default labelmap. The config API now reports the `plus://<id>` reference the model was configured with, and the models section drops the fields the Frigate+ model info supplies (size, tensor, pixel format, dtype, and type) instead of pinning them in the config.
This commit is contained in:
Josh Hawkins
2026-09-28 08:53:45 -05:00
parent 85a2731510
commit 225e014979
5 changed files with 81 additions and 4 deletions
@@ -7,6 +7,7 @@
*/
import { RJSFSchema } from "@rjsf/utils";
import { omit } from "lodash";
import { applySchemaDefaults } from "@/lib/config-schema";
import { isJsonObject } from "@/lib/utils";
import { HiddenFieldContext, JsonObject, JsonValue } from "@/types/configForm";
@@ -352,6 +353,17 @@ export function synthesizeMissingFilters(
return { ...(data as JsonObject), filters: newFilters };
}
// the backend fills these from the Frigate+ model info when it loads a
// plus:// model, so saving them would only pin values Frigate+ owns
const PLUS_SUPPLIED_MODEL_FIELDS = [
"width",
"height",
"input_tensor",
"input_pixel_format",
"input_dtype",
"model_type",
];
/**
* Sanitize overrides payloads for section-specific quirks.
*/
@@ -360,6 +372,21 @@ export function sanitizeOverridesForSection(
level: string,
overrides: unknown,
): unknown {
// the models list is saved whole
if (sectionPath === "models" && Array.isArray(overrides)) {
return overrides.map((model) => {
if (
!isJsonObject(model) ||
typeof model.path !== "string" ||
!model.path.startsWith("plus://")
) {
return model;
}
return omit(model, PLUS_SUPPLIED_MODEL_FIELDS);
});
}
if (!overrides || !isJsonObject(overrides)) {
return overrides;
}
@@ -38,9 +38,7 @@ function plusModelId(path: unknown): string | undefined {
type ModelSourcePickerProps = {
path: unknown;
// Frigate+ metadata the backend attaches to a saved model, and the only
// reliable signal that one is active: it resolves `plus://<id>` to a local
// cache path before serving the config back
// Frigate+ metadata the backend attaches to a saved model
plus?: { id: string } | null;
// the detector this model runs on, used to filter incompatible Plus models
detector?: string;