-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor processors and add LPR postprocessing (#16722)
* recordings data pub/sub * function to process recording stream frames * model runner * lpr model runner * refactor to mixin class and use model runner * separate out realtime and post processors * move model and mixin folders * basic postprocessor * clean up * docs * postprocessing logic * clean up * return none if recordings are disabled * run postprocessor handle_requests too * tweak expansion * add put endpoint * postprocessor tweaks with endpoint
- Loading branch information
1 parent
e773d63
commit 60b34bc
Showing
16 changed files
with
567 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
"""Facilitates communication between processes.""" | ||
|
||
import logging | ||
from enum import Enum | ||
|
||
from .zmq_proxy import Publisher, Subscriber | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class RecordingsDataTypeEnum(str, Enum): | ||
all = "" | ||
recordings_available_through = "recordings_available_through" | ||
|
||
|
||
class RecordingsDataPublisher(Publisher): | ||
"""Publishes latest recording data.""" | ||
|
||
topic_base = "recordings/" | ||
|
||
def __init__(self, topic: RecordingsDataTypeEnum) -> None: | ||
topic = topic.value | ||
super().__init__(topic) | ||
|
||
def publish(self, payload: tuple[str, float]) -> None: | ||
super().publish(payload) | ||
|
||
|
||
class RecordingsDataSubscriber(Subscriber): | ||
"""Receives latest recording data.""" | ||
|
||
topic_base = "recordings/" | ||
|
||
def __init__(self, topic: RecordingsDataTypeEnum) -> None: | ||
topic = topic.value | ||
super().__init__(topic) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from frigate.embeddings.onnx.lpr_embedding import ( | ||
LicensePlateDetector, | ||
PaddleOCRClassification, | ||
PaddleOCRDetection, | ||
PaddleOCRRecognition, | ||
) | ||
|
||
from ...types import DataProcessorModelRunner | ||
|
||
|
||
class LicensePlateModelRunner(DataProcessorModelRunner): | ||
def __init__(self, requestor, device: str = "CPU", model_size: str = "large"): | ||
super().__init__(requestor, device, model_size) | ||
self.detection_model = PaddleOCRDetection( | ||
model_size=model_size, requestor=requestor, device=device | ||
) | ||
self.classification_model = PaddleOCRClassification( | ||
model_size=model_size, requestor=requestor, device=device | ||
) | ||
self.recognition_model = PaddleOCRRecognition( | ||
model_size=model_size, requestor=requestor, device=device | ||
) | ||
self.yolov9_detection_model = LicensePlateDetector( | ||
model_size=model_size, requestor=requestor, device=device | ||
) | ||
|
||
# Load all models once | ||
self.detection_model._load_model_and_utils() | ||
self.classification_model._load_model_and_utils() | ||
self.recognition_model._load_model_and_utils() | ||
self.yolov9_detection_model._load_model_and_utils() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.