Skip to content

Commit

Permalink
initial conversion to pydantic
Browse files Browse the repository at this point in the history
  • Loading branch information
hunterjm authored and blakeblackshear committed Jun 24, 2021
1 parent dada764 commit c664bd6
Show file tree
Hide file tree
Showing 9 changed files with 710 additions and 1,050 deletions.
2 changes: 1 addition & 1 deletion docker/Dockerfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ RUN apt-get -qq update \

RUN pip3 install \
peewee_migrate \
pydantic \
zeroconf \
voluptuous\
ws4py

COPY --from=nginx /usr/local/nginx/ /usr/local/nginx/
Expand Down
20 changes: 11 additions & 9 deletions frigate/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from playhouse.sqlite_ext import SqliteExtDatabase
from playhouse.sqliteq import SqliteQueueDatabase

from frigate.config import FrigateConfig
from frigate.config import DetectorTypeEnum, FrigateConfig
from frigate.const import CACHE_DIR, CLIPS_DIR, RECORD_DIR
from frigate.edgetpu import EdgeTPUProcess
from frigate.events import EventCleanup, EventProcessor
Expand All @@ -35,6 +35,7 @@
class FrigateApp:
def __init__(self):
self.stop_event = mp.Event()
self.base_config: FrigateConfig = None
self.config: FrigateConfig = None
self.detection_queue = mp.Queue()
self.detectors: Dict[str, EdgeTPUProcess] = {}
Expand Down Expand Up @@ -65,7 +66,8 @@ def init_logger(self):

def init_config(self):
config_file = os.environ.get("CONFIG_FILE", "/config/config.yml")
self.config = FrigateConfig(config_file=config_file)
user_config = FrigateConfig.parse_file(config_file)
self.config = user_config.runtime_config

for camera_name in self.config.cameras.keys():
# create camera_metrics
Expand Down Expand Up @@ -116,9 +118,9 @@ def check_config(self):
)

def set_log_levels(self):
logging.getLogger().setLevel(self.config.logger.default)
logging.getLogger().setLevel(self.config.logger.default.value.upper())
for log, level in self.config.logger.logs.items():
logging.getLogger(log).setLevel(level)
logging.getLogger(log).setLevel(level.value.upper())

if not "werkzeug" in self.config.logger.logs:
logging.getLogger("werkzeug").setLevel("ERROR")
Expand Down Expand Up @@ -183,9 +185,9 @@ def start_detectors(self):

try:
shm_in = mp.shared_memory.SharedMemory(
name=name,
create=True,
size=self.config.model.height*self.config.model.width * 3,
name=name,
create=True,
size=self.config.model.height * self.config.model.width * 3,
)
except FileExistsError:
shm_in = mp.shared_memory.SharedMemory(name=name)
Expand All @@ -201,7 +203,7 @@ def start_detectors(self):
self.detection_shms.append(shm_out)

for name, detector in self.config.detectors.items():
if detector.type == "cpu":
if detector.type == DetectorTypeEnum.cpu:
self.detectors[name] = EdgeTPUProcess(
name,
self.detection_queue,
Expand All @@ -210,7 +212,7 @@ def start_detectors(self):
"cpu",
detector.num_threads,
)
if detector.type == "edgetpu":
if detector.type == DetectorTypeEnum.edgetpu:
self.detectors[name] = EdgeTPUProcess(
name,
self.detection_queue,
Expand Down
Loading

0 comments on commit c664bd6

Please sign in to comment.