NVR with realtime local object detection for IP cameras
TypeScript aicameragoogle-coralhome-assistanthome-automationhomeautomationmqttnvrobject-detectionrealtimertsptensorflow
Merge remote-tracking branch 'origin/master' into dev
Blake Blackshear652fdc6a389f
diff --cc docs/docs/configuration/camera_specific.mdindex 1face3883a,3a3809605e..64285d99ad--- a/docs/docs/configuration/camera_specific.md+++ b/docs/docs/configuration/camera_specific.md@@@ -147,7 -147,7 +147,7 @@@ WEB Digest Algorithm - MDReolink has many different camera models with inconsistently supported features and behavior. The below table shows a summary of various features and recommendations.| Camera Resolution | Camera Generation | Recommended Stream Type | Additional Notes |- |-------------------|---------------------------|-----------------------------------|-------------------------------------------------------------------------|-| ---------------- | ------------------------- | -------------------------------- | ----------------------------------------------------------------------- |++| ----------------- | ------------------------- | --------------------------------- | ----------------------------------------------------------------------- || 5MP or lower | All | http-flv | Stream is h264 || 6MP or higher | Latest (ex: Duo3, CX-8##) | http-flv with ffmpeg 8.0, or rtsp | This uses the new http-flv-enhanced over H265 which requires ffmpeg 8.0 || 6MP or higher | Older (ex: RLC-8##) | rtsp | |@@@ -250,6 -250,6 +250,7 @@@ TP-Link VIGI cameras need some adjustmeTo use a USB camera (webcam) with Frigate, the recommendation is to use go2rtc's [FFmpeg Device](https://github.com/AlexxIT/go2rtc?tab=readme-ov-file#source-ffmpeg-device) support:- Preparation outside of Frigate:++- Get USB camera path. Run `v4l2-ctl --list-devices` to get a listing of locally-connected cameras available. (You may need to install `v4l-utils` in a way appropriate for your Linux distribution). In the sample configuration below, we use `video=0` to correlate with a detected device path of `/dev/video0`- Get USB camera formats & resolutions. Run `ffmpeg -f v4l2 -list_formats all -i /dev/video0` to get an idea of what formats and resolutions the USB Camera supports. In the sample configuration below, we use a width of 1024 and height of 576 in the stream and detection settings based on what was reported back.- If using Frigate in a container (e.g. Docker on TrueNAS), ensure you have USB Passthrough support enabled, along with a specific Host Device (`/dev/video0`) + Container Device (`/dev/video0`) listed.@@@ -277,5 -277,5 +278,3 @@@ cameraswidth: 1024height: 576```----diff --cc docs/docs/frigate/hardware.mdindex aa3e4044e2,fcb98573f8..9dac865275--- a/docs/docs/frigate/hardware.md+++ b/docs/docs/frigate/hardware.md@@@ -56,12 -56,8 +56,13 @@@ Frigate supports multiple different det- Runs best with tiny or small size models- [Google Coral EdgeTPU](#google-coral-tpu): The Google Coral EdgeTPU is available in USB and m.2 format allowing for a wide range of compatibility with devices.++- [Supports primarily ssdlite and mobilenet model architectures](../../configuration/object_detectors#edge-tpu-detector)+- [MemryX](#memryx-mx3): The MX3 M.2 accelerator module is available in m.2 format allowing for a wide range of compatibility with devices.+ - [Supports many model architectures](../../configuration/object_detectors#memryx-mx3)+ - Runs best with tiny, small, or medium-size models+**AMD**- [ROCm](#rocm---amd-gpu): ROCm can run on AMD Discrete GPUs to provide efficient object detection@@@ -142,17 -132,19 +144,19 @@@ More information is available [in the dInference speeds vary greatly depending on the CPU or GPU used, some known examples of GPU inference times are below:- | Name | MobileNetV2 Inference Time | YOLO-NAS Inference Time | RF-DETR Inference Time | Notes |- | -------------- | -------------------------- | ------------------------- | ---------------------- | ---------------------------------- |- | Intel HD 530 | 15 - 35 ms | | | Can only run one detector instance |- | Intel HD 620 | 15 - 25 ms | 320: ~ 35 ms | | |- | Intel HD 630 | ~ 15 ms | 320: ~ 30 ms | | |- | Intel UHD 730 | ~ 10 ms | 320: ~ 19 ms 640: ~ 54 ms | | |- | Intel UHD 770 | ~ 15 ms | 320: ~ 20 ms 640: ~ 46 ms | | |- | Intel N100 | ~ 15 ms | 320: ~ 25 ms | | Can only run one detector instance |- | Intel Iris XE | ~ 10 ms | 320: ~ 18 ms 640: ~ 50 ms | | |- | Intel Arc A380 | ~ 6 ms | 320: ~ 10 ms 640: ~ 22 ms | 336: 20 ms 448: 27 ms | |- | Intel Arc A750 | ~ 4 ms | 320: ~ 8 ms | | |+ | Name | MobileNetV2 Inference Time | YOLOv9 | YOLO-NAS Inference Time | RF-DETR Inference Time | Notes |+ | -------------- | -------------------------- | ------------------------------------------------- | ------------------------- | ---------------------- | ---------------------------------- |+ | Intel HD 530 | 15 - 35 ms | | | | Can only run one detector instance |+ | Intel HD 620 | 15 - 25 ms | | 320: ~ 35 ms | | |+ | Intel HD 630 | ~ 15 ms | | 320: ~ 30 ms | | |+ | Intel UHD 730 | ~ 10 ms | | 320: ~ 19 ms 640: ~ 54 ms | | |+ | Intel UHD 770 | ~ 15 ms | t-320: ~ 16 ms s-320: ~ 20 ms s-640: ~ 40 ms | 320: ~ 20 ms 640: ~ 46 ms | | |+ | Intel N100 | ~ 15 ms | s-320: 30 ms | 320: ~ 25 ms | | Can only run one detector instance |+ | Intel N150 | ~ 15 ms | t-320: 16 ms s-320: 24 ms | | | |+ | Intel Iris XE | ~ 10 ms | s-320: 12 ms s-640: 30 ms | 320: ~ 18 ms 640: ~ 50 ms | | |-| Intel Arc A310 | ~ 5 ms | t-320: 7 ms t-640: 11 ms s-320: 8 ms s-640: 15 ms | 320: ~ 8 ms 640: ~ 14 ms | | |++| Intel Arc A310 | ~ 5 ms | t-320: 7 ms t-640: 11 ms s-320: 8 ms s-640: 15 ms | 320: ~ 8 ms 640: ~ 14 ms | | |+ | Intel Arc A380 | ~ 6 ms | | 320: ~ 10 ms 640: ~ 22 ms | 336: 20 ms 448: 27 ms | |+ | Intel Arc A750 | ~ 4 ms | | 320: ~ 8 ms | | |### TensorRT - Nvidia GPU@@@ -160,7 -152,7 +164,7 @@@ Frigate is able to utilize an Nvidia GP#### Minimum Hardware Support-- 12.x series of CUDA libraries are used which have minor version compatibility. The minimum driver version on the host system must be `>=545`. Also the GPU must support a Compute Capability of `5.0` or greater. This generally correlates to a Maxwell-era GPU or newer, check the NVIDIA GPU Compute Capability table linked below.++12.x series of CUDA libraries are used which have minor version compatibility. The minimum driver version on the host system must be `>=545`. Also the GPU must support a Compute Capability of `5.0` or greater. This generally correlates to a Maxwell-era GPU or newer, check the NVIDIA GPU Compute Capability table linked below.Make sure your host system has the [nvidia-container-runtime](https://docs.docker.com/config/containers/resource_constraints/#access-an-nvidia-gpu) installed to pass through the GPU to the container and the host system has a compatible driver installed for your GPU.@@@ -175,69 -167,27 +179,71 @@@ There are improved capabilities in newe[NVIDIA GPU Compute Capability](https://developer.nvidia.com/cuda-gpus)Inference speeds will vary greatly depending on the GPU and the model used.-`tiny` variants are faster than the equivalent non-tiny model, some known examples are below:+`tiny (t)` variants are faster than the equivalent non-tiny model, some known examples are below:++✅ - Accelerated with CUDA Graphs+❌ - Not accelerated with CUDA Graphs+- | Name | ✅ YOLOv9 Inference Time | ✅ RF-DETR Inference Time | ❌ YOLO-NAS Inference Time |- | --------------- | ------------------------------------- | ------------------------- | --------------------------- |- | RTX 3050 | t-320: 8 ms s-320: 10 ms s-640: 28 ms | Nano-320: ~ 12 ms | 320: ~ 10 ms 640: ~ 16 ms |- | RTX 3070 | t-320: 6 ms s-320: 8 ms s-640: 25 ms | Nano-320: ~ 9 ms | 320: ~ 8 ms 640: ~ 14 ms |- | RTX A4000 | | | 320: ~ 15 ms |- | Tesla P40 | | | 320: ~ 105 ms |++| Name | ✅ YOLOv9 Inference Time | ✅ RF-DETR Inference Time | ❌ YOLO-NAS Inference Time |++| --------- | ------------------------------------- | ------------------------- | -------------------------- |++| GTX 1070 | s-320: 16 ms | | 320: 14 ms |++| RTX 3050 | t-320: 8 ms s-320: 10 ms s-640: 28 ms | Nano-320: ~ 12 ms | 320: ~ 10 ms 640: ~ 16 ms |++| RTX 3070 | t-320: 6 ms s-320: 8 ms s-640: 25 ms | Nano-320: ~ 9 ms | 320: ~ 8 ms 640: ~ 14 ms |++| RTX A4000 | | | 320: ~ 15 ms |++| Tesla P40 | | | 320: ~ 105 ms |++### Apple Silicon++With the [Apple Silicon](../configuration/object_detectors.md#apple-silicon-detector) detector Frigate can take advantage of the NPU in M1 and newer Apple Silicon.++:::warning++Apple Silicon can not run within a container, so a ZMQ proxy is utilized to communicate with [the Apple Silicon Frigate detector](https://github.com/frigate-nvr/apple-silicon-detector) which runs on the host. This should add minimal latency when run on the same device.-| Name | YOLOv9 Inference Time | YOLO-NAS Inference Time | RF-DETR Inference Time |-| --------------- | ------------------------- | ------------------------- | ---------------------- |-| GTX 1070 | s-320: 16 ms | 320: 14 ms | |-| RTX 3050 | t-320: 15 ms s-320: 17 ms | 320: ~ 10 ms 640: ~ 16 ms | Nano-320: ~ 12 ms |-| RTX 3070 | t-320: 11 ms s-320: 13 ms | 320: ~ 8 ms 640: ~ 14 ms | Nano-320: ~ 9 ms |-| RTX A4000 | | 320: ~ 15 ms | |-| Tesla P40 | | 320: ~ 105 ms | |+:::+- | Name | YOLOv9 Inference Time |- | --------- | ------------------------------------ |- | M4 | s-20: 10 ms |- | M3 Pro | t-320: 6 ms s-320: 8 ms s-640: 20 ms |- | M1 | s-320: 9ms |++| Name | YOLOv9 Inference Time |++| ------ | ------------------------------------ |++| M4 | s-320: 10 ms |++| M3 Pro | t-320: 6 ms s-320: 8 ms s-640: 20 ms |++| M1 | s-320: 9ms |### ROCm - AMD GPU-With the [rocm](../configuration/object_detectors.md#amdrocm-gpu-detector) detector Frigate can take advantage of many discrete AMD GPUs.+With the [ROCm](../configuration/object_detectors.md#amdrocm-gpu-detector) detector Frigate can take advantage of many discrete AMD GPUs.- | Name | YOLOv9 Inference Time | YOLO-NAS Inference Time |- | --------- | ------------------------- | ------------------------- |- | AMD 780M | t-320: 14 ms s-320: 20 ms | 320: ~ 25 ms 640: ~ 50 ms |-| Name | YOLOv9 Inference Time | YOLO-NAS Inference Time |-| --------- | --------------------- | ------------------------- |-| AMD 780M | 320: ~ 14 ms | 320: ~ 25 ms 640: ~ 50 ms |-| AMD 8700G | | 320: ~ 20 ms 640: ~ 40 ms |++| Name | YOLOv9 Inference Time | YOLO-NAS Inference Time |++| --------- | --------------------------- | ------------------------- |++| AMD 780M | t-320: ~ 14 ms s-320: 20 ms | 320: ~ 25 ms 640: ~ 50 ms |++| AMD 8700G | | 320: ~ 20 ms 640: ~ 40 ms |## Community Supported Detectors+### MemryX MX3++Frigate supports the MemryX MX3 M.2 AI Acceleration Module on compatible hardware platforms, including both x86 (Intel/AMD) and ARM-based SBCs such as Raspberry Pi 5.++A single MemryX MX3 module is capable of handling multiple camera streams using the default models, making it sufficient for most users. For larger deployments with more cameras or bigger models, multiple MX3 modules can be used. Frigate supports multi-detector configurations, allowing you to connect multiple MX3 modules to scale inference capacity.++Detailed information is available [in the detector docs](/configuration/object_detectors#memryx-mx3).++**Default Model Configuration:**++- Default model is **YOLO-NAS-Small**.++The MX3 is a pipelined architecture, where the maximum frames per second supported (and thus supported number of cameras) cannot be calculated as `1/latency` (1/"Inference Time") and is measured separately. When estimating how many camera streams you may support with your configuration, use the **MX3 Total FPS** column to approximate of the detector's limit, not the Inference Time.++| Model | Input Size | MX3 Inference Time | MX3 Total FPS |- |----------------------|------------|--------------------|---------------|++| -------------------- | ---------- | ------------------ | ------------- |+| YOLO-NAS-Small | 320 | ~ 9 ms | ~ 378 |+| YOLO-NAS-Small | 640 | ~ 21 ms | ~ 138 |+| YOLOv9s | 320 | ~ 16 ms | ~ 382 |+| YOLOv9s | 640 | ~ 41 ms | ~ 110 |+| YOLOX-Small | 640 | ~ 16 ms | ~ 263 |+| SSDlite MobileNet v2 | 320 | ~ 5 ms | ~ 1056 |++Inference speeds may vary depending on the host platform. The above data was measured on an **Intel 13700 CPU**. Platforms like Raspberry Pi, Orange Pi, and other ARM-based SBCs have different levels of processing capability, which may limit total FPS.+### Nvidia JetsonFrigate supports all Jetson boards, from the inexpensive Jetson Nano to the powerful Jetson Orin AGX. It will [make use of the Jetson's hardware media engine](/configuration/hardware_acceleration_video#nvidia-jetson-orin-agx-orin-nx-orin-nano-xavier-agx-xavier-nx-tx2-tx1-nano) when configured with the [appropriate presets](/configuration/ffmpeg_presets#hwaccel-presets), and will make use of the Jetson's GPU and DLA for object detection when configured with the [TensorRT detector](/configuration/object_detectors#nvidia-tensorrt-detector).diff --cc frigate/detectors/detector_config.pyindex d315f4cd50,7ee04bde5e..aa92f28f41--- a/frigate/detectors/detector_config.py+++ b/frigate/detectors/detector_config.py@@@ -154,13 -154,17 +154,17 @@@ class ModelConfig(BaseModel)self.width = model_info["width"]self.height = model_info["height"]- self.input_tensor = model_info["inputShape"]- self.input_pixel_format = model_info["pixelFormat"]- self.model_type = model_info["type"]+ self.input_tensor = InputTensorEnum(model_info["inputShape"])+ self.input_pixel_format = PixelFormatEnum(model_info["pixelFormat"])+ self.model_type = ModelTypeEnum(model_info["type"])if model_info.get("inputDataType"):- self.input_dtype = model_info["inputDataType"]+ self.input_dtype = InputDTypeEnum(model_info["inputDataType"])+ # RKNN always uses NHWC+ if detector == "rknn":+ self.input_tensor = InputTensorEnum.nhwc+# generate list of attribute labelsself.attributes_map = {**model_info.get("attributes", DEFAULT_ATTRIBUTE_LABEL_MAP),diff --cc frigate/embeddings/onnx/face_embedding.pyindex 77f2dbdca5,eb04b43b27..e661f8d376--- a/frigate/embeddings/onnx/face_embedding.py+++ b/frigate/embeddings/onnx/face_embedding.py@@@ -113,15 -110,15 +114,16 @@@ class FaceNetEmbedding(BaseEmbedding)class ArcfaceEmbedding(BaseEmbedding):- def __init__(self):+ def __init__(self, config: FaceRecognitionConfig):+ GITHUB_ENDPOINT = os.environ.get("GITHUB_ENDPOINT", "https://github.com")super().__init__(model_name="facedet",model_file="arcface.onnx",download_urls={- "arcface.onnx": "https://github.com/NickM-27/facenet-onnx/releases/download/v1.0/arcface.onnx",+ "arcface.onnx": f"{GITHUB_ENDPOINT}/NickM-27/facenet-onnx/releases/download/v1.0/arcface.onnx",},)+ self.config = configself.download_path = os.path.join(MODEL_CACHE_DIR, self.model_name)self.tokenizer = Noneself.feature_extractor = Nonediff --cc frigate/embeddings/onnx/lpr_embedding.pyindex e485bf6115,35ff5ceeed..ad20999572--- a/frigate/embeddings/onnx/lpr_embedding.py+++ b/frigate/embeddings/onnx/lpr_embedding.py@@@ -33,15 -32,14 +33,16 @@@ class PaddleOCRDetection(BaseEmbedding)device: str = "AUTO",):model_file = (- "detection-large.onnx" if model_size == "large" else "detection-small.onnx"+ "detection_v3-large.onnx"+ if model_size == "large"+ else "detection_v5-small.onnx")+ GITHUB_ENDPOINT = os.environ.get("GITHUB_ENDPOINT", "https://github.com")super().__init__(model_name="paddleocr-onnx",model_file=model_file,download_urls={- model_file: f"https://github.com/hawkeye217/paddleocr-onnx/raw/refs/heads/master/models/{'v3' if model_size == 'large' else 'v5'}/{model_file}"- model_file: f"{GITHUB_ENDPOINT}/hawkeye217/paddleocr-onnx/raw/refs/heads/master/models/{model_file}"++ model_file: f"{GITHUB_ENDPOINT}/hawkeye217/paddleocr-onnx/raw/refs/heads/master/models/{'v3' if model_size == 'large' else 'v5'}/{model_file}"},)self.requestor = requestor@@@ -157,12 -156,12 +159,13 @@@ class PaddleOCRRecognition(BaseEmbeddinrequestor: InterProcessRequestor,device: str = "AUTO",):+ GITHUB_ENDPOINT = os.environ.get("GITHUB_ENDPOINT", "https://github.com")super().__init__(model_name="paddleocr-onnx",- model_file="recognition.onnx",+ model_file="recognition_v4.onnx",download_urls={- "recognition_v4.onnx": "https://github.com/hawkeye217/paddleocr-onnx/raw/refs/heads/master/models/v4/recognition_v4.onnx",- "ppocr_keys_v1.txt": "https://github.com/hawkeye217/paddleocr-onnx/raw/refs/heads/master/models/v4/ppocr_keys_v1.txt",- "recognition.onnx": f"{GITHUB_ENDPOINT}/hawkeye217/paddleocr-onnx/raw/refs/heads/master/models/recognition.onnx"++ "recognition_v4.onnx": f"{GITHUB_ENDPOINT}/hawkeye217/paddleocr-onnx/raw/refs/heads/master/models/v4/recognition_v4.onnx",++ "ppocr_keys_v1.txt": f"{GITHUB_ENDPOINT}/hawkeye217/paddleocr-onnx/raw/refs/heads/master/models/v4/ppocr_keys_v1.txt",},)self.requestor = requestor