mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-02 06:23:42 +00:00
Dynamically add metrics for new model
This commit is contained in:
parent
4dd999dc74
commit
82c236f349
@ -10,6 +10,7 @@ from frigate.data_processing.real_time.whisper_online import FasterWhisperASR
|
||||
|
||||
|
||||
class DataProcessorMetrics:
|
||||
manager: SyncManager
|
||||
image_embeddings_speed: Synchronized
|
||||
image_embeddings_eps: Synchronized
|
||||
text_embeddings_speed: Synchronized
|
||||
@ -28,6 +29,7 @@ class DataProcessorMetrics:
|
||||
classification_cps: dict[str, Synchronized]
|
||||
|
||||
def __init__(self, manager: SyncManager, custom_classification_models: list[str]):
|
||||
self.manager = manager
|
||||
self.image_embeddings_speed = manager.Value("d", 0.0)
|
||||
self.image_embeddings_eps = manager.Value("d", 0.0)
|
||||
self.text_embeddings_speed = manager.Value("d", 0.0)
|
||||
@ -50,6 +52,12 @@ class DataProcessorMetrics:
|
||||
self.classification_speeds[key] = manager.Value("d", 0.0)
|
||||
self.classification_cps[key] = manager.Value("d", 0.0)
|
||||
|
||||
def add_classification_model(self, model_name: str) -> None:
|
||||
"""Add metrics for a new classification model dynamically."""
|
||||
if model_name not in self.classification_speeds:
|
||||
self.classification_speeds[model_name] = self.manager.Value("d", 0.0)
|
||||
self.classification_cps[model_name] = self.manager.Value("d", 0.0)
|
||||
|
||||
|
||||
class DataProcessorModelRunner:
|
||||
def __init__(self, requestor, device: str = "CPU", model_size: str = "large"):
|
||||
|
||||
@ -304,6 +304,9 @@ class EmbeddingMaintainer(threading.Thread):
|
||||
)
|
||||
return
|
||||
|
||||
if self.metrics:
|
||||
self.metrics.add_classification_model(model_name)
|
||||
|
||||
if model_config.state_config is not None:
|
||||
processor = CustomStateClassificationProcessor(
|
||||
self.config, model_config, self.requestor, self.metrics
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user