From 6e332bbdf8600dc22a297d5098281d6e3d141f69 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Fri, 11 Oct 2024 16:08:14 -0600 Subject: [PATCH] Remove device config and use model size to configure device used (#14290) * Remove device config and use model size to configure device used * Don't show Frigate+ submission when in progress * Add docs link for bounding box colors --- docs/docs/configuration/reference.md | 3 +-- docs/docs/configuration/semantic_search.md | 15 ++++++++------- frigate/config/semantic_search.py | 1 - frigate/embeddings/embeddings.py | 2 +- .../overlay/detail/SearchDetailDialog.tsx | 2 +- web/src/views/settings/ObjectSettingsView.tsx | 13 +++++++++++++ 6 files changed, 24 insertions(+), 12 deletions(-) diff --git a/docs/docs/configuration/reference.md b/docs/docs/configuration/reference.md index 234478714..604791621 100644 --- a/docs/docs/configuration/reference.md +++ b/docs/docs/configuration/reference.md @@ -518,9 +518,8 @@ semantic_search: enabled: False # Optional: Re-index embeddings database from historical tracked objects (default: shown below) reindex: False - # Optional: Set device used to run embeddings, options are AUTO, CPU, GPU. (default: shown below) - device: "AUTO" # Optional: Set the model size used for embeddings. (default: shown below) + # NOTE: small model runs on CPU and large model runs on GPU model_size: "small" # Optional: Configuration for AI generated tracked object descriptions diff --git a/docs/docs/configuration/semantic_search.md b/docs/docs/configuration/semantic_search.md index 87ccbf802..a569e8f1a 100644 --- a/docs/docs/configuration/semantic_search.md +++ b/docs/docs/configuration/semantic_search.md @@ -29,25 +29,26 @@ If you are enabling the Search feature for the first time, be advised that Friga ### Jina AI CLIP -:::tip - -The CLIP models are downloaded in ONNX format, which means they will be accelerated using GPU hardware when available. This depends on the Docker build that is used. See [the object detector docs](../configuration/object_detectors.md) for more information. - -::: - The vision model is able to embed both images and text into the same vector space, which allows `image -> image` and `text -> image` similarity searches. Frigate uses this model on tracked objects to encode the thumbnail image and store it in the database. When searching for tracked objects via text in the search box, Frigate will perform a `text -> image` similarity search against this embedding. When clicking "Find Similar" in the tracked object detail pane, Frigate will perform an `image -> image` similarity search to retrieve the closest matching thumbnails. The text model is used to embed tracked object descriptions and perform searches against them. Descriptions can be created, viewed, and modified on the Search page when clicking on the gray tracked object chip at the top left of each review item. See [the Generative AI docs](/configuration/genai.md) for more information on how to automatically generate tracked object descriptions. Differently weighted CLIP models are available and can be selected by setting the `model_size` config option: +:::tip + +The CLIP models are downloaded in ONNX format, which means they will be accelerated using GPU hardware when available. This depends on the Docker build that is used. See [the object detector docs](../configuration/object_detectors.md) for more information. + +::: + ```yaml semantic_search: enabled: True model_size: small ``` -Using `large` as the model size setting employs the full Jina model appropriate for high performance systems running a GPU. The `small` size uses a quantized version of the model that uses much less RAM and runs faster on CPU with a very negligible difference in embedding quality. Most users will not need to change this setting from the default of `small`. +- Configuring the `large` model employs the full Jina model and will automatically run on the GPU if applicable. +- Configuring the `small` model employs a quantized version of the model that uses much less RAM and runs faster on CPU with a very negligible difference in embedding quality. ## Usage diff --git a/frigate/config/semantic_search.py b/frigate/config/semantic_search.py index fdaf0fff4..2891050a1 100644 --- a/frigate/config/semantic_search.py +++ b/frigate/config/semantic_search.py @@ -12,7 +12,6 @@ class SemanticSearchConfig(FrigateBaseModel): reindex: Optional[bool] = Field( default=False, title="Reindex all detections on startup." ) - device: str = Field(default="AUTO", title="Device Type") model_size: str = Field( default="small", title="The size of the embeddings model used." ) diff --git a/frigate/embeddings/embeddings.py b/frigate/embeddings/embeddings.py index 4883e0914..9c8d4abbd 100644 --- a/frigate/embeddings/embeddings.py +++ b/frigate/embeddings/embeddings.py @@ -127,7 +127,7 @@ class Embeddings: model_size=config.model_size, model_type="vision", requestor=self.requestor, - device=self.config.device, + device="GPU" if config.model_size == "large" else "CPU", ) def upsert_thumbnail(self, event_id: str, thumbnail: bytes): diff --git a/web/src/components/overlay/detail/SearchDetailDialog.tsx b/web/src/components/overlay/detail/SearchDetailDialog.tsx index 843f2de59..4063f3a59 100644 --- a/web/src/components/overlay/detail/SearchDetailDialog.tsx +++ b/web/src/components/overlay/detail/SearchDetailDialog.tsx @@ -554,7 +554,7 @@ function ObjectSnapshotTab({
- {state == "reviewing" && ( + {state == "reviewing" && search.end_time && ( <>