From a525374010ee8fcd83e5fe15ab95dd21691f8e3a Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Mon, 14 Apr 2025 11:03:25 -0600 Subject: [PATCH] Update documentation --- docs/docs/configuration/object_detectors.md | 52 +++++++++++++++------ frigate/detectors/plugins/onnx.py | 1 - 2 files changed, 37 insertions(+), 16 deletions(-) diff --git a/docs/docs/configuration/object_detectors.md b/docs/docs/configuration/object_detectors.md index 31f0df1dac..961fb94806 100644 --- a/docs/docs/configuration/object_detectors.md +++ b/docs/docs/configuration/object_detectors.md @@ -312,13 +312,13 @@ model: Note that the labelmap uses a subset of the complete COCO label set that has only 80 objects. -#### YOLOv9 +#### YOLO (v3, v4, v7, v9) -[YOLOv9](https://github.com/WongKinYiu/yolov9) models are supported, but not included by default. +YOLOv3, YOLOv4, YOLOv7, and [YOLOv9](https://github.com/WongKinYiu/yolov9) models are supported, but not included by default. :::tip -The YOLOv9 detector has been designed to support YOLOv9 models, but may support other YOLO model architectures as well. +The YOLO detector has been designed to support YOLOv3, YOLOv4, YOLOv7, and YOLOv9 models, but may support other YOLO model architectures as well. ::: @@ -331,12 +331,12 @@ detectors: device: GPU model: - model_type: yolov9 - width: 640 # <--- should match the imgsize set during model export - height: 640 # <--- should match the imgsize set during model export + model_type: yolo-generic + width: 320 # <--- should match the imgsize set during model export + height: 320 # <--- should match the imgsize set during model export input_tensor: nchw input_dtype: float - path: /config/model_cache/yolov9-t.onnx + path: /config/model_cache/yolo.onnx labelmap_path: /labelmap/coco-80.txt ``` @@ -653,13 +653,13 @@ model: labelmap_path: /labelmap/coco-80.txt ``` -#### YOLOv9 +#### YOLO (v3, v4, v7, v9) -[YOLOv9](https://github.com/WongKinYiu/yolov9) models are supported, but not included by default. +YOLOv3, YOLOv4, YOLOv7, and [YOLOv9](https://github.com/WongKinYiu/yolov9) models are supported, but not included by default. :::tip -The YOLOv9 detector has been designed to support YOLOv9 models, but may support other YOLO model architectures as well. +The YOLO detector has been designed to support YOLOv3, YOLOv4, YOLOv7, and YOLOv9 models, but may support other YOLO model architectures as well. ::: @@ -671,12 +671,12 @@ detectors: type: onnx model: - model_type: yolov9 - width: 640 # <--- should match the imgsize set during model export - height: 640 # <--- should match the imgsize set during model export + model_type: yolo-generic + width: 320 # <--- should match the imgsize set during model export + height: 320 # <--- should match the imgsize set during model export input_tensor: nchw input_dtype: float - path: /config/model_cache/yolov9-t.onnx + path: /config/model_cache/yolo.onnx labelmap_path: /labelmap/coco-80.txt ``` @@ -684,7 +684,7 @@ Note that the labelmap uses a subset of the complete COCO label set that has onl #### RF-DETR -[RF-DETR](https://github.com/roboflow/rf-detr) is a DETR based model. The ONNX exported models are supported, but not included by default. See [the models section](#downloading-rf-detr-model) for more informatoin on downloading the RF-DETR model for use in Frigate. +[RF-DETR](https://github.com/roboflow/rf-detr) is a DETR based model. The ONNX exported models are supported, but not included by default. See [the models section](#downloading-rf-detr-model) for more information on downloading the RF-DETR model for use in Frigate. After placing the downloaded onnx model in your `config/model_cache` folder, you can use the following configuration: @@ -959,3 +959,25 @@ The pre-trained YOLO-NAS weights from DeciAI are subject to their license and ca ::: The input image size in this notebook is set to 320x320. This results in lower CPU usage and faster inference times without impacting performance in most cases due to the way Frigate crops video frames to areas of interest before running detection. The notebook and config can be updated to 640x640 if desired. + +### Downloading YOLO Models + +#### YOLOv3, YOLOv4, and YOLOv7 + +To export as ONNX: + +```sh +git clone https://github.com/NateMeyer/tensorrt_demos +cd tensorrt_demos/yolo +./download_yolo.sh +python3 yolo_to_onnx.py -m yolov7-320 +``` + +#### YOLOv9 + +YOLOv9 models can be exported using the below code or they [can be downloaded from hugging face](https://huggingface.co/Xenova/yolov9-onnx/tree/main) + +```sh +wget -O yolov9-t.pt "https://github.com/WongKinYiu/yolov9/releases/download/v0.1/yolov9-t-converted.pt" +python3 export.py --weights ./yolov9-t.pt --imgsz 320 --simplify +``` diff --git a/frigate/detectors/plugins/onnx.py b/frigate/detectors/plugins/onnx.py index c3893ea25e..aef6e909b7 100644 --- a/frigate/detectors/plugins/onnx.py +++ b/frigate/detectors/plugins/onnx.py @@ -98,7 +98,6 @@ class ONNXDetector(DetectionApi): ] return detections elif self.onnx_model_type == ModelTypeEnum.yologeneric: - predictions: np.ndarray = tensor_output[0] return post_process_yolo(tensor_output, self.w, self.h) else: raise Exception(