ต่อจากบล็อก Config Detector ด้วย OpenVINO ตอนนั้นใช้ model MobileNet ซึ่งเป็นตัว default ที่มากับ Frigate NVR อยู่แล้ว ทำงานได้ดี แต่ยังมีข้อจำกัดเล็กน้อย เวลาเจอวัตถุขนาดเล็ก

ลองเปลี่ยนมาใช้ YOLO-NAS เพราะโมเดลตัวนี้ขึ้นชื่อเรื่องการ detect วัตถุขนาดเล็กได้แม่นยำกว่า และยังคงทำงานได้เร็วใกล้เคียงกับ MobileNet

ตัวอย่าง docker-compose.yml

services:
  frigate:
    container_name: frigate
    restart: unless-stopped
    stop_grace_period: 30s
    image: ghcr.io/blakeblackshear/frigate:0.16.1
    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

ต้องเตรียมโมเดล YOLO-NAS S สามารถ export ออกมาเป็นไฟล์ yolo_nas_s.onnx ได้ง่าย ๆ ผ่าน Google Colab สามารถนำไปใช้เป็น detector ได้ทันที

ประสิทธิภาพของแต่ละรุ่น Performance Models

ให้นำไฟล์ yolo_nas_s.onnx ไปเก็บไว้ที่ config/model_cache

ตัวอย่าง /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: yolonas
  width: 320
  height: 320
  input_pixel_format: bgr
  input_tensor: nchw
  path: /config/model_cache/yolo_nas_s.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
      width: 640
      height: 360
      fps: 5

record:
  enabled: true

ทดสอบกับกล้อง 7 ตัว บันทึก 24/7 และเปิด detect 3 ตัว ผลลัพธ์ออกมาดี GPU ใช้งานไม่สูงมาก ระบบลื่น ไม่มีหน่วง Inference Speed ใกล้เคียง MobileNet แต่ตรวจจับวัตถุเล็กได้แม่นกว่า

GPU usage GPU usage ขณะรัน Frigate กับ YOLO-NAS

Detector Inference Speed ความเร็วในการประมวลผลของ Detector

Debug result ผลลัพธ์จาก Debug ของ Frigate

โดยรวมแล้ว YOLO-NAS S เป็นตัวเลือกที่คุ้มค่าสำหรับใครที่อยากให้ Frigate ตรวจจับได้ละเอียดขึ้น โดยไม่ต้องแลกกับประสิทธิภาพมากนัก 🙂


ตัวอย่างการทดสอบ YOLO-NAS S ทำงานร่วมกับ Frigate ได้ลื่นขนาดไหน 👇

@teeratech.com