mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-09-26 20:18:58 +03:00
Refactor detector and model management (#23995)
* Refactor detector and model management * Fix model resolution field
This commit is contained in:
@@ -13,6 +13,7 @@ import { cn } from "@/lib/utils";
|
||||
import { TooltipPortal } from "@radix-ui/react-tooltip";
|
||||
import useContextMenu from "@/hooks/use-contextmenu";
|
||||
import { getTranslatedLabel } from "@/utils/i18n";
|
||||
import { isAttributeOfLabel } from "@/utils/modelUtil";
|
||||
|
||||
type SearchThumbnailProps = {
|
||||
searchResult: SearchResult;
|
||||
@@ -58,9 +59,7 @@ export default function SearchThumbnail({
|
||||
}
|
||||
|
||||
if (
|
||||
config.model.attributes_map[searchResult.label]?.includes(
|
||||
searchResult.sub_label,
|
||||
)
|
||||
isAttributeOfLabel(config, searchResult.label, searchResult.sub_label)
|
||||
) {
|
||||
return searchResult.sub_label;
|
||||
}
|
||||
@@ -82,9 +81,7 @@ export default function SearchThumbnail({
|
||||
}
|
||||
|
||||
if (
|
||||
config.model.attributes_map[searchResult.label]?.includes(
|
||||
searchResult.sub_label,
|
||||
)
|
||||
isAttributeOfLabel(config, searchResult.label, searchResult.sub_label)
|
||||
) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import {
|
||||
} from "@/types/frigateConfig";
|
||||
import { ClassificationDatasetResponse } from "@/types/classification";
|
||||
import { getTranslatedLabel } from "@/utils/i18n";
|
||||
import { isAttributeLabel } from "@/utils/modelUtil";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import axios from "axios";
|
||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
@@ -99,7 +100,7 @@ export default function ClassificationModelEditDialog({
|
||||
}
|
||||
|
||||
cameraConfig.objects.track.forEach((label) => {
|
||||
if (!config.model.all_attributes.includes(label)) {
|
||||
if (!isAttributeLabel(config, label)) {
|
||||
labels.add(label);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -27,6 +27,7 @@ import useSWR from "swr";
|
||||
import { FrigateConfig } from "@/types/frigateConfig";
|
||||
import { getTranslatedLabel } from "@/utils/i18n";
|
||||
import { useDocDomain } from "@/hooks/use-doc-domain";
|
||||
import { isAttributeLabel } from "@/utils/modelUtil";
|
||||
import {
|
||||
Popover,
|
||||
PopoverContent,
|
||||
@@ -72,7 +73,7 @@ export default function Step1NameAndDefine({
|
||||
}
|
||||
|
||||
cameraConfig.objects.track.forEach((label) => {
|
||||
if (!config.model.all_attributes.includes(label)) {
|
||||
if (!isAttributeLabel(config, label)) {
|
||||
labels.add(label);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -19,23 +19,16 @@ function collectLabelmapLabels(labelmap: unknown, labels: Set<string>) {
|
||||
});
|
||||
}
|
||||
|
||||
// Read labelmap labels from the global model and detector models.
|
||||
// Read labelmap labels from every configured detection model.
|
||||
function getLabelmapLabels(context: FormContext): string[] {
|
||||
const labels = new Set<string>();
|
||||
const fullConfig = context.fullConfig as FrigateConfig | undefined;
|
||||
|
||||
if (fullConfig?.model) {
|
||||
collectLabelmapLabels(fullConfig.model.labelmap, labels);
|
||||
}
|
||||
|
||||
if (fullConfig?.detectors) {
|
||||
// detectors is a map of detector configs; each may include a model labelmap.
|
||||
Object.values(fullConfig.detectors).forEach((detector) => {
|
||||
if (detector?.model?.labelmap) {
|
||||
collectLabelmapLabels(detector.model.labelmap, labels);
|
||||
}
|
||||
});
|
||||
}
|
||||
fullConfig?.models?.forEach((model) => {
|
||||
if (model?.labelmap) {
|
||||
collectLabelmapLabels(model.labelmap, labels);
|
||||
}
|
||||
});
|
||||
|
||||
return [...labels];
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import { CalendarRangeFilterButton } from "./CalendarFilterButton";
|
||||
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { getTranslatedLabel } from "@/utils/i18n";
|
||||
import { isAttributeLabel } from "@/utils/modelUtil";
|
||||
import { useAllowedCameras } from "@/hooks/use-allowed-cameras";
|
||||
|
||||
type SearchFilterGroupProps = {
|
||||
@@ -73,7 +74,7 @@ export default function SearchFilterGroup({
|
||||
}
|
||||
|
||||
cameraConfig.objects.track.forEach((label) => {
|
||||
if (!config.model.all_attributes.includes(label)) {
|
||||
if (!isAttributeLabel(config, label)) {
|
||||
labels.add(label);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -13,6 +13,7 @@ import { cn } from "@/lib/utils";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Event } from "@/types/event";
|
||||
import { resolveZoneName } from "@/hooks/use-zone-friendly-name";
|
||||
import { getPrimaryModel } from "@/utils/modelUtil";
|
||||
|
||||
// Use a small tolerance (10ms) for browsers with seek precision by-design issues
|
||||
const TOLERANCE = 0.01;
|
||||
@@ -178,7 +179,7 @@ export default function ObjectTrackOverlay({
|
||||
|
||||
const getObjectColor = useCallback(
|
||||
(label: string, objectId: string) => {
|
||||
const objectColor = config?.model?.colormap[label];
|
||||
const objectColor = getPrimaryModel(config)?.colormap?.[label];
|
||||
if (objectColor) {
|
||||
const reversed = [...objectColor].reverse();
|
||||
return `rgb(${reversed.join(",")})`;
|
||||
|
||||
Reference in New Issue
Block a user