mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-03 17:55:21 +03:00
Only create colormap for enabled labels
This commit is contained in:
parent
417a42b0b3
commit
2185456ea5
@ -962,6 +962,12 @@ class FrigateConfig(FrigateBaseModel):
|
||||
camera_config.create_ffmpeg_cmds()
|
||||
config.cameras[name] = camera_config
|
||||
|
||||
# get list of unique enabled labels for tracking
|
||||
enabled_labels = set(config.objects.track)
|
||||
|
||||
for _, camera in config.cameras.items():
|
||||
enabled_labels.update(camera.objects.track)
|
||||
|
||||
for key, detector in config.detectors.items():
|
||||
detector_config: DetectorConfig = parse_obj_as(DetectorConfig, detector)
|
||||
if detector_config.model is None:
|
||||
@ -986,6 +992,7 @@ class FrigateConfig(FrigateBaseModel):
|
||||
config.model.dict(exclude_unset=True),
|
||||
)
|
||||
detector_config.model = ModelConfig.parse_obj(merged_model)
|
||||
detector_config.model.create_colormap(enabled_labels)
|
||||
config.detectors[key] = detector_config
|
||||
|
||||
return config
|
||||
|
||||
@ -55,11 +55,13 @@ class ModelConfig(BaseModel):
|
||||
**load_labels(config.get("labelmap_path", "/labelmap.txt")),
|
||||
**config.get("labelmap", {}),
|
||||
}
|
||||
|
||||
cmap = plt.cm.get_cmap("tab10", len(self._merged_labelmap.keys()))
|
||||
|
||||
self._colormap = {}
|
||||
for key, val in self._merged_labelmap.items():
|
||||
|
||||
def create_colormap(self, enabled_labels: set[str]) -> None:
|
||||
"""Get a list of colors for enabled labels."""
|
||||
cmap = plt.cm.get_cmap("tab10", len(enabled_labels))
|
||||
|
||||
for key, val in enumerate(enabled_labels):
|
||||
self._colormap[val] = tuple(int(round(255 * c)) for c in cmap(key)[:3])
|
||||
|
||||
class Config:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user