mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-05 02:35:22 +03:00
reformatted frigate/detectors/plugins/meta.py
This commit is contained in:
parent
3d9b1996f9
commit
5546c085fb
@ -21,6 +21,7 @@ DetectorConfig = Annotated[
|
|||||||
Field(discriminator="type"),
|
Field(discriminator="type"),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class MetaDetectorConfig(BaseDetectorConfig):
|
class MetaDetectorConfig(BaseDetectorConfig):
|
||||||
type: Literal[DETECTOR_KEY]
|
type: Literal[DETECTOR_KEY]
|
||||||
detectors: Dict[str, DetectorConfig] = Field(
|
detectors: Dict[str, DetectorConfig] = Field(
|
||||||
@ -68,8 +69,6 @@ class MetaDetector(DetectionApi):
|
|||||||
meta_detector_config.detectors[key] = detector_config
|
meta_detector_config.detectors[key] = detector_config
|
||||||
self.detectors.append(self.create_detector(detector_config))
|
self.detectors.append(self.create_detector(detector_config))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def merge_detections(self, detections_list: List[np.ndarray]) -> np.ndarray:
|
def merge_detections(self, detections_list: List[np.ndarray]) -> np.ndarray:
|
||||||
all_detections = np.vstack(detections_list)
|
all_detections = np.vstack(detections_list)
|
||||||
sorted_indices = np.argsort(-all_detections[:, 1])
|
sorted_indices = np.argsort(-all_detections[:, 1])
|
||||||
@ -82,12 +81,15 @@ class MetaDetector(DetectionApi):
|
|||||||
return self.merge_detections(detections_list)
|
return self.merge_detections(detections_list)
|
||||||
|
|
||||||
def create_detector(self, detector_config):
|
def create_detector(self, detector_config):
|
||||||
|
|
||||||
current_module_name = os.path.splitext(os.path.basename(__file__))[0]
|
current_module_name = os.path.splitext(os.path.basename(__file__))[0]
|
||||||
modules_folder = os.path.dirname(os.path.abspath(__file__))
|
modules_folder = os.path.dirname(os.path.abspath(__file__))
|
||||||
module_prefix = __package__ + "."
|
module_prefix = __package__ + "."
|
||||||
|
|
||||||
_included_modules = [module for module in pkgutil.iter_modules([modules_folder], module_prefix) if module.name != current_module_name]
|
_included_modules = [
|
||||||
|
module
|
||||||
|
for module in pkgutil.iter_modules([modules_folder], module_prefix)
|
||||||
|
if module.name != current_module_name
|
||||||
|
]
|
||||||
|
|
||||||
plugin_modules = []
|
plugin_modules = []
|
||||||
|
|
||||||
@ -99,8 +101,6 @@ class MetaDetector(DetectionApi):
|
|||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
logger.error(f"Error importing detector runtime: {e}")
|
logger.error(f"Error importing detector runtime: {e}")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
api_types = {det.type_key: det for det in DetectionApi.__subclasses__()}
|
api_types = {det.type_key: det for det in DetectionApi.__subclasses__()}
|
||||||
api = api_types.get(detector_config.type)
|
api = api_types.get(detector_config.type)
|
||||||
if not api:
|
if not api:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user