mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-07-30 13:48:07 +02:00
Revamp YOLOv9 export guide
This commit is contained in:
parent
7680b050b4
commit
012dfde944
@ -1032,22 +1032,21 @@ python3 yolo_to_onnx.py -m yolov7-320
|
|||||||
|
|
||||||
#### YOLOv9
|
#### YOLOv9
|
||||||
|
|
||||||
YOLOv9 models can be exported using the below code
|
YOLOv9 model can be exported as ONNX using the below command:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
git clone https://github.com/WongKinYiu/yolov9
|
docker build . --output . -f- <<'EOF'
|
||||||
cd yolov9
|
FROM python:3.11 AS build
|
||||||
|
RUN apt-get update && apt-get install --no-install-recommends -y libgl1 && rm -rf /var/lib/apt/lists/*
|
||||||
# setup the virtual environment so installation doesn't affect main system
|
COPY --from=ghcr.io/astral-sh/uv:0.8.0 /uv /bin/
|
||||||
# NOTE: Virtual environment must be using Python 3.11 or older.
|
WORKDIR /yolov9
|
||||||
python3 -m venv ./
|
ADD https://github.com/WongKinYiu/yolov9.git .
|
||||||
bin/pip install -r requirements.txt
|
RUN uv pip install --system -r requirements.txt
|
||||||
bin/pip install onnx onnxruntime onnx-simplifier>=0.4.1
|
RUN uv pip install --system onnx onnxruntime onnx-simplifier>=0.4.1
|
||||||
|
ADD https://github.com/WongKinYiu/yolov9/releases/download/v0.1/yolov9-t-converted.pt yolov9-t.pt
|
||||||
# download the weights
|
RUN sed -i "s/ckpt = torch.load(attempt_download(w), map_location='cpu')/ckpt = torch.load(attempt_download(w), map_location='cpu', weights_only=False)/g" models/experimental.py
|
||||||
wget -O yolov9-t.pt "https://github.com/WongKinYiu/yolov9/releases/download/v0.1/yolov9-t-converted.pt" # download the weights
|
RUN python3 export.py --weights ./yolov9-t.pt --imgsz 320 --simplify --include onnx
|
||||||
|
FROM scratch
|
||||||
# prepare and run export script
|
COPY --from=build /yolov9/yolov9-t.onnx /
|
||||||
sed -i "s/ckpt = torch.load(attempt_download(w), map_location='cpu')/ckpt = torch.load(attempt_download(w), map_location='cpu', weights_only=False)/g" ./models/experimental.py
|
EOF
|
||||||
bin/python3 export.py --weights ./yolov9-t.pt --imgsz 320 --simplify --include onnx
|
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user