mirror of
				https://github.com/blakeblackshear/frigate.git
				synced 2025-10-27 10:52:11 +01:00 
			
		
		
		
	Reuse constants (#16874)
This commit is contained in:
		
							parent
							
								
									06d6e21de8
								
							
						
					
					
						commit
						458134de5d
					
				@ -31,6 +31,7 @@ from frigate.config import FrigateConfig
 | 
				
			|||||||
from frigate.const import (
 | 
					from frigate.const import (
 | 
				
			||||||
    CACHE_DIR,
 | 
					    CACHE_DIR,
 | 
				
			||||||
    CLIPS_DIR,
 | 
					    CLIPS_DIR,
 | 
				
			||||||
 | 
					    INSTALL_DIR,
 | 
				
			||||||
    MAX_SEGMENT_DURATION,
 | 
					    MAX_SEGMENT_DURATION,
 | 
				
			||||||
    PREVIEW_FRAME_TYPE,
 | 
					    PREVIEW_FRAME_TYPE,
 | 
				
			||||||
    RECORD_DIR,
 | 
					    RECORD_DIR,
 | 
				
			||||||
@ -155,7 +156,9 @@ def latest_frame(
 | 
				
			|||||||
            frame_processor.get_current_frame_time(camera_name) + retry_interval
 | 
					            frame_processor.get_current_frame_time(camera_name) + retry_interval
 | 
				
			||||||
        ):
 | 
					        ):
 | 
				
			||||||
            if request.app.camera_error_image is None:
 | 
					            if request.app.camera_error_image is None:
 | 
				
			||||||
                error_image = glob.glob("/opt/frigate/frigate/images/camera-error.jpg")
 | 
					                error_image = glob.glob(
 | 
				
			||||||
 | 
					                    os.path.join(INSTALL_DIR, "frigate/images/camera-error.jpg")
 | 
				
			||||||
 | 
					                )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if len(error_image) > 0:
 | 
					                if len(error_image) > 0:
 | 
				
			||||||
                    request.app.camera_error_image = cv2.imread(
 | 
					                    request.app.camera_error_image = cv2.imread(
 | 
				
			||||||
@ -550,7 +553,7 @@ def recording_clip(
 | 
				
			|||||||
    )
 | 
					    )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    file_name = sanitize_filename(f"playlist_{camera_name}_{start_ts}-{end_ts}.txt")
 | 
					    file_name = sanitize_filename(f"playlist_{camera_name}_{start_ts}-{end_ts}.txt")
 | 
				
			||||||
    file_path = f"/tmp/cache/{file_name}"
 | 
					    file_path = os.path.join(CACHE_DIR, file_name)
 | 
				
			||||||
    with open(file_path, "w") as file:
 | 
					    with open(file_path, "w") as file:
 | 
				
			||||||
        clip: Recordings
 | 
					        clip: Recordings
 | 
				
			||||||
        for clip in recordings:
 | 
					        for clip in recordings:
 | 
				
			||||||
 | 
				
			|||||||
@ -9,7 +9,7 @@ from fastapi import APIRouter
 | 
				
			|||||||
from fastapi.responses import JSONResponse
 | 
					from fastapi.responses import JSONResponse
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from frigate.api.defs.tags import Tags
 | 
					from frigate.api.defs.tags import Tags
 | 
				
			||||||
from frigate.const import CACHE_DIR, PREVIEW_FRAME_TYPE
 | 
					from frigate.const import BASE_DIR, CACHE_DIR, PREVIEW_FRAME_TYPE
 | 
				
			||||||
from frigate.models import Previews
 | 
					from frigate.models import Previews
 | 
				
			||||||
 | 
					
 | 
				
			||||||
logger = logging.getLogger(__name__)
 | 
					logger = logging.getLogger(__name__)
 | 
				
			||||||
@ -52,7 +52,7 @@ def preview_ts(camera_name: str, start_ts: float, end_ts: float):
 | 
				
			|||||||
        clips.append(
 | 
					        clips.append(
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                "camera": preview["camera"],
 | 
					                "camera": preview["camera"],
 | 
				
			||||||
                "src": preview["path"].replace("/media/frigate", ""),
 | 
					                "src": preview["path"].replace(BASE_DIR, ""),
 | 
				
			||||||
                "type": "video/mp4",
 | 
					                "type": "video/mp4",
 | 
				
			||||||
                "start": preview["start_time"],
 | 
					                "start": preview["start_time"],
 | 
				
			||||||
                "end": preview["end_time"],
 | 
					                "end": preview["end_time"],
 | 
				
			||||||
 | 
				
			|||||||
@ -1,6 +1,7 @@
 | 
				
			|||||||
import os
 | 
					import os
 | 
				
			||||||
import re
 | 
					import re
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					INSTALL_DIR = "/opt/frigate"
 | 
				
			||||||
CONFIG_DIR = "/config"
 | 
					CONFIG_DIR = "/config"
 | 
				
			||||||
DEFAULT_DB_PATH = f"{CONFIG_DIR}/frigate.db"
 | 
					DEFAULT_DB_PATH = f"{CONFIG_DIR}/frigate.db"
 | 
				
			||||||
MODEL_CACHE_DIR = f"{CONFIG_DIR}/model_cache"
 | 
					MODEL_CACHE_DIR = f"{CONFIG_DIR}/model_cache"
 | 
				
			||||||
 | 
				
			|||||||
@ -76,14 +76,16 @@ class FaceRealTimeProcessor(RealTimeProcessorApi):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    def __build_detector(self) -> None:
 | 
					    def __build_detector(self) -> None:
 | 
				
			||||||
        self.face_detector = cv2.FaceDetectorYN.create(
 | 
					        self.face_detector = cv2.FaceDetectorYN.create(
 | 
				
			||||||
            "/config/model_cache/facedet/facedet.onnx",
 | 
					            os.path.join(MODEL_CACHE_DIR, "facedet/facedet.onnx"),
 | 
				
			||||||
            config="",
 | 
					            config="",
 | 
				
			||||||
            input_size=(320, 320),
 | 
					            input_size=(320, 320),
 | 
				
			||||||
            score_threshold=0.8,
 | 
					            score_threshold=0.8,
 | 
				
			||||||
            nms_threshold=0.3,
 | 
					            nms_threshold=0.3,
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        self.landmark_detector = cv2.face.createFacemarkLBF()
 | 
					        self.landmark_detector = cv2.face.createFacemarkLBF()
 | 
				
			||||||
        self.landmark_detector.loadModel("/config/model_cache/facedet/landmarkdet.yaml")
 | 
					        self.landmark_detector.loadModel(
 | 
				
			||||||
 | 
					            os.path.join(MODEL_CACHE_DIR, "facedet/landmarkdet.yaml")
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __build_classifier(self) -> None:
 | 
					    def __build_classifier(self) -> None:
 | 
				
			||||||
        if not self.landmark_detector:
 | 
					        if not self.landmark_detector:
 | 
				
			||||||
 | 
				
			|||||||
@ -9,7 +9,7 @@ import requests
 | 
				
			|||||||
from pydantic import BaseModel, ConfigDict, Field
 | 
					from pydantic import BaseModel, ConfigDict, Field
 | 
				
			||||||
from pydantic.fields import PrivateAttr
 | 
					from pydantic.fields import PrivateAttr
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from frigate.const import DEFAULT_ATTRIBUTE_LABEL_MAP
 | 
					from frigate.const import DEFAULT_ATTRIBUTE_LABEL_MAP, MODEL_CACHE_DIR
 | 
				
			||||||
from frigate.plus import PlusApi
 | 
					from frigate.plus import PlusApi
 | 
				
			||||||
from frigate.util.builtin import generate_color_palette, load_labels
 | 
					from frigate.util.builtin import generate_color_palette, load_labels
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -123,7 +123,7 @@ class ModelConfig(BaseModel):
 | 
				
			|||||||
            return
 | 
					            return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        model_id = self.path[7:]
 | 
					        model_id = self.path[7:]
 | 
				
			||||||
        self.path = f"/config/model_cache/{model_id}"
 | 
					        self.path = os.path.join(MODEL_CACHE_DIR, model_id)
 | 
				
			||||||
        model_info_path = f"{self.path}.json"
 | 
					        model_info_path = f"{self.path}.json"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # download the model if it doesn't exist
 | 
					        # download the model if it doesn't exist
 | 
				
			||||||
 | 
				
			|||||||
@ -22,6 +22,7 @@ except ModuleNotFoundError:
 | 
				
			|||||||
from pydantic import BaseModel, Field
 | 
					from pydantic import BaseModel, Field
 | 
				
			||||||
from typing_extensions import Literal
 | 
					from typing_extensions import Literal
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from frigate.const import MODEL_CACHE_DIR
 | 
				
			||||||
from frigate.detectors.detection_api import DetectionApi
 | 
					from frigate.detectors.detection_api import DetectionApi
 | 
				
			||||||
from frigate.detectors.detector_config import BaseDetectorConfig
 | 
					from frigate.detectors.detector_config import BaseDetectorConfig
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -57,7 +58,7 @@ class HailoDetector(DetectionApi):
 | 
				
			|||||||
        self.h8l_tensor_format = detector_config.model.input_tensor
 | 
					        self.h8l_tensor_format = detector_config.model.input_tensor
 | 
				
			||||||
        self.h8l_pixel_format = detector_config.model.input_pixel_format
 | 
					        self.h8l_pixel_format = detector_config.model.input_pixel_format
 | 
				
			||||||
        self.model_url = "https://hailo-model-zoo.s3.eu-west-2.amazonaws.com/ModelZoo/Compiled/v2.11.0/hailo8l/ssd_mobilenet_v1.hef"
 | 
					        self.model_url = "https://hailo-model-zoo.s3.eu-west-2.amazonaws.com/ModelZoo/Compiled/v2.11.0/hailo8l/ssd_mobilenet_v1.hef"
 | 
				
			||||||
        self.cache_dir = "/config/model_cache/h8l_cache"
 | 
					        self.cache_dir = os.path.join(MODEL_CACHE_DIR, "h8l_cache")
 | 
				
			||||||
        self.expected_model_filename = "ssd_mobilenet_v1.hef"
 | 
					        self.expected_model_filename = "ssd_mobilenet_v1.hef"
 | 
				
			||||||
        output_type = "FLOAT32"
 | 
					        output_type = "FLOAT32"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -7,6 +7,7 @@ import openvino.properties as props
 | 
				
			|||||||
from pydantic import Field
 | 
					from pydantic import Field
 | 
				
			||||||
from typing_extensions import Literal
 | 
					from typing_extensions import Literal
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from frigate.const import MODEL_CACHE_DIR
 | 
				
			||||||
from frigate.detectors.detection_api import DetectionApi
 | 
					from frigate.detectors.detection_api import DetectionApi
 | 
				
			||||||
from frigate.detectors.detector_config import BaseDetectorConfig, ModelTypeEnum
 | 
					from frigate.detectors.detector_config import BaseDetectorConfig, ModelTypeEnum
 | 
				
			||||||
from frigate.util.model import post_process_yolov9
 | 
					from frigate.util.model import post_process_yolov9
 | 
				
			||||||
@ -41,8 +42,10 @@ class OvDetector(DetectionApi):
 | 
				
			|||||||
            logger.error(f"OpenVino model file {detector_config.model.path} not found.")
 | 
					            logger.error(f"OpenVino model file {detector_config.model.path} not found.")
 | 
				
			||||||
            raise FileNotFoundError
 | 
					            raise FileNotFoundError
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        os.makedirs("/config/model_cache/openvino", exist_ok=True)
 | 
					        os.makedirs(os.path.join(MODEL_CACHE_DIR, "openvino"), exist_ok=True)
 | 
				
			||||||
        self.ov_core.set_property({props.cache_dir: "/config/model_cache/openvino"})
 | 
					        self.ov_core.set_property(
 | 
				
			||||||
 | 
					            {props.cache_dir: os.path.join(MODEL_CACHE_DIR, "openvino")}
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
        self.interpreter = self.ov_core.compile_model(
 | 
					        self.interpreter = self.ov_core.compile_model(
 | 
				
			||||||
            model=detector_config.model.path, device_name=detector_config.device
 | 
					            model=detector_config.model.path, device_name=detector_config.device
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
 | 
				
			|||||||
@ -6,6 +6,7 @@ from typing import Literal
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
from pydantic import Field
 | 
					from pydantic import Field
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from frigate.const import MODEL_CACHE_DIR
 | 
				
			||||||
from frigate.detectors.detection_api import DetectionApi
 | 
					from frigate.detectors.detection_api import DetectionApi
 | 
				
			||||||
from frigate.detectors.detector_config import BaseDetectorConfig, ModelTypeEnum
 | 
					from frigate.detectors.detector_config import BaseDetectorConfig, ModelTypeEnum
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -17,7 +18,7 @@ supported_socs = ["rk3562", "rk3566", "rk3568", "rk3576", "rk3588"]
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
supported_models = {ModelTypeEnum.yolonas: "^deci-fp16-yolonas_[sml]$"}
 | 
					supported_models = {ModelTypeEnum.yolonas: "^deci-fp16-yolonas_[sml]$"}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
model_cache_dir = "/config/model_cache/rknn_cache/"
 | 
					model_cache_dir = os.path.join(MODEL_CACHE_DIR, "rknn_cache/")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class RknnDetectorConfig(BaseDetectorConfig):
 | 
					class RknnDetectorConfig(BaseDetectorConfig):
 | 
				
			||||||
 | 
				
			|||||||
@ -9,6 +9,7 @@ import numpy as np
 | 
				
			|||||||
from pydantic import Field
 | 
					from pydantic import Field
 | 
				
			||||||
from typing_extensions import Literal
 | 
					from typing_extensions import Literal
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from frigate.const import MODEL_CACHE_DIR
 | 
				
			||||||
from frigate.detectors.detection_api import DetectionApi
 | 
					from frigate.detectors.detection_api import DetectionApi
 | 
				
			||||||
from frigate.detectors.detector_config import (
 | 
					from frigate.detectors.detector_config import (
 | 
				
			||||||
    BaseDetectorConfig,
 | 
					    BaseDetectorConfig,
 | 
				
			||||||
@ -116,7 +117,7 @@ class ROCmDetector(DetectionApi):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            logger.info(f"AMD/ROCm: saving parsed model into {mxr_path}")
 | 
					            logger.info(f"AMD/ROCm: saving parsed model into {mxr_path}")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            os.makedirs("/config/model_cache/rocm", exist_ok=True)
 | 
					            os.makedirs(os.path.join(MODEL_CACHE_DIR, "rocm"), exist_ok=True)
 | 
				
			||||||
            migraphx.save(self.model, mxr_path)
 | 
					            migraphx.save(self.model, mxr_path)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        logger.info("AMD/ROCm: model loaded")
 | 
					        logger.info("AMD/ROCm: model loaded")
 | 
				
			||||||
 | 
				
			|||||||
@ -1,10 +1,12 @@
 | 
				
			|||||||
"""Convenience runner for onnx models."""
 | 
					"""Convenience runner for onnx models."""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import logging
 | 
					import logging
 | 
				
			||||||
 | 
					import os.path
 | 
				
			||||||
from typing import Any
 | 
					from typing import Any
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import onnxruntime as ort
 | 
					import onnxruntime as ort
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from frigate.const import MODEL_CACHE_DIR
 | 
				
			||||||
from frigate.util.model import get_ort_providers
 | 
					from frigate.util.model import get_ort_providers
 | 
				
			||||||
 | 
					
 | 
				
			||||||
try:
 | 
					try:
 | 
				
			||||||
@ -32,7 +34,7 @@ class ONNXModelRunner:
 | 
				
			|||||||
                self.type = "ov"
 | 
					                self.type = "ov"
 | 
				
			||||||
                self.ov = ov.Core()
 | 
					                self.ov = ov.Core()
 | 
				
			||||||
                self.ov.set_property(
 | 
					                self.ov.set_property(
 | 
				
			||||||
                    {ov.properties.cache_dir: "/config/model_cache/openvino"}
 | 
					                    {ov.properties.cache_dir: os.path.join(MODEL_CACHE_DIR, "openvino")}
 | 
				
			||||||
                )
 | 
					                )
 | 
				
			||||||
                self.interpreter = self.ov.compile_model(
 | 
					                self.interpreter = self.ov.compile_model(
 | 
				
			||||||
                    model=model_path, device_name=device
 | 
					                    model=model_path, device_name=device
 | 
				
			||||||
 | 
				
			|||||||
@ -16,7 +16,7 @@ import numpy as np
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
from frigate.comms.config_updater import ConfigSubscriber
 | 
					from frigate.comms.config_updater import ConfigSubscriber
 | 
				
			||||||
from frigate.config import BirdseyeModeEnum, FfmpegConfig, FrigateConfig
 | 
					from frigate.config import BirdseyeModeEnum, FfmpegConfig, FrigateConfig
 | 
				
			||||||
from frigate.const import BASE_DIR, BIRDSEYE_PIPE
 | 
					from frigate.const import BASE_DIR, BIRDSEYE_PIPE, INSTALL_DIR
 | 
				
			||||||
from frigate.util.image import (
 | 
					from frigate.util.image import (
 | 
				
			||||||
    SharedMemoryFrameManager,
 | 
					    SharedMemoryFrameManager,
 | 
				
			||||||
    copy_yuv_to_position,
 | 
					    copy_yuv_to_position,
 | 
				
			||||||
@ -297,7 +297,9 @@ class BirdsEyeFrameManager:
 | 
				
			|||||||
            birdseye_logo = cv2.imread(custom_logo_files[0], cv2.IMREAD_UNCHANGED)
 | 
					            birdseye_logo = cv2.imread(custom_logo_files[0], cv2.IMREAD_UNCHANGED)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if birdseye_logo is None:
 | 
					        if birdseye_logo is None:
 | 
				
			||||||
            logo_files = glob.glob("/opt/frigate/frigate/images/birdseye.png")
 | 
					            logo_files = glob.glob(
 | 
				
			||||||
 | 
					                os.path.join(INSTALL_DIR, "frigate/images/birdseye.png")
 | 
				
			||||||
 | 
					            )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if len(logo_files) > 0:
 | 
					            if len(logo_files) > 0:
 | 
				
			||||||
                birdseye_logo = cv2.imread(logo_files[0], cv2.IMREAD_UNCHANGED)
 | 
					                birdseye_logo = cv2.imread(logo_files[0], cv2.IMREAD_UNCHANGED)
 | 
				
			||||||
 | 
				
			|||||||
@ -10,6 +10,7 @@ from pydantic import Json
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
from frigate.api.fastapi_app import create_fastapi_app
 | 
					from frigate.api.fastapi_app import create_fastapi_app
 | 
				
			||||||
from frigate.config import FrigateConfig
 | 
					from frigate.config import FrigateConfig
 | 
				
			||||||
 | 
					from frigate.const import BASE_DIR, CACHE_DIR
 | 
				
			||||||
from frigate.models import Event, Recordings, ReviewSegment
 | 
					from frigate.models import Event, Recordings, ReviewSegment
 | 
				
			||||||
from frigate.review.types import SeverityEnum
 | 
					from frigate.review.types import SeverityEnum
 | 
				
			||||||
from frigate.test.const import TEST_DB, TEST_DB_CLEANUPS
 | 
					from frigate.test.const import TEST_DB, TEST_DB_CLEANUPS
 | 
				
			||||||
@ -73,19 +74,19 @@ class BaseTestHttp(unittest.TestCase):
 | 
				
			|||||||
                        "total": 67.1,
 | 
					                        "total": 67.1,
 | 
				
			||||||
                        "used": 16.6,
 | 
					                        "used": 16.6,
 | 
				
			||||||
                    },
 | 
					                    },
 | 
				
			||||||
                    "/media/frigate/clips": {
 | 
					                    os.path.join(BASE_DIR, "clips"): {
 | 
				
			||||||
                        "free": 42429.9,
 | 
					                        "free": 42429.9,
 | 
				
			||||||
                        "mount_type": "ext4",
 | 
					                        "mount_type": "ext4",
 | 
				
			||||||
                        "total": 244529.7,
 | 
					                        "total": 244529.7,
 | 
				
			||||||
                        "used": 189607.0,
 | 
					                        "used": 189607.0,
 | 
				
			||||||
                    },
 | 
					                    },
 | 
				
			||||||
                    "/media/frigate/recordings": {
 | 
					                    os.path.join(BASE_DIR, "recordings"): {
 | 
				
			||||||
                        "free": 0.2,
 | 
					                        "free": 0.2,
 | 
				
			||||||
                        "mount_type": "ext4",
 | 
					                        "mount_type": "ext4",
 | 
				
			||||||
                        "total": 8.0,
 | 
					                        "total": 8.0,
 | 
				
			||||||
                        "used": 7.8,
 | 
					                        "used": 7.8,
 | 
				
			||||||
                    },
 | 
					                    },
 | 
				
			||||||
                    "/tmp/cache": {
 | 
					                    CACHE_DIR: {
 | 
				
			||||||
                        "free": 976.8,
 | 
					                        "free": 976.8,
 | 
				
			||||||
                        "mount_type": "tmpfs",
 | 
					                        "mount_type": "tmpfs",
 | 
				
			||||||
                        "total": 1000.0,
 | 
					                        "total": 1000.0,
 | 
				
			||||||
 | 
				
			|||||||
@ -854,9 +854,9 @@ class TestConfig(unittest.TestCase):
 | 
				
			|||||||
        assert frigate_config.model.merged_labelmap[0] == "person"
 | 
					        assert frigate_config.model.merged_labelmap[0] == "person"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_plus_labelmap(self):
 | 
					    def test_plus_labelmap(self):
 | 
				
			||||||
        with open("/config/model_cache/test", "w") as f:
 | 
					        with open(os.path.join(MODEL_CACHE_DIR, "test"), "w") as f:
 | 
				
			||||||
            json.dump(self.plus_model_info, f)
 | 
					            json.dump(self.plus_model_info, f)
 | 
				
			||||||
        with open("/config/model_cache/test.json", "w") as f:
 | 
					        with open(os.path.join(MODEL_CACHE_DIR, "test.json"), "w") as f:
 | 
				
			||||||
            json.dump(self.plus_model_info, f)
 | 
					            json.dump(self.plus_model_info, f)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        config = {
 | 
					        config = {
 | 
				
			||||||
 | 
				
			|||||||
@ -11,6 +11,7 @@ from playhouse.sqliteq import SqliteQueueDatabase
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
from frigate.api.fastapi_app import create_fastapi_app
 | 
					from frigate.api.fastapi_app import create_fastapi_app
 | 
				
			||||||
from frigate.config import FrigateConfig
 | 
					from frigate.config import FrigateConfig
 | 
				
			||||||
 | 
					from frigate.const import BASE_DIR, CACHE_DIR
 | 
				
			||||||
from frigate.models import Event, Recordings, Timeline
 | 
					from frigate.models import Event, Recordings, Timeline
 | 
				
			||||||
from frigate.test.const import TEST_DB, TEST_DB_CLEANUPS
 | 
					from frigate.test.const import TEST_DB, TEST_DB_CLEANUPS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -74,19 +75,19 @@ class TestHttp(unittest.TestCase):
 | 
				
			|||||||
                        "total": 67.1,
 | 
					                        "total": 67.1,
 | 
				
			||||||
                        "used": 16.6,
 | 
					                        "used": 16.6,
 | 
				
			||||||
                    },
 | 
					                    },
 | 
				
			||||||
                    "/media/frigate/clips": {
 | 
					                    os.path.join(BASE_DIR, "clips"): {
 | 
				
			||||||
                        "free": 42429.9,
 | 
					                        "free": 42429.9,
 | 
				
			||||||
                        "mount_type": "ext4",
 | 
					                        "mount_type": "ext4",
 | 
				
			||||||
                        "total": 244529.7,
 | 
					                        "total": 244529.7,
 | 
				
			||||||
                        "used": 189607.0,
 | 
					                        "used": 189607.0,
 | 
				
			||||||
                    },
 | 
					                    },
 | 
				
			||||||
                    "/media/frigate/recordings": {
 | 
					                    os.path.join(BASE_DIR, "recordings"): {
 | 
				
			||||||
                        "free": 0.2,
 | 
					                        "free": 0.2,
 | 
				
			||||||
                        "mount_type": "ext4",
 | 
					                        "mount_type": "ext4",
 | 
				
			||||||
                        "total": 8.0,
 | 
					                        "total": 8.0,
 | 
				
			||||||
                        "used": 7.8,
 | 
					                        "used": 7.8,
 | 
				
			||||||
                    },
 | 
					                    },
 | 
				
			||||||
                    "/tmp/cache": {
 | 
					                    CACHE_DIR: {
 | 
				
			||||||
                        "free": 976.8,
 | 
					                        "free": 976.8,
 | 
				
			||||||
                        "mount_type": "tmpfs",
 | 
					                        "mount_type": "tmpfs",
 | 
				
			||||||
                        "total": 1000.0,
 | 
					                        "total": 1000.0,
 | 
				
			||||||
 | 
				
			|||||||
@ -14,7 +14,7 @@ from frigate.util.services import get_video_properties
 | 
				
			|||||||
logger = logging.getLogger(__name__)
 | 
					logger = logging.getLogger(__name__)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
CURRENT_CONFIG_VERSION = "0.16-0"
 | 
					CURRENT_CONFIG_VERSION = "0.16-0"
 | 
				
			||||||
DEFAULT_CONFIG_FILE = "/config/config.yml"
 | 
					DEFAULT_CONFIG_FILE = os.path.join(CONFIG_DIR, "config.yml")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def find_config_file() -> str:
 | 
					def find_config_file() -> str:
 | 
				
			||||||
 | 
				
			|||||||
@ -7,6 +7,8 @@ import cv2
 | 
				
			|||||||
import numpy as np
 | 
					import numpy as np
 | 
				
			||||||
import onnxruntime as ort
 | 
					import onnxruntime as ort
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from frigate.const import MODEL_CACHE_DIR
 | 
				
			||||||
 | 
					
 | 
				
			||||||
logger = logging.getLogger(__name__)
 | 
					logger = logging.getLogger(__name__)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -105,7 +107,8 @@ def get_ort_providers(
 | 
				
			|||||||
            # so it is not enabled by default
 | 
					            # so it is not enabled by default
 | 
				
			||||||
            if device == "Tensorrt":
 | 
					            if device == "Tensorrt":
 | 
				
			||||||
                os.makedirs(
 | 
					                os.makedirs(
 | 
				
			||||||
                    "/config/model_cache/tensorrt/ort/trt-engines", exist_ok=True
 | 
					                    os.path.join(MODEL_CACHE_DIR, "tensorrt/ort/trt-engines"),
 | 
				
			||||||
 | 
					                    exist_ok=True,
 | 
				
			||||||
                )
 | 
					                )
 | 
				
			||||||
                device_id = 0 if not device.isdigit() else int(device)
 | 
					                device_id = 0 if not device.isdigit() else int(device)
 | 
				
			||||||
                providers.append(provider)
 | 
					                providers.append(provider)
 | 
				
			||||||
@ -116,19 +119,23 @@ def get_ort_providers(
 | 
				
			|||||||
                        and os.environ.get("USE_FP_16", "True") != "False",
 | 
					                        and os.environ.get("USE_FP_16", "True") != "False",
 | 
				
			||||||
                        "trt_timing_cache_enable": True,
 | 
					                        "trt_timing_cache_enable": True,
 | 
				
			||||||
                        "trt_engine_cache_enable": True,
 | 
					                        "trt_engine_cache_enable": True,
 | 
				
			||||||
                        "trt_timing_cache_path": "/config/model_cache/tensorrt/ort",
 | 
					                        "trt_timing_cache_path": os.path.join(
 | 
				
			||||||
                        "trt_engine_cache_path": "/config/model_cache/tensorrt/ort/trt-engines",
 | 
					                            MODEL_CACHE_DIR, "tensorrt/ort"
 | 
				
			||||||
 | 
					                        ),
 | 
				
			||||||
 | 
					                        "trt_engine_cache_path": os.path.join(
 | 
				
			||||||
 | 
					                            MODEL_CACHE_DIR, "tensorrt/ort/trt-engines"
 | 
				
			||||||
 | 
					                        ),
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                )
 | 
					                )
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
                continue
 | 
					                continue
 | 
				
			||||||
        elif provider == "OpenVINOExecutionProvider":
 | 
					        elif provider == "OpenVINOExecutionProvider":
 | 
				
			||||||
            os.makedirs("/config/model_cache/openvino/ort", exist_ok=True)
 | 
					            os.makedirs(os.path.join(MODEL_CACHE_DIR, "openvino/ort"), exist_ok=True)
 | 
				
			||||||
            providers.append(provider)
 | 
					            providers.append(provider)
 | 
				
			||||||
            options.append(
 | 
					            options.append(
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    "arena_extend_strategy": "kSameAsRequested",
 | 
					                    "arena_extend_strategy": "kSameAsRequested",
 | 
				
			||||||
                    "cache_dir": "/config/model_cache/openvino/ort",
 | 
					                    "cache_dir": os.path.join(MODEL_CACHE_DIR, "openvino/ort"),
 | 
				
			||||||
                    "device_type": device,
 | 
					                    "device_type": device,
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            )
 | 
					            )
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user