Refactor yolov9 detector to support v3, v4, v7 as well (#17697)

* Implement blobbed yolov7 post processing and consolidate yolo implementation

* Update documentation

* Add repo

* fix name
This commit is contained in:
Nicolas Mowen
2025-04-14 16:05:41 -05:00
committed by GitHub
parent 4feba8bcf3
commit bd0ee86db9
5 changed files with 145 additions and 32 deletions
+39 -15
View File
@@ -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,27 @@ 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
git clone https://github.com/WongKinYiu/yolov9
cd yolov9
wget -O yolov9-t.pt "https://github.com/WongKinYiu/yolov9/releases/download/v0.1/yolov9-t-converted.pt"
python3 export.py --weights ./yolov9-t-converted.pt --imgsz 320 --simplify
```