จากบล็อกก่อนหน้า
ลองเปลี่ยน Frigate มาใช้ YOLO-NAS แทน MobileNet
รอบนี้มาลองทดสอบ YOLOv9 กันบ้าง ว่าประสิทธิภาพและความเร็วต่างจาก YOLO-NAS แค่ไหน
| Model | mAP (val) | Params | FLOPs | Latency | Reference |
|---|---|---|---|---|---|
| YOLO-NAS S | 47.5 | 19.0 M | 66.9 G | 3.21 ms | 👉 YOLO-NAS |
| YOLOv9-S | 46.8 | 7.1 M | 26.4 G | ~3.0 ms | 👉 YOLOv9 |
สรุป:
- ขนาดทดสอบ: 640×640
- YOLO-NAS S แม่นยำกว่าหน่อย (47.5 vs 46.8%)
- YOLOv9-S เบากว่าเยอะ (Params และ FLOPs ลดลงกว่าครึ่ง)
- Latency ใกล้เคียงกัน แต่ YOLOv9-S เหมาะกับ Edge Device มากกว่า
ตัวอย่าง docker-compose.yml
services:
frigate:
container_name: frigate
restart: unless-stopped
stop_grace_period: 30s
image: ghcr.io/blakeblackshear/frigate:0.16.2
shm_size: 64mb
cap_add:
- CAP_PERFMON
group_add:
- "104"
devices:
- /dev/dri/renderD128:/dev/dri/renderD128
volumes:
- /etc/localtime:/etc/localtime:ro
- ./config:/config
- ./storage:/media/frigate
- type: tmpfs
target: /tmp/cache
tmpfs:
size: 1000000000
ports:
- 5000:5000
environment:
- TZ=Asia/Bangkok
export model ออกมาเป็นไฟล์ yolov9-s-320.onnx และเก็บไว้ที่ config/model_cache
docker build . --build-arg MODEL_SIZE=s --build-arg IMG_SIZE=320 --output . -f- <<'EOF'
FROM python:3.11 AS build
RUN apt-get update && apt-get install --no-install-recommends -y libgl1 && rm -rf /var/lib/apt/lists/*
COPY --from=ghcr.io/astral-sh/uv:0.8.0 /uv /bin/
WORKDIR /yolov9
ADD https://github.com/WongKinYiu/yolov9.git .
RUN uv pip install --system -r requirements.txt
RUN uv pip install --system onnx==1.18.0 onnxruntime onnx-simplifier>=0.4.1 onnxscript
ARG MODEL_SIZE
ARG IMG_SIZE
ADD https://github.com/WongKinYiu/yolov9/releases/download/v0.1/yolov9-${MODEL_SIZE}-converted.pt yolov9-${MODEL_SIZE}.pt
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
RUN python3 export.py --weights ./yolov9-${MODEL_SIZE}.pt --imgsz ${IMG_SIZE} --simplify --include onnx
FROM scratch
ARG MODEL_SIZE
ARG IMG_SIZE
COPY --from=build /yolov9/yolov9-${MODEL_SIZE}.onnx /yolov9-${MODEL_SIZE}-${IMG_SIZE}.onnx
EOF
ตัวอย่าง /config/config.yml
go2rtc:
streams:
front_house:
- rtsp://admin:[email protected]:554/stream1
mqtt:
enabled: false
detectors:
ov:
type: openvino
device: GPU
model:
model_type: yolo-generic
width: 320
height: 320
input_tensor: nchw
input_dtype: float
path: /config/model_cache/yolov9-s-320.onnx
labelmap_path: /labelmap/coco-80.txt
ffmpeg:
hwaccel_args: preset-vaapi
input_args: preset-rtsp-restream
output_args:
record: preset-record-generic-audio-aac
cameras:
front_house:
ffmpeg:
inputs:
- path: rtsp://127.0.0.1:8554/front_house
roles:
- detect
detect:
enabled: true
record:
enabled: true
Inference Speed อยู่ประมาณ 30 ms ประสิทธิภาพใกล้เคียง YOLO-NAS.
ตัวอย่างการทดสอบ YOLOv9-S 👇
@teeratech.com

