Initial Frigate config with GPU detection

- Amcrest AD110 doorbell setup with go2rtc restreaming
- ONNX GPU detection using YOLOv9-s model on RTX 3060
- Auto day/night mode for IR switching
- CLAUDE.md with full setup documentation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-16 01:09:25 -06:00
commit d56f021fd8
2 changed files with 270 additions and 0 deletions

192
CLAUDE.md Normal file
View File

@@ -0,0 +1,192 @@
# CLAUDE.md
This file provides guidance to Claude Code when working with this Frigate NVR configuration.
## Next Steps / TODO
- Add more cameras this weekend
- Explore detection zones and masks
- Fine-tune object detection thresholds
- Consider Frigate+ for better models
## Overview
Frigate NVR running on Unraid (192.168.0.5) with NVIDIA RTX 3060 GPU detection.
## Server Details
- **Unraid Server:** 192.168.0.5
- **Frigate URL:** http://192.168.0.5:5341
- **Docker Image:** `ghcr.io/blakeblackshear/frigate:stable-tensorrt`
- **Config Path:** `/mnt/cache/appdata/frigate/config.yaml`
## Gitea Repository
- **URL:** http://192.168.0.5:3022/tonym/ha-frigate
- **API Token:** 8a04b3cb5dbb54e2d895b707305523c3ad83a945
## Camera: Amcrest AD110 Doorbell
- **IP:** 192.168.0.118
- **Credentials:** admin / tbhXM3131!
- **Main Stream (1080p):** `rtsp://admin:tbhXM3131!@192.168.0.118:554/cam/realmonitor?channel=1&subtype=0`
- **Sub Stream (480p):** `rtsp://admin:tbhXM3131!@192.168.0.118:554/cam/realmonitor?channel=1&subtype=1`
### Amcrest API Commands
```bash
# Set day/night mode (0=color, 1=auto, 2=B&W)
curl --digest -u admin:tbhXM3131! -g 'http://192.168.0.118/cgi-bin/configManager.cgi?action=setConfig&VideoInOptions[0].DayNightColor=1'
# Set IR LED mode (Auto/On/Off)
curl --digest -u admin:tbhXM3131! -g 'http://192.168.0.118/cgi-bin/configManager.cgi?action=setConfig&Lighting_V2[0][0][0].Mode=Auto'
# Get snapshot
curl --digest -u admin:tbhXM3131! 'http://192.168.0.118/cgi-bin/snapshot.cgi' -o snapshot.jpg
# Get encoding settings
curl --digest -u admin:tbhXM3131! 'http://192.168.0.118/cgi-bin/configManager.cgi?action=getConfig&name=Encode'
```
## GPU Detection Setup (ONNX + YOLOv9)
### Why ONNX?
- TensorRT detector deprecated on amd64 in Frigate 0.16+
- ONNX with onnxruntime-gpu uses CUDA automatically
- YOLOv9 more accurate than old TFLite models
### Model Conversion Process
Models must be converted locally - no direct downloads available.
```bash
# On Unraid, create conversion directory
mkdir -p /mnt/user/appdata/frigate-model-convert
cd /mnt/user/appdata/frigate-model-convert
# Create conversion script
cat > convert.sh << 'EOF'
#!/bin/bash
set -e
cd /work
if [ ! -d "yolov9" ]; then
git clone https://github.com/WongKinYiu/yolov9.git
fi
cd yolov9
pip install -q opencv-python-headless pandas seaborn onnx onnxsim scipy PyYAML tqdm matplotlib requests psutil
if [ ! -f "yolov9-s-converted.pt" ]; then
wget -q https://github.com/WongKinYiu/yolov9/releases/download/v0.1/yolov9-s-converted.pt
fi
python export.py --weights yolov9-s-converted.pt --imgsz 640 --simplify --include onnx
cp yolov9-s-converted.onnx /work/yolov9-s-640.onnx
EOF
# Run conversion in PyTorch container
docker run --rm -v /mnt/user/appdata/frigate-model-convert:/work -w /work \
pytorch/pytorch:2.1.0-cuda12.1-cudnn8-runtime bash -c \
'apt-get update -qq && apt-get install -y -qq git wget && bash convert.sh'
# Copy model to Frigate
cp /mnt/user/appdata/frigate-model-convert/yolov9-s-640.onnx /mnt/cache/appdata/frigate/model_cache/
```
### ONNX Config (working)
```yaml
detectors:
onnx:
type: onnx
model:
path: /config/model_cache/yolov9-s-640.onnx
input_tensor: nchw
input_pixel_format: rgb
width: 640
height: 640
model_type: yolo-generic
input_dtype: float
```
### Performance Results
- **CPU Detection:** 12% CPU, 11ms inference
- **GPU Detection:** 6.2% CPU, 17ms inference, RTX 3060 @ 6.4% VRAM
## Adding New Cameras
1. Add streams to `go2rtc.streams` section
2. Add camera config to `cameras` section
3. Restart Frigate: `docker restart frigate`
### Template for new camera:
```yaml
go2rtc:
streams:
newcam:
- rtsp://user:pass@IP:554/stream/path
newcam_sub:
- rtsp://user:pass@IP:554/substream/path
cameras:
newcam:
ffmpeg:
inputs:
- path: rtsp://127.0.0.1:8554/newcam_sub
input_args: preset-rtsp-restream
roles: [detect]
- path: rtsp://127.0.0.1:8554/newcam
input_args: preset-rtsp-restream
roles: [record]
detect:
enabled: true
width: 640
height: 480
fps: 5
```
## Common Commands
```bash
# SSH to Unraid
ssh root@192.168.0.5
# View Frigate logs
docker logs frigate -f
# Restart Frigate
docker restart frigate
# Check stats
curl -s 'http://localhost:5341/api/stats' | python3 -m json.tool
# Edit config
nano /mnt/cache/appdata/frigate/config.yaml
```
## MQTT
- **Broker:** 192.168.0.205:1883
- **User:** tonym
- **Topic Prefix:** frigate
## Troubleshooting
### Black & White Video
Camera stuck in IR mode. Fix:
```bash
curl --digest -u admin:tbhXM3131! -g 'http://192.168.0.118/cgi-bin/configManager.cgi?action=setConfig&VideoInOptions[0].DayNightColor=1'
curl --digest -u admin:tbhXM3131! -g 'http://192.168.0.118/cgi-bin/configManager.cgi?action=setConfig&Lighting_V2[0][0][0].Mode=Auto'
```
### ONNX Model Not Loading
- Check path exists: `docker exec frigate ls /config/model_cache/`
- Use `model_type: yolo-generic` (not `yolov9`)
- Ensure `input_dtype: float` is set
### Config Validation Errors
Check logs: `docker logs frigate 2>&1 | grep -A10 'Config Validation'`

78
config.yaml Normal file
View File

@@ -0,0 +1,78 @@
version: 0.16.1
mqtt:
host: 192.168.0.205
port: 1883
user: tonym
password: "tbhXM3131!"
topic_prefix: frigate
go2rtc:
streams:
front:
- rtsp://admin:tbhXM3131!@192.168.0.118:554/cam/realmonitor?channel=1&subtype=0
front_sub:
- rtsp://admin:tbhXM3131!@192.168.0.118:554/cam/realmonitor?channel=1&subtype=1
ffmpeg:
hwaccel_args: preset-nvidia
detectors:
onnx:
type: onnx
model:
path: /config/model_cache/yolov9-s-640.onnx
input_tensor: nchw
input_pixel_format: rgb
width: 640
height: 640
model_type: yolo-generic
input_dtype: float
objects:
track:
- person
birdseye:
enabled: false
cameras:
front:
ffmpeg:
inputs:
- path: rtsp://127.0.0.1:8554/front_sub
input_args: preset-rtsp-restream
roles: [detect]
- path: rtsp://127.0.0.1:8554/front
input_args: preset-rtsp-restream
roles: [record]
detect:
enabled: true
width: 640
height: 480
fps: 5
motion:
threshold: 30
contour_area: 10
improve_contrast: true
snapshots:
enabled: true
timestamp: true
bounding_box: true
record:
enabled: true
retain:
days: 5
mode: motion
objects:
filters:
person:
min_area: 2000
max_area: 100000
min_score: 0.65
threshold: 0.5
min_ratio: 0.3
max_ratio: 10
track:
- person