mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-05-09 15:05:26 +03:00
Change Semantic Search reindex to reindex_on_startup
This commit is contained in:
parent
1233bc3a42
commit
73cd861a14
@ -535,7 +535,8 @@ semantic_search:
|
|||||||
# Optional: Enable semantic search (default: shown below)
|
# Optional: Enable semantic search (default: shown below)
|
||||||
enabled: False
|
enabled: False
|
||||||
# Optional: Re-index embeddings database from historical tracked objects (default: shown below)
|
# Optional: Re-index embeddings database from historical tracked objects (default: shown below)
|
||||||
reindex: False
|
# Resets on successful completion
|
||||||
|
reindex_next_startup: False
|
||||||
# Optional: Set the model used for embeddings. (default: shown below)
|
# Optional: Set the model used for embeddings. (default: shown below)
|
||||||
model: "jinav1"
|
model: "jinav1"
|
||||||
# Optional: Set the model size used for embeddings. (default: shown below)
|
# Optional: Set the model size used for embeddings. (default: shown below)
|
||||||
|
|||||||
@ -24,14 +24,14 @@ Semantic Search is disabled by default, and must be enabled in your config file
|
|||||||
```yaml
|
```yaml
|
||||||
semantic_search:
|
semantic_search:
|
||||||
enabled: True
|
enabled: True
|
||||||
reindex: False
|
reindex_next_startup: False
|
||||||
```
|
```
|
||||||
|
|
||||||
:::tip
|
:::tip
|
||||||
|
|
||||||
The embeddings database can be re-indexed from the existing tracked objects in your database by adding `reindex: True` to your `semantic_search` configuration or by toggling the switch on the Search Settings page in the UI and restarting Frigate. Depending on the number of tracked objects you have, it can take a long while to complete and may max out your CPU while indexing. Make sure to turn the UI's switch off or set the config back to `False` before restarting Frigate again.
|
The embeddings database can be re-indexed from the existing tracked objects in your database by adding `reindex_next_startup: True` to your `semantic_search` configuration or by toggling the switch on the Search Settings page in the UI and restarting Frigate. Depending on the number of tracked objects you have, it can take a long while to complete and may max out your CPU while indexing. Once completed, this will automatically be set back to `False`.
|
||||||
|
|
||||||
If you are enabling Semantic Search for the first time, be advised that Frigate does not automatically index older tracked objects. You will need to enable the `reindex` feature in order to do that.
|
If you are enabling Semantic Search for the first time, be advised that Frigate does not automatically index older tracked objects. You will need to enable the `reindex_next_startup` feature in order to do that.
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
|
|||||||
@ -37,8 +37,9 @@ class ClassificationConfig(FrigateBaseModel):
|
|||||||
|
|
||||||
class SemanticSearchConfig(FrigateBaseModel):
|
class SemanticSearchConfig(FrigateBaseModel):
|
||||||
enabled: bool = Field(default=False, title="Enable semantic search.")
|
enabled: bool = Field(default=False, title="Enable semantic search.")
|
||||||
reindex: Optional[bool] = Field(
|
reindex_next_startup: Optional[bool] = Field(
|
||||||
default=False, title="Reindex all tracked objects on startup."
|
default=False,
|
||||||
|
title="Reindex all tracked objects on next startup. Resets to false on completion.",
|
||||||
)
|
)
|
||||||
model: Optional[SemanticSearchModelEnum] = Field(
|
model: Optional[SemanticSearchModelEnum] = Field(
|
||||||
default=SemanticSearchModelEnum.jinav1,
|
default=SemanticSearchModelEnum.jinav1,
|
||||||
|
|||||||
@ -20,7 +20,8 @@ from frigate.data_processing.types import DataProcessorMetrics
|
|||||||
from frigate.db.sqlitevecq import SqliteVecQueueDatabase
|
from frigate.db.sqlitevecq import SqliteVecQueueDatabase
|
||||||
from frigate.models import Event
|
from frigate.models import Event
|
||||||
from frigate.types import ModelStatusTypesEnum
|
from frigate.types import ModelStatusTypesEnum
|
||||||
from frigate.util.builtin import serialize
|
from frigate.util.builtin import serialize, update_yaml_file
|
||||||
|
from frigate.util.config import find_config_file
|
||||||
from frigate.util.path import get_event_thumbnail_bytes
|
from frigate.util.path import get_event_thumbnail_bytes
|
||||||
|
|
||||||
from .onnx.jina_v1_embedding import JinaV1ImageEmbedding, JinaV1TextEmbedding
|
from .onnx.jina_v1_embedding import JinaV1ImageEmbedding, JinaV1TextEmbedding
|
||||||
@ -367,4 +368,12 @@ class Embeddings:
|
|||||||
)
|
)
|
||||||
totals["status"] = "completed"
|
totals["status"] = "completed"
|
||||||
|
|
||||||
|
self.config.semantic_search.reindex_next_startup = False
|
||||||
|
|
||||||
|
update_yaml_file(
|
||||||
|
find_config_file(),
|
||||||
|
["semantic_search", "reindex_next_startup"],
|
||||||
|
False,
|
||||||
|
)
|
||||||
|
|
||||||
self.requestor.send_data(UPDATE_EMBEDDINGS_REINDEX_PROGRESS, totals)
|
self.requestor.send_data(UPDATE_EMBEDDINGS_REINDEX_PROGRESS, totals)
|
||||||
|
|||||||
@ -85,7 +85,7 @@ class EmbeddingMaintainer(threading.Thread):
|
|||||||
self.embeddings = Embeddings(config, db, metrics)
|
self.embeddings = Embeddings(config, db, metrics)
|
||||||
|
|
||||||
# Check if we need to re-index events
|
# Check if we need to re-index events
|
||||||
if config.semantic_search.reindex:
|
if config.semantic_search.reindex_next_startup:
|
||||||
self.embeddings.reindex()
|
self.embeddings.reindex()
|
||||||
|
|
||||||
# create communication for updating event descriptions
|
# create communication for updating event descriptions
|
||||||
|
|||||||
@ -89,7 +89,7 @@
|
|||||||
"readTheDocumentation": "Read the Documentation",
|
"readTheDocumentation": "Read the Documentation",
|
||||||
"reindexOnStartup": {
|
"reindexOnStartup": {
|
||||||
"label": "Re-Index On Startup",
|
"label": "Re-Index On Startup",
|
||||||
"desc": "Re-indexing will reprocess all thumbnails and descriptions (if enabled) and apply the embeddings on each startup. <em>Don't forget to disable the option after restarting!</em>"
|
"desc": "Re-indexing will reprocess all thumbnails and descriptions (if enabled) and apply the embeddings at next startup. This field will be reset after successfully completing."
|
||||||
},
|
},
|
||||||
"modelSize": {
|
"modelSize": {
|
||||||
"label": "Model Size",
|
"label": "Model Size",
|
||||||
|
|||||||
@ -486,7 +486,7 @@ export interface FrigateConfig {
|
|||||||
|
|
||||||
semantic_search: {
|
semantic_search: {
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
reindex: boolean;
|
reindex_next_startup: boolean;
|
||||||
model: SearchModel;
|
model: SearchModel;
|
||||||
model_size: SearchModelSize;
|
model_size: SearchModelSize;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -25,7 +25,7 @@ import { Trans, useTranslation } from "react-i18next";
|
|||||||
type ClassificationSettings = {
|
type ClassificationSettings = {
|
||||||
search: {
|
search: {
|
||||||
enabled?: boolean;
|
enabled?: boolean;
|
||||||
reindex?: boolean;
|
reindex_next_startup?: boolean;
|
||||||
model_size?: SearchModelSize;
|
model_size?: SearchModelSize;
|
||||||
};
|
};
|
||||||
face: {
|
face: {
|
||||||
@ -55,7 +55,7 @@ export default function ClassificationSettingsView({
|
|||||||
useState<ClassificationSettings>({
|
useState<ClassificationSettings>({
|
||||||
search: {
|
search: {
|
||||||
enabled: undefined,
|
enabled: undefined,
|
||||||
reindex: undefined,
|
reindex_next_startup: undefined,
|
||||||
model_size: undefined,
|
model_size: undefined,
|
||||||
},
|
},
|
||||||
face: {
|
face: {
|
||||||
@ -71,7 +71,7 @@ export default function ClassificationSettingsView({
|
|||||||
useState<ClassificationSettings>({
|
useState<ClassificationSettings>({
|
||||||
search: {
|
search: {
|
||||||
enabled: undefined,
|
enabled: undefined,
|
||||||
reindex: undefined,
|
reindex_next_startup: undefined,
|
||||||
model_size: undefined,
|
model_size: undefined,
|
||||||
},
|
},
|
||||||
face: {
|
face: {
|
||||||
@ -89,7 +89,7 @@ export default function ClassificationSettingsView({
|
|||||||
setClassificationSettings({
|
setClassificationSettings({
|
||||||
search: {
|
search: {
|
||||||
enabled: config.semantic_search.enabled,
|
enabled: config.semantic_search.enabled,
|
||||||
reindex: config.semantic_search.reindex,
|
reindex_next_startup: config.semantic_search.reindex_next_startup,
|
||||||
model_size: config.semantic_search.model_size,
|
model_size: config.semantic_search.model_size,
|
||||||
},
|
},
|
||||||
face: {
|
face: {
|
||||||
@ -105,7 +105,7 @@ export default function ClassificationSettingsView({
|
|||||||
setOrigSearchSettings({
|
setOrigSearchSettings({
|
||||||
search: {
|
search: {
|
||||||
enabled: config.semantic_search.enabled,
|
enabled: config.semantic_search.enabled,
|
||||||
reindex: config.semantic_search.reindex,
|
reindex_next_startup: config.semantic_search.reindex_next_startup,
|
||||||
model_size: config.semantic_search.model_size,
|
model_size: config.semantic_search.model_size,
|
||||||
},
|
},
|
||||||
face: {
|
face: {
|
||||||
@ -141,7 +141,7 @@ export default function ClassificationSettingsView({
|
|||||||
|
|
||||||
axios
|
axios
|
||||||
.put(
|
.put(
|
||||||
`config/set?semantic_search.enabled=${classificationSettings.search.enabled ? "True" : "False"}&semantic_search.reindex=${classificationSettings.search.reindex ? "True" : "False"}&semantic_search.model_size=${classificationSettings.search.model_size}&face_recognition.enabled=${classificationSettings.face.enabled ? "True" : "False"}&face_recognition.model_size=${classificationSettings.face.model_size}&lpr.enabled=${classificationSettings.lpr.enabled ? "True" : "False"}`,
|
`config/set?semantic_search.enabled=${classificationSettings.search.enabled ? "True" : "False"}&semantic_search.reindex_next_startup=${classificationSettings.search.reindex_next_startup ? "True" : "False"}&semantic_search.model_size=${classificationSettings.search.model_size}&face_recognition.enabled=${classificationSettings.face.enabled ? "True" : "False"}&face_recognition.model_size=${classificationSettings.face.model_size}&lpr.enabled=${classificationSettings.lpr.enabled ? "True" : "False"}`,
|
||||||
{
|
{
|
||||||
requires_restart: 0,
|
requires_restart: 0,
|
||||||
},
|
},
|
||||||
@ -267,11 +267,11 @@ export default function ClassificationSettingsView({
|
|||||||
<Switch
|
<Switch
|
||||||
id="reindex"
|
id="reindex"
|
||||||
className="mr-3"
|
className="mr-3"
|
||||||
disabled={classificationSettings.search.reindex === undefined}
|
disabled={classificationSettings.search.reindex_next_startup === undefined}
|
||||||
checked={classificationSettings.search.reindex === true}
|
checked={classificationSettings.search.reindex_next_startup === true}
|
||||||
onCheckedChange={(isChecked) => {
|
onCheckedChange={(isChecked) => {
|
||||||
handleClassificationConfigChange({
|
handleClassificationConfigChange({
|
||||||
search: { reindex: isChecked },
|
search: { reindex_next_startup: isChecked },
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user