mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-09 04:35:25 +03:00
add enable_cpu_fallback flag with default false
This commit is contained in:
parent
85ccd1e8f1
commit
2062cde368
@ -1329,7 +1329,7 @@ class FrigateConfig(FrigateBaseModel):
|
|||||||
)
|
)
|
||||||
detector_config.model.compute_model_hash()
|
detector_config.model.compute_model_hash()
|
||||||
|
|
||||||
if detector_config.type != "cpu":
|
if detector_config.enable_cpu_fallback and detector_config.type != "cpu":
|
||||||
fallback_config = config.copy(deep=True)
|
fallback_config = config.copy(deep=True)
|
||||||
fallback_config.model = ModelConfig()
|
fallback_config.model = ModelConfig()
|
||||||
detector_config.fallback_config = self.generate_detector_config(
|
detector_config.fallback_config = self.generate_detector_config(
|
||||||
|
|||||||
@ -139,6 +139,9 @@ class ModelConfig(BaseModel):
|
|||||||
class BaseDetectorConfig(BaseModel):
|
class BaseDetectorConfig(BaseModel):
|
||||||
# the type field must be defined in all subclasses
|
# the type field must be defined in all subclasses
|
||||||
type: str = Field(default="cpu", title="Detector Type")
|
type: str = Field(default="cpu", title="Detector Type")
|
||||||
|
enable_cpu_fallback: bool = Field(
|
||||||
|
default=False, title="Fallback to CPU if startup fails"
|
||||||
|
)
|
||||||
model: ModelConfig = Field(
|
model: ModelConfig = Field(
|
||||||
default=None, title="Detector specific model configuration."
|
default=None, title="Detector specific model configuration."
|
||||||
)
|
)
|
||||||
|
|||||||
@ -103,11 +103,16 @@ def run_detector(
|
|||||||
try:
|
try:
|
||||||
object_detector = LocalObjectDetector(detector_config=detector_config)
|
object_detector = LocalObjectDetector(detector_config=detector_config)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
logger.error(f"Got exception when initializing detector: {ex}, falling back to CPU detector")
|
if detector_config.enable_cpu_fallback:
|
||||||
|
logger.error(
|
||||||
object_detector = LocalObjectDetector(detector_config=detector_config.fallback_config)
|
f"Got exception when initializing detector: {ex}, falling back to CPU detector"
|
||||||
using_fallback_detector.value = 1
|
)
|
||||||
|
object_detector = LocalObjectDetector(
|
||||||
|
detector_config=detector_config.fallback_config
|
||||||
|
)
|
||||||
|
using_fallback_detector.value = 1
|
||||||
|
else:
|
||||||
|
raise ex
|
||||||
|
|
||||||
outputs = {}
|
outputs = {}
|
||||||
for name in out_events.keys():
|
for name in out_events.keys():
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user