From 7d0ba3fd921e23cf61618255ba3c258d04e4afe4 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Sun, 7 Jul 2024 14:23:29 +0200 Subject: [PATCH] Update matplotlib to 3.9.x The mpl.cm toplevel registration has been removed. https://matplotlib.org/stable/api/prev_api_changes/api_changes_3.9.0.html#top-level-cmap-registration-and-access-functions-in-mpl-cm --- docker/main/requirements-wheels.txt | 2 +- frigate/config.py | 2 +- frigate/detectors/detector_config.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docker/main/requirements-wheels.txt b/docker/main/requirements-wheels.txt index 6c8a8629e..c823fada8 100644 --- a/docker/main/requirements-wheels.txt +++ b/docker/main/requirements-wheels.txt @@ -4,7 +4,7 @@ Flask_Limiter == 3.7.* imutils == 0.5.* joserfc == 0.11.* markupsafe == 2.1.* -matplotlib == 3.8.* +matplotlib == 3.9.* mypy == 1.6.1 numpy == 1.26.* onvif_zeep == 0.2.12 diff --git a/frigate/config.py b/frigate/config.py index 301aeeb95..3ccd25903 100644 --- a/frigate/config.py +++ b/frigate/config.py @@ -1033,7 +1033,7 @@ class CameraConfig(FrigateBaseModel): def __init__(self, **config): # Set zone colors if "zones" in config: - colors = plt.cm.get_cmap("tab10", len(config["zones"])) + colors = plt.colormaps["tab10"].resampled(len(config["zones"])) config["zones"] = { name: {**z, "color": tuple(round(255 * c) for c in colors(idx)[:3])} for idx, (name, z) in enumerate(config["zones"].items()) diff --git a/frigate/detectors/detector_config.py b/frigate/detectors/detector_config.py index 0952fff88..14359cc39 100644 --- a/frigate/detectors/detector_config.py +++ b/frigate/detectors/detector_config.py @@ -128,7 +128,7 @@ class ModelConfig(BaseModel): 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)) + cmap = plt.colormaps["tab10"].resampled(len(enabled_labels)) for key, val in enumerate(enabled_labels): self._colormap[val] = tuple(int(round(255 * c)) for c in cmap(key)[:3])