Use the dynamic label map

This commit is contained in:
Nicolas Mowen 2024-09-28 07:39:06 -06:00
parent 0036a85523
commit 7931203261
3 changed files with 7 additions and 5 deletions

View File

@ -15,7 +15,7 @@ PLUS_API_HOST = "https://api.frigate.video"
# Attribute & Object constants # Attribute & Object constants
ATTRIBUTE_LABEL_MAP = { DEFAULT_ATTRIBUTE_LABEL_MAP = {
"person": ["amazon", "face"], "person": ["amazon", "face"],
"car": ["amazon", "fedex", "license_plate", "ups"], "car": ["amazon", "fedex", "license_plate", "ups"],
} }

View File

@ -9,7 +9,7 @@ import requests
from pydantic import BaseModel, ConfigDict, Field from pydantic import BaseModel, ConfigDict, Field
from pydantic.fields import PrivateAttr from pydantic.fields import PrivateAttr
from frigate.const import ATTRIBUTE_LABEL_MAP from frigate.const import DEFAULT_ATTRIBUTE_LABEL_MAP
from frigate.plus import PlusApi from frigate.plus import PlusApi
from frigate.util.builtin import generate_color_palette, load_labels from frigate.util.builtin import generate_color_palette, load_labels
@ -130,7 +130,10 @@ class ModelConfig(BaseModel):
self.model_type = model_info["type"] self.model_type = model_info["type"]
# generate list of attribute labels # generate list of attribute labels
self.attributes_map = model_info.get("attributes", ATTRIBUTE_LABEL_MAP) self.attributes_map = {
**model_info.get("attributes", DEFAULT_ATTRIBUTE_LABEL_MAP),
**self.attributes_map,
}
unique_attributes = set() unique_attributes = set()
for attributes in self.attributes_map.values(): for attributes in self.attributes_map.values():

View File

@ -16,7 +16,6 @@ from frigate.comms.config_updater import ConfigSubscriber
from frigate.comms.inter_process import InterProcessRequestor from frigate.comms.inter_process import InterProcessRequestor
from frigate.config import CameraConfig, DetectConfig, ModelConfig from frigate.config import CameraConfig, DetectConfig, ModelConfig
from frigate.const import ( from frigate.const import (
ATTRIBUTE_LABEL_MAP,
CACHE_DIR, CACHE_DIR,
CACHE_SEGMENT_FORMAT, CACHE_SEGMENT_FORMAT,
REQUEST_REGION_GRID, REQUEST_REGION_GRID,
@ -736,7 +735,7 @@ def process_frames(
# group the attribute detections based on what label they apply to # group the attribute detections based on what label they apply to
attribute_detections = {} attribute_detections = {}
for label, attribute_labels in ATTRIBUTE_LABEL_MAP.items(): for label, attribute_labels in model_config.attributes_map.items():
attribute_detections[label] = [ attribute_detections[label] = [
d for d in consolidated_detections if d[0] in attribute_labels d for d in consolidated_detections if d[0] in attribute_labels
] ]