diff --git a/.cspell/frigate-dictionary.txt b/.cspell/frigate-dictionary.txt index 397584bd9b..6c0e8022f3 100644 --- a/.cspell/frigate-dictionary.txt +++ b/.cspell/frigate-dictionary.txt @@ -1,168 +1,303 @@ -rtmp -edgetpu -labelmap -rockchip -jetson -rocm -vaapi -CUDA -hwaccel -RTSP -Hikvision -Dahua +aarch +absdiff +airockchip +Alloc Amcrest -Reolink -Loryta +amdgpu +analyzeduration +Annke +apexcharts +arange +argmax +argmin +argpartition +ascontiguousarray +authelia +authentik +autodetected +automations +autotrack +autotracked +autotracker +autotracking +balena Beelink -Celeron -vaapi +BGRA +BHWC +blackshear blakeblackshear -workdir -onvif -autotracking -openvino -tflite -deepstack +bottombar +buildx +castable +cdist +Celeron +cgroups +chipset +chromadb +Chromecast +cmdline +codeowner +CODEOWNERS codeproject -udev -tailscale -restream -restreaming -webrtc -ssdlite -mobilenet -mosquitto +colormap +colorspace +comms +ctypeslib +CUDA +Cuvid +Dahua datasheet -Jellyfin -Radeon -libva -Ubiquiti -Unifi -Tapo -Annke -autotracker -autotracked -variations -ONVIF -traefik +debconf +deci +deepstack +defragment devcontainer -rootfs +DEVICEMAP +discardcorrupt +dpkg +dsize +dtype +ECONNRESET +edgetpu +faststart +fflags ffprobe -autotrack -logpipe -imread -imwrite -imencode -imutils -thresholded -timelapse -ultrafast -sleeptime -radeontop -vainfo -tmpfs -homography -websockets -LIBAVFORMAT -NTSC -onnxruntime +fillna +flac +foscam fourcc -radeonsi -paho -imagestream -jsonify -cgroups -sysconf -memlimit -gpuload -nvml -setproctitle -psutil -Kalman +framebuffer +fregate +frégate +fromarray +frombuffer frontdoor -namedtuples -zeep -fflags -probesize -wallclock -rknn -socs -pydantic -shms -imdecode -colormap -webui -mse -jsmpeg -unreviewed -Chromecast -Swipeable -flac -scroller -cmdline -toggleable -bottombar -opencv -apexcharts -buildx -mqtt -rawvideo -defragment -Norfair -subclassing -yolo -tensorrt -blackshear -stylelint +fstype +fullchain +fullscreen +genai +generativeai +genpts +getpid +gpuload HACS -homeassistant +Hailo hass -castable -mobiledet -framebuffer -mjpeg -substream -codeowner -noninteractive -restreamed -mountpoint -fstype -OWASP +hconcat +healthcheck +hideable +Hikvision +homeassistant +homekit +homography +hsize +hstack +httpx +hwaccel +hwdownload +hwmap +hwupload +iloc +imagestream +imdecode +imencode +imread +imutils +imwrite +interp +iostat iotop +itemsize +Jellyfin +jetson +jetsons +joserfc +jsmpeg +jsonify +Kalman +keepalive +keepdims +labelmap letsencrypt -fullchain +levelname +LIBAVFORMAT +libedgetpu +libnvinfer +libva +libwebp +libx +libyolo +linalg +localzone +logpipe +Loryta +lstsq lsusb -iostat -usermod -balena +markupsafe +maxsplit +MEMHOSTALLOC +memlimit +meshgrid +metadatas +migraphx +minilm +mjpeg +mkfifo +mobiledet +mobilenet +modelpath +mosquitto +mountpoint +movflags +mpegts +mqtt +mse +msenc +namedtuples +nbytes +nchw +ndarray +ndimage +nethogs +newaxis +nhwc +NOBLOCK +nobuffer +nokey +NONBLOCK +noninteractive +noprint +Norfair +nptype +NTSC +numpy +nvenc +nvhost +nvml +nvmpi +ollama +onnx +onnxruntime +onvif +ONVIF +openai +opencv +openvino +OWASP +paho passwordless -debconf -dpkg +popleft +posthog +postprocess poweroff -surveillance +preexec +probesize +protobuf +psutil +pubkey +putenv +pycache +pydantic +pyobj +pysqlite +pytz +pywebpush qnap -homekit -colorspace quantisation -skylake -Cuvid -foscam -onnx -numpy -protobuf -aarch -amdgpu -chipset -referer -mpegts -webp -authelia -authentik -unichip +Radeon +radeonsi +radeontop +rawvideo +rcond +RDONLY rebranded +referer +Reolink +restream +restreamed +restreaming +rkmpp +rknn +rkrga +rockchip +rocm +rocminfo +rootfs +rtmp +RTSP +ruamel +scroller +setproctitle +setpts +shms +SIGUSR +skylake +sleeptime +SNDMORE +socs +sqliteq +ssdlite +statm +stimeout +stylelint +subclassing +substream +superfast +surveillance +svscan +Swipeable +sysconf +tailscale +Tapo +tensorrt +tflite +thresholded +timelapse +tmpfs +tobytes +toggleable +traefik +tzlocal +Ubiquiti +udev udevadm -automations +ultrafast +unichip +unidecode +Unifi +unixepoch unraid -hideable -healthcheck -keepalive \ No newline at end of file +unreviewed +userdata +usermod +vaapi +vainfo +variations +vconcat +vitb +vstream +vsync +wallclock +webp +webpush +webrtc +websockets +webui +werkzeug +workdir +WRONLY +wsgirefserver +wsgiutils +wsize +xaddr +xmaxs +xmins +XPUB +XSUB +ymaxs +ymins +yolo +yolonas +yolox +zeep +zerolatency diff --git a/.devcontainer/post_create.sh b/.devcontainer/post_create.sh index 1a1832f3b6..ee08880163 100755 --- a/.devcontainer/post_create.sh +++ b/.devcontainer/post_create.sh @@ -17,7 +17,7 @@ sudo chown -R "$(id -u):$(id -g)" /media/frigate # When started as a service, LIBAVFORMAT_VERSION_MAJOR is defined in the # s6 service file. For dev, where frigate is started from an interactive # shell, we define it in .bashrc instead. -echo 'export LIBAVFORMAT_VERSION_MAJOR=$(ffmpeg -version | grep -Po "libavformat\W+\K\d+")' >> $HOME/.bashrc +echo 'export LIBAVFORMAT_VERSION_MAJOR=$(/usr/lib/ffmpeg/7.0/bin/ffmpeg -version | grep -Po "libavformat\W+\K\d+")' >> $HOME/.bashrc make version diff --git a/.github/DISCUSSION_TEMPLATE/bug-report.yml b/.github/DISCUSSION_TEMPLATE/bug-report.yml deleted file mode 100644 index c1c34fb51e..0000000000 --- a/.github/DISCUSSION_TEMPLATE/bug-report.yml +++ /dev/null @@ -1,83 +0,0 @@ -title: "[Bug]: " -labels: ["bug", "triage"] -body: - - type: textarea - id: description - attributes: - label: Describe the problem you are having - validations: - required: true - - type: textarea - id: steps - attributes: - label: Steps to reproduce - validations: - required: true - - type: input - id: version - attributes: - label: Version - description: Visible on the System page in the Web UI - validations: - required: true - - type: textarea - id: config - attributes: - label: Frigate config file - description: This will be automatically formatted into code, so no need for backticks. - render: yaml - validations: - required: true - - type: textarea - id: logs - attributes: - label: Relevant log output - description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks. - render: shell - validations: - required: true - - type: dropdown - id: os - attributes: - label: Operating system - options: - - HassOS - - Debian - - Other Linux - - Proxmox - - UNRAID - - Windows - - Other - validations: - required: true - - type: dropdown - id: install-method - attributes: - label: Install method - options: - - HassOS Addon - - Docker Compose - - Docker CLI - validations: - required: true - - type: dropdown - id: network - attributes: - label: Network connection - options: - - Wired - - Wireless - - Mixed - validations: - required: true - - type: input - id: camera - attributes: - label: Camera make and model - description: Dahua, hikvision, amcrest, reolink, etc and model number - validations: - required: true - - type: textarea - id: other - attributes: - label: Any other information that may be helpful diff --git a/.github/DISCUSSION_TEMPLATE/camera-support.yml b/.github/DISCUSSION_TEMPLATE/camera-support.yml index 6f99790df3..bbbffea500 100644 --- a/.github/DISCUSSION_TEMPLATE/camera-support.yml +++ b/.github/DISCUSSION_TEMPLATE/camera-support.yml @@ -1,6 +1,16 @@ title: "[Camera Support]: " labels: ["support", "triage"] body: + - type: markdown + attributes: + value: | + Use this form for support or questions for an issue with your cameras. + + Before submitting your support request, please [search the discussions][discussions], read the [official Frigate documentation][docs], and read the [Frigate FAQ][faq] pinned at the Discussion page to see if your question has already been answered by the community. + + [discussions]: https://www.github.com/blakeblackshear/frigate/discussions + [docs]: https://docs.frigate.video + [faq]: https://github.com/blakeblackshear/frigate/discussions/12724 - type: textarea id: description attributes: @@ -11,9 +21,15 @@ body: id: version attributes: label: Version - description: Visible on the System page in the Web UI + description: Visible on the System page in the Web UI. Please include the full version including the build identifier (eg. 0.14.0-ea36ds1) validations: required: true + - type: input + attributes: + label: What browser(s) are you using? + placeholder: Google Chrome 88.0.4324.150 + description: > + Provide the full name and don't forget to add the version! - type: textarea id: config attributes: @@ -23,10 +39,18 @@ body: validations: required: true - type: textarea - id: logs + id: frigatelogs + attributes: + label: Relevant Frigate log output + description: Please copy and paste any relevant Frigate log output. Include logs before and after your exact error when possible. This will be automatically formatted into code, so no need for backticks. + render: shell + validations: + required: true + - type: textarea + id: go2rtclogs attributes: - label: Relevant log output - description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks. + label: Relevant go2rtc log output + description: Please copy and paste any relevant go2rtc log output. Include logs before and after your exact error when possible. Logs can be viewed via the Frigate UI, Docker, or the go2rtc dashboard. This will be automatically formatted into code, so no need for backticks. render: shell validations: required: true @@ -34,7 +58,7 @@ body: id: ffprobe attributes: label: FFprobe output from your camera - description: Run `ffprobe ` and provide output below + description: Run `ffprobe ` from within the Frigate container if possible, and provide output below render: shell validations: required: true @@ -78,7 +102,7 @@ body: - TensorRT - RKNN - Other - - CPU (no coral) + - CPU (no Coral) validations: required: true - type: dropdown @@ -98,6 +122,13 @@ body: description: Dahua, hikvision, amcrest, reolink, etc and model number validations: required: true + - type: textarea + id: screenshots + attributes: + label: Screenshots of the Frigate UI's System metrics pages + description: Drag and drop for images is possible in this field. Please post screenshots of at least General and Cameras tabs. + validations: + required: true - type: textarea id: other attributes: diff --git a/.github/DISCUSSION_TEMPLATE/config-support.yml b/.github/DISCUSSION_TEMPLATE/config-support.yml index 3a9265f448..5b70b1d914 100644 --- a/.github/DISCUSSION_TEMPLATE/config-support.yml +++ b/.github/DISCUSSION_TEMPLATE/config-support.yml @@ -1,6 +1,16 @@ title: "[Config Support]: " labels: ["support", "triage"] body: + - type: markdown + attributes: + value: | + Use this form for support or questions related to Frigate's configuration and config file. + + Before submitting your support request, please [search the discussions][discussions], read the [official Frigate documentation][docs], and read the [Frigate FAQ][faq] pinned at the Discussion page to see if your question has already been answered by the community. + + [discussions]: https://www.github.com/blakeblackshear/frigate/discussions + [docs]: https://docs.frigate.video + [faq]: https://github.com/blakeblackshear/frigate/discussions/12724 - type: textarea id: description attributes: @@ -11,7 +21,7 @@ body: id: version attributes: label: Version - description: Visible on the System page in the Web UI + description: Visible on the System page in the Web UI. Please include the full version including the build identifier (eg. 0.14.0-ea36ds1) validations: required: true - type: textarea @@ -23,10 +33,18 @@ body: validations: required: true - type: textarea - id: logs + id: frigatelogs + attributes: + label: Relevant Frigate log output + description: Please copy and paste any relevant Frigate log output. Include logs before and after your exact error when possible. This will be automatically formatted into code, so no need for backticks. + render: shell + validations: + required: true + - type: textarea + id: go2rtclogs attributes: - label: Relevant log output - description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks. + label: Relevant go2rtc log output + description: Please copy and paste any relevant go2rtc log output. Include logs before and after your exact error when possible. This will be automatically formatted into code, so no need for backticks. render: shell validations: required: true @@ -73,6 +91,11 @@ body: - CPU (no coral) validations: required: true + - type: textarea + id: screenshots + attributes: + label: Screenshots of the Frigate UI's System metrics pages + description: Drag and drop or simple cut/paste is possible in this field - type: textarea id: other attributes: diff --git a/.github/DISCUSSION_TEMPLATE/detector-support.yml b/.github/DISCUSSION_TEMPLATE/detector-support.yml index c09aec2ec6..e4ae976a3e 100644 --- a/.github/DISCUSSION_TEMPLATE/detector-support.yml +++ b/.github/DISCUSSION_TEMPLATE/detector-support.yml @@ -1,6 +1,16 @@ title: "[Detector Support]: " labels: ["support", "triage"] body: + - type: markdown + attributes: + value: | + Use this form for support or questions related to Frigate's object detectors. + + Before submitting your support request, please [search the discussions][discussions], read the [official Frigate documentation][docs], and read the [Frigate FAQ][faq] pinned at the Discussion page to see if your question has already been answered by the community. + + [discussions]: https://www.github.com/blakeblackshear/frigate/discussions + [docs]: https://docs.frigate.video + [faq]: https://github.com/blakeblackshear/frigate/discussions/12724 - type: textarea id: description attributes: @@ -11,7 +21,7 @@ body: id: version attributes: label: Version - description: Visible on the System page in the Web UI + description: Visible on the System page in the Web UI. Please include the full version including the build identifier (eg. 0.14.0-ea36ds1) validations: required: true - type: textarea @@ -31,10 +41,18 @@ body: validations: required: true - type: textarea - id: logs + id: frigatelogs + attributes: + label: Relevant Frigate log output + description: Please copy and paste any relevant Frigate log output. Include logs before and after your exact error when possible. This will be automatically formatted into code, so no need for backticks. + render: shell + validations: + required: true + - type: textarea + id: go2rtclogs attributes: - label: Relevant log output - description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks. + label: Relevant go2rtc log output + description: Please copy and paste any relevant go2rtc log output. Include logs before and after your exact error when possible. Logs can be viewed via the Frigate UI, Docker, or the go2rtc dashboard. This will be automatically formatted into code, so no need for backticks. render: shell validations: required: true @@ -75,6 +93,13 @@ body: - CPU (no coral) validations: required: true + - type: textarea + id: screenshots + attributes: + label: Screenshots of the Frigate UI's System metrics pages + description: Drag and drop for images is possible in this field. Please post screenshots of at least General and Cameras tabs. + validations: + required: true - type: textarea id: other attributes: diff --git a/.github/DISCUSSION_TEMPLATE/general-support.yml b/.github/DISCUSSION_TEMPLATE/general-support.yml index cb9bd1992a..0ae7d7083b 100644 --- a/.github/DISCUSSION_TEMPLATE/general-support.yml +++ b/.github/DISCUSSION_TEMPLATE/general-support.yml @@ -1,6 +1,16 @@ title: "[Support]: " labels: ["support", "triage"] body: + - type: markdown + attributes: + value: | + Use this form for support for issues that don't fall into any specific category. + + Before submitting your support request, please [search the discussions][discussions], read the [official Frigate documentation][docs], and read the [Frigate FAQ][faq] pinned at the Discussion page to see if your question has already been answered by the community. + + [discussions]: https://www.github.com/blakeblackshear/frigate/discussions + [docs]: https://docs.frigate.video + [faq]: https://github.com/blakeblackshear/frigate/discussions/12724 - type: textarea id: description attributes: @@ -11,9 +21,15 @@ body: id: version attributes: label: Version - description: Visible on the System page in the Web UI + description: Visible on the System page in the Web UI. Please include the full version including the build identifier (eg. 0.14.0-ea36ds1) validations: required: true + - type: input + attributes: + label: What browser(s) are you using? + placeholder: Google Chrome 88.0.4324.150 + description: > + Provide the full name and don't forget to add the version! - type: textarea id: config attributes: @@ -23,10 +39,18 @@ body: validations: required: true - type: textarea - id: logs + id: frigatelogs + attributes: + label: Relevant Frigate log output + description: Please copy and paste any relevant Frigate log output. Include logs before and after your exact error when possible. This will be automatically formatted into code, so no need for backticks. + render: shell + validations: + required: true + - type: textarea + id: go2rtclogs attributes: - label: Relevant log output - description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks. + label: Relevant go2rtc log output + description: Please copy and paste any relevant go2rtc log output. Include logs before and after your exact error when possible. Logs can be viewed via the Frigate UI, Docker, or the go2rtc dashboard. This will be automatically formatted into code, so no need for backticks. render: shell validations: required: true @@ -34,7 +58,7 @@ body: id: ffprobe attributes: label: FFprobe output from your camera - description: Run `ffprobe ` and provide output below + description: Run `ffprobe ` from within the Frigate container if possible, and provide output below render: shell validations: required: true @@ -98,6 +122,11 @@ body: description: Dahua, hikvision, amcrest, reolink, etc and model number validations: required: true + - type: textarea + id: screenshots + attributes: + label: Screenshots of the Frigate UI's System metrics pages + description: Drag and drop for images is possible in this field - type: textarea id: other attributes: diff --git a/.github/DISCUSSION_TEMPLATE/hardware-acceleration-support.yml b/.github/DISCUSSION_TEMPLATE/hardware-acceleration-support.yml index 43960c537d..1b7094fd7b 100644 --- a/.github/DISCUSSION_TEMPLATE/hardware-acceleration-support.yml +++ b/.github/DISCUSSION_TEMPLATE/hardware-acceleration-support.yml @@ -1,6 +1,16 @@ title: "[HW Accel Support]: " labels: ["support", "triage"] body: + - type: markdown + attributes: + value: | + Use this form to submit a support request for hardware acceleration issues. + + Before submitting your support request, please [search the discussions][discussions], read the [official Frigate documentation][docs], and read the [Frigate FAQ][faq] pinned at the Discussion page to see if your question has already been answered by the community. + + [discussions]: https://www.github.com/blakeblackshear/frigate/discussions + [docs]: https://docs.frigate.video + [faq]: https://github.com/blakeblackshear/frigate/discussions/12724 - type: textarea id: description attributes: @@ -11,9 +21,15 @@ body: id: version attributes: label: Version - description: Visible on the System page in the Web UI + description: Visible on the System page in the Web UI. Please include the full version including the build identifier (eg. 0.14.0-ea36ds1) validations: required: true + - type: input + attributes: + label: In which browser(s) are you experiencing the issue with? + placeholder: Google Chrome 88.0.4324.150 + description: > + Provide the full name and don't forget to add the version! - type: textarea id: config attributes: @@ -31,10 +47,18 @@ body: validations: required: true - type: textarea - id: logs + id: frigatelogs + attributes: + label: Relevant Frigate log output + description: Please copy and paste any relevant Frigate log output. Include logs before and after your exact error when possible. This will be automatically formatted into code, so no need for backticks. + render: shell + validations: + required: true + - type: textarea + id: go2rtclogs attributes: - label: Relevant log output - description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks. + label: Relevant go2rtc log output + description: Please copy and paste any relevant go2rtc log output. Include logs before and after your exact error when possible. Logs can be viewed via the Frigate UI, Docker, or the go2rtc dashboard. This will be automatically formatted into code, so no need for backticks. render: shell validations: required: true @@ -42,7 +66,7 @@ body: id: ffprobe attributes: label: FFprobe output from your camera - description: Run `ffprobe ` and provide output below + description: Run `ffprobe ` from within the Frigate container if possible, and provide output below render: shell validations: required: true @@ -87,6 +111,13 @@ body: description: Dahua, hikvision, amcrest, reolink, etc and model number validations: required: true + - type: textarea + id: screenshots + attributes: + label: Screenshots of the Frigate UI's System metrics pages + description: Drag and drop for images is possible in this field. Please post screenshots of at least General and Cameras tabs. + validations: + required: true - type: textarea id: other attributes: diff --git a/.github/DISCUSSION_TEMPLATE/question.yml b/.github/DISCUSSION_TEMPLATE/question.yml index 41339e6092..6a4789c9c5 100644 --- a/.github/DISCUSSION_TEMPLATE/question.yml +++ b/.github/DISCUSSION_TEMPLATE/question.yml @@ -1,9 +1,21 @@ title: "[Question]: " labels: ["question"] body: + - type: markdown + attributes: + value: | + Use this form for questions you have about Frigate. + + Before submitting your question, please [search the discussions][discussions], read the [official Frigate documentation][docs], and read the [Frigate FAQ][faq] pinned at the Discussion page to see if your question has already been answered by the community. + + **If you are looking for support, start a new discussion and use a support category.** + + [discussions]: https://www.github.com/blakeblackshear/frigate/discussions + [docs]: https://docs.frigate.video + [faq]: https://github.com/blakeblackshear/frigate/discussions/12724 - type: textarea id: description attributes: - label: "What is your question:" + label: "What is your question?" validations: required: true diff --git a/.github/DISCUSSION_TEMPLATE/report-a-bug.yml b/.github/DISCUSSION_TEMPLATE/report-a-bug.yml new file mode 100644 index 0000000000..dba6d695e3 --- /dev/null +++ b/.github/DISCUSSION_TEMPLATE/report-a-bug.yml @@ -0,0 +1,146 @@ +title: "[Bug]: " +labels: ["bug", "triage"] +body: + - type: markdown + attributes: + value: | + Use this form to submit a reproducible bug in Frigate or Frigate's UI. + + Before submitting your bug report, please [search the discussions][discussions], look at recent open and closed [pull requests][prs], read the [official Frigate documentation][docs], and read the [Frigate FAQ][faq] pinned at the Discussion page to see if your bug has already been fixed by the developers or reported by the community. + + **If you are unsure if your issue is actually a bug or not, please submit a support request first.** + + [discussions]: https://www.github.com/blakeblackshear/frigate/discussions + [prs]: https://www.github.com/blakeblackshear/frigate/pulls + [docs]: https://docs.frigate.video + [faq]: https://github.com/blakeblackshear/frigate/discussions/12724 + - type: checkboxes + attributes: + label: Checklist + description: Please verify that you've followed these steps + options: + - label: I have updated to the latest available Frigate version. + required: true + - label: I have cleared the cache of my browser. + required: true + - label: I have tried a different browser to see if it is related to my browser. + required: true + - label: I have tried reproducing the issue in [incognito mode](https://www.computerworld.com/article/1719851/how-to-go-incognito-in-chrome-firefox-safari-and-edge.html) to rule out problems with any third party extensions or plugins I have installed. + - type: textarea + id: description + attributes: + label: Describe the problem you are having + description: Provide a clear and concise description of what the bug is. + validations: + required: true + - type: textarea + id: steps + attributes: + label: Steps to reproduce + description: | + Please tell us exactly how to reproduce your issue. + Provide clear and concise step by step instructions and add code snippets if needed. + value: | + 1. + 2. + 3. + ... + validations: + required: true + - type: input + id: version + attributes: + label: Version + description: Visible on the System page in the Web UI. Please include the full version including the build identifier (eg. 0.14.0-ea36ds1) + validations: + required: true + - type: input + attributes: + label: In which browser(s) are you experiencing the issue with? + placeholder: Google Chrome 88.0.4324.150 + description: > + Provide the full name and don't forget to add the version! + - type: textarea + id: config + attributes: + label: Frigate config file + description: This will be automatically formatted into code, so no need for backticks. + render: yaml + validations: + required: true + - type: textarea + id: docker + attributes: + label: docker-compose file or Docker CLI command + description: This will be automatically formatted into code, so no need for backticks. + render: yaml + validations: + required: true + - type: textarea + id: frigatelogs + attributes: + label: Relevant Frigate log output + description: Please copy and paste any relevant Frigate log output. Include logs before and after your exact error when possible. This will be automatically formatted into code, so no need for backticks. + render: shell + validations: + required: true + - type: textarea + id: go2rtclogs + attributes: + label: Relevant go2rtc log output + description: Please copy and paste any relevant go2rtc log output. Include logs before and after your exact error when possible. Logs can be viewed via the Frigate UI, Docker, or the go2rtc dashboard. This will be automatically formatted into code, so no need for backticks. + render: shell + validations: + required: true + - type: dropdown + id: os + attributes: + label: Operating system + options: + - HassOS + - Debian + - Other Linux + - Proxmox + - UNRAID + - Windows + - Other + validations: + required: true + - type: dropdown + id: install-method + attributes: + label: Install method + options: + - HassOS Addon + - Docker Compose + - Docker CLI + validations: + required: true + - type: dropdown + id: network + attributes: + label: Network connection + options: + - Wired + - Wireless + - Mixed + validations: + required: true + - type: input + id: camera + attributes: + label: Camera make and model + description: Dahua, hikvision, amcrest, reolink, etc and model number + validations: + required: true + - type: textarea + id: screenshots + attributes: + label: Screenshots of the Frigate UI's System metrics pages + description: Drag and drop for images is possible in this field. Please post screenshots of all tabs. + validations: + required: true + - type: textarea + id: other + attributes: + label: Any other information that may be helpful diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 88ceab9355..793ea7d42e 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -5,7 +5,7 @@ inputs: required: true outputs: image-name: - value: ghcr.io/${{ steps.lowercaseRepo.outputs.lowercase }}:${{ github.ref_name }}-${{ steps.create-short-sha.outputs.SHORT_SHA }} + value: ghcr.io/${{ steps.lowercaseRepo.outputs.lowercase }}:${{ steps.create-short-sha.outputs.SHORT_SHA }} cache-name: value: ghcr.io/${{ steps.lowercaseRepo.outputs.lowercase }}:cache runs: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 860c8b4e44..619d71d48a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -155,57 +155,42 @@ jobs: tensorrt.tags=${{ steps.setup.outputs.image-name }}-tensorrt *.cache-from=type=registry,ref=${{ steps.setup.outputs.cache-name }}-amd64 *.cache-to=type=registry,ref=${{ steps.setup.outputs.cache-name }}-amd64,mode=max - #- name: AMD/ROCm general build - # env: - # AMDGPU: gfx - # HSA_OVERRIDE: 0 - # uses: docker/bake-action@v3 - # with: - # push: true - # targets: rocm - # files: docker/rocm/rocm.hcl - # set: | - # rocm.tags=${{ steps.setup.outputs.image-name }}-rocm - # *.cache-from=type=gha - #- name: AMD/ROCm gfx900 - # env: - # AMDGPU: gfx900 - # HSA_OVERRIDE: 1 - # HSA_OVERRIDE_GFX_VERSION: 9.0.0 - # uses: docker/bake-action@v3 - # with: - # push: true - # targets: rocm - # files: docker/rocm/rocm.hcl - # set: | - # rocm.tags=${{ steps.setup.outputs.image-name }}-rocm-gfx900 - # *.cache-from=type=gha - #- name: AMD/ROCm gfx1030 - # env: - # AMDGPU: gfx1030 - # HSA_OVERRIDE: 1 - # HSA_OVERRIDE_GFX_VERSION: 10.3.0 - # uses: docker/bake-action@v3 - # with: - # push: true - # targets: rocm - # files: docker/rocm/rocm.hcl - # set: | - # rocm.tags=${{ steps.setup.outputs.image-name }}-rocm-gfx1030 - # *.cache-from=type=gha - #- name: AMD/ROCm gfx1100 - # env: - # AMDGPU: gfx1100 - # HSA_OVERRIDE: 1 - # HSA_OVERRIDE_GFX_VERSION: 11.0.0 - # uses: docker/bake-action@v3 - # with: - # push: true - # targets: rocm - # files: docker/rocm/rocm.hcl - # set: | - # rocm.tags=${{ steps.setup.outputs.image-name }}-rocm-gfx1100 - # *.cache-from=type=gha + combined_extra_builds: + runs-on: ubuntu-latest + name: Combined Extra Builds + needs: + - amd64_build + - arm64_build + steps: + - name: Check out code + uses: actions/checkout@v4 + - name: Set up QEMU and Buildx + id: setup + uses: ./.github/actions/setup + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push Hailo-8l build + uses: docker/bake-action@v4 + with: + push: true + targets: h8l + files: docker/hailo8l/h8l.hcl + set: | + h8l.tags=${{ steps.setup.outputs.image-name }}-h8l + *.cache-from=type=registry,ref=${{ steps.setup.outputs.cache-name }}-h8l + *.cache-to=type=registry,ref=${{ steps.setup.outputs.cache-name }}-h8l,mode=max + - name: AMD/ROCm general build + env: + AMDGPU: gfx + HSA_OVERRIDE: 0 + uses: docker/bake-action@v3 + with: + push: true + targets: rocm + files: docker/rocm/rocm.hcl + set: | + rocm.tags=${{ steps.setup.outputs.image-name }}-rocm + *.cache-from=type=gha # The majority of users running arm64 are rpi users, so the rpi # build should be the primary arm64 image assemble_default_build: @@ -229,7 +214,7 @@ jobs: run: echo "SHORT_SHA=${GITHUB_SHA::7}" >> $GITHUB_ENV - uses: int128/docker-manifest-create-action@v2 with: - tags: ghcr.io/${{ steps.lowercaseRepo.outputs.lowercase }}:${{ github.ref_name }}-${{ env.SHORT_SHA }} + tags: ghcr.io/${{ steps.lowercaseRepo.outputs.lowercase }}:${{ env.SHORT_SHA }} sources: | - ghcr.io/${{ steps.lowercaseRepo.outputs.lowercase }}:${{ github.ref_name }}-${{ env.SHORT_SHA }}-amd64 - ghcr.io/${{ steps.lowercaseRepo.outputs.lowercase }}:${{ github.ref_name }}-${{ env.SHORT_SHA }}-rpi + ghcr.io/${{ steps.lowercaseRepo.outputs.lowercase }}:${{ env.SHORT_SHA }}-amd64 + ghcr.io/${{ steps.lowercaseRepo.outputs.lowercase }}:${{ env.SHORT_SHA }}-rpi diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b51381956a..97d22202e1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,10 +23,10 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Create tag variables run: | - BRANCH=dev - echo "BRANCH=${BRANCH}" >> $GITHUB_ENV + BUILD_TYPE=$([[ "${{ github.ref_name }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] && echo "stable" || echo "beta") + echo "BUILD_TYPE=${BUILD_TYPE}" >> $GITHUB_ENV echo "BASE=ghcr.io/${{ steps.lowercaseRepo.outputs.lowercase }}" >> $GITHUB_ENV - echo "BUILD_TAG=${BRANCH}-${GITHUB_SHA::7}" >> $GITHUB_ENV + echo "BUILD_TAG=${GITHUB_SHA::7}" >> $GITHUB_ENV echo "CLEAN_VERSION=$(echo ${GITHUB_REF##*/} | tr '[:upper:]' '[:lower:]' | sed 's/^[v]//')" >> $GITHUB_ENV - name: Tag and push the main image run: | @@ -39,7 +39,7 @@ jobs: done # stable tag - if [[ "${BRANCH}" == "master" ]]; then + if [[ "${BUILD_TYPE}" == "stable" ]]; then docker run --rm -v $HOME/.docker/config.json:/config.json quay.io/skopeo/stable:latest copy --authfile /config.json --multi-arch all docker://${PULL_TAG} docker://${STABLE_TAG} for variant in standard-arm64 tensorrt tensorrt-jp4 tensorrt-jp5 rk; do docker run --rm -v $HOME/.docker/config.json:/config.json quay.io/skopeo/stable:latest copy --authfile /config.json --multi-arch all docker://${PULL_TAG}-${variant} docker://${STABLE_TAG}-${variant} diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 172eaeca6f..8e7e3223cb 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -25,17 +25,17 @@ jobs: - name: Print outputs run: echo ${{ join(steps.stale.outputs.*, ',') }} - clean_ghcr: - name: Delete outdated dev container images - runs-on: ubuntu-latest - steps: - - name: Delete old images - uses: snok/container-retention-policy@v2 - with: - image-names: dev-* - cut-off: 60 days ago UTC - keep-at-least: 5 - account-type: personal - token: ${{ secrets.GITHUB_TOKEN }} - token-type: github-token + # clean_ghcr: + # name: Delete outdated dev container images + # runs-on: ubuntu-latest + # steps: + # - name: Delete old images + # uses: snok/container-retention-policy@v2 + # with: + # image-names: dev-* + # cut-off: 60 days ago UTC + # keep-at-least: 5 + # account-type: personal + # token: ${{ secrets.GITHUB_TOKEN }} + # token-type: github-token diff --git a/.vscode/launch.json b/.vscode/launch.json index fe709c92d3..5c858267d8 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -3,10 +3,9 @@ "configurations": [ { "name": "Python: Launch Frigate", - "type": "python", + "type": "debugpy", "request": "launch", - "module": "frigate", - "justMyCode": true + "module": "frigate" } ] } diff --git a/CODEOWNERS b/CODEOWNERS index edae5de842..c37041c2c3 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -4,3 +4,4 @@ /docker/tensorrt/*jetson* @madsciencetist /docker/rockchip/ @MarcA711 /docker/rocm/ @harakas +/docker/hailo8l/ @spanner3003 diff --git a/Makefile b/Makefile index 0cfd9b282a..b7c6ab821b 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,9 @@ default_target: local COMMIT_HASH := $(shell git log -1 --pretty=format:"%h"|tail -1) -VERSION = 0.14.0 +VERSION = 0.15.0 IMAGE_REPO ?= ghcr.io/blakeblackshear/frigate GITHUB_REF_NAME ?= $(shell git rev-parse --abbrev-ref HEAD) -CURRENT_UID := $(shell id -u) -CURRENT_GID := $(shell id -g) BOARDS= #Initialized empty include docker/*/*.mk @@ -18,25 +16,38 @@ version: echo 'VERSION = "$(VERSION)-$(COMMIT_HASH)"' > frigate/version.py local: version - docker buildx build --target=frigate --tag frigate:latest --load --file docker/main/Dockerfile . + docker buildx build --target=frigate --file docker/main/Dockerfile . \ + --tag frigate:latest \ + --load amd64: - docker buildx build --platform linux/amd64 --target=frigate --tag $(IMAGE_REPO):$(VERSION)-$(COMMIT_HASH) --file docker/main/Dockerfile . + docker buildx build --target=frigate --file docker/main/Dockerfile . \ + --tag $(IMAGE_REPO):$(VERSION)-$(COMMIT_HASH) \ + --platform linux/amd64 arm64: - docker buildx build --platform linux/arm64 --target=frigate --tag $(IMAGE_REPO):$(VERSION)-$(COMMIT_HASH) --file docker/main/Dockerfile . + docker buildx build --target=frigate --file docker/main/Dockerfile . \ + --tag $(IMAGE_REPO):$(VERSION)-$(COMMIT_HASH) \ + --platform linux/arm64 build: version amd64 arm64 - docker buildx build --platform linux/arm64/v8,linux/amd64 --target=frigate --tag $(IMAGE_REPO):$(VERSION)-$(COMMIT_HASH) --file docker/main/Dockerfile . + docker buildx build --target=frigate --file docker/main/Dockerfile . \ + --tag $(IMAGE_REPO):$(VERSION)-$(COMMIT_HASH) \ + --platform linux/arm64/v8,linux/amd64 push: push-boards - docker buildx build --push --platform linux/arm64/v8,linux/amd64 --target=frigate --tag $(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH) --file docker/main/Dockerfile . + docker buildx build --target=frigate --file docker/main/Dockerfile . \ + --tag $(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH) \ + --platform linux/arm64/v8,linux/amd64 \ + --push run: local docker run --rm --publish=5000:5000 --volume=${PWD}/config:/config frigate:latest run_tests: local - docker run --rm --workdir=/opt/frigate --entrypoint= frigate:latest python3 -u -m unittest - docker run --rm --workdir=/opt/frigate --entrypoint= frigate:latest python3 -u -m mypy --config-file frigate/mypy.ini frigate + docker run --rm --workdir=/opt/frigate --entrypoint= frigate:latest \ + python3 -u -m unittest + docker run --rm --workdir=/opt/frigate --entrypoint= frigate:latest \ + python3 -u -m mypy --config-file frigate/mypy.ini frigate .PHONY: run_tests diff --git a/cspell.json b/cspell.json index e325bbb69f..132e51532b 100644 --- a/cspell.json +++ b/cspell.json @@ -7,7 +7,8 @@ "*.db", "node_modules", "__pycache__", - "dist" + "dist", + "/audio-labelmap.txt" ], "language": "en", "dictionaryDefinitions": [ diff --git a/docker/hailo8l/Dockerfile b/docker/hailo8l/Dockerfile new file mode 100644 index 0000000000..391f6f5414 --- /dev/null +++ b/docker/hailo8l/Dockerfile @@ -0,0 +1,104 @@ +# syntax=docker/dockerfile:1.6 + +ARG DEBIAN_FRONTEND=noninteractive + +# Build Python wheels +FROM wheels AS h8l-wheels + +COPY docker/main/requirements-wheels.txt /requirements-wheels.txt +COPY docker/hailo8l/requirements-wheels-h8l.txt /requirements-wheels-h8l.txt + +RUN sed -i "/https:\/\//d" /requirements-wheels.txt + +# Create a directory to store the built wheels +RUN mkdir /h8l-wheels + +# Build the wheels +RUN pip3 wheel --wheel-dir=/h8l-wheels -c /requirements-wheels.txt -r /requirements-wheels-h8l.txt + +# Build HailoRT and create wheel +FROM wheels AS build-hailort +ARG TARGETARCH + +SHELL ["/bin/bash", "-c"] + +# Install necessary APT packages +RUN apt-get -qq update \ + && apt-get -qq install -y \ + apt-transport-https \ + gnupg \ + wget \ + # the key fingerprint can be obtained from https://ftp-master.debian.org/keys.html + && wget -qO- "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xA4285295FC7B1A81600062A9605C66F00D6C9793" | \ + gpg --dearmor > /usr/share/keyrings/debian-archive-bullseye-stable.gpg \ + && echo "deb [signed-by=/usr/share/keyrings/debian-archive-bullseye-stable.gpg] http://deb.debian.org/debian bullseye main contrib non-free" | \ + tee /etc/apt/sources.list.d/debian-bullseye-nonfree.list \ + && apt-get -qq update \ + && apt-get -qq install -y \ + python3.9 \ + python3.9-dev \ + build-essential cmake git \ + && rm -rf /var/lib/apt/lists/* + +# Extract Python version and set environment variables +RUN PYTHON_VERSION=$(python3 --version 2>&1 | awk '{print $2}' | cut -d. -f1,2) && \ + PYTHON_VERSION_NO_DOT=$(echo $PYTHON_VERSION | sed 's/\.//') && \ + echo "PYTHON_VERSION=$PYTHON_VERSION" > /etc/environment && \ + echo "PYTHON_VERSION_NO_DOT=$PYTHON_VERSION_NO_DOT" >> /etc/environment + +# Clone and build HailoRT +RUN . /etc/environment && \ + git clone https://github.com/hailo-ai/hailort.git /opt/hailort && \ + cd /opt/hailort && \ + git checkout v4.17.0 && \ + cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Release -DHAILO_BUILD_PYBIND=1 -DPYBIND11_PYTHON_VERSION=${PYTHON_VERSION} && \ + cmake --build build --config release --target libhailort && \ + cmake --build build --config release --target _pyhailort && \ + cp build/hailort/libhailort/bindings/python/src/_pyhailort.cpython-${PYTHON_VERSION_NO_DOT}-$(if [ $TARGETARCH == "amd64" ]; then echo 'x86_64'; else echo 'aarch64'; fi )-linux-gnu.so hailort/libhailort/bindings/python/platform/hailo_platform/pyhailort/ && \ + cp build/hailort/libhailort/src/libhailort.so hailort/libhailort/bindings/python/platform/hailo_platform/pyhailort/ + +RUN ls -ahl /opt/hailort/build/hailort/libhailort/src/ +RUN ls -ahl /opt/hailort/hailort/libhailort/bindings/python/platform/hailo_platform/pyhailort/ + +# Remove the existing setup.py if it exists in the target directory +RUN rm -f /opt/hailort/hailort/libhailort/bindings/python/platform/setup.py + +# Copy generate_wheel_conf.py and setup.py +COPY docker/hailo8l/pyhailort_build_scripts/generate_wheel_conf.py /opt/hailort/hailort/libhailort/bindings/python/platform/generate_wheel_conf.py +COPY docker/hailo8l/pyhailort_build_scripts/setup.py /opt/hailort/hailort/libhailort/bindings/python/platform/setup.py + +# Run the generate_wheel_conf.py script +RUN python3 /opt/hailort/hailort/libhailort/bindings/python/platform/generate_wheel_conf.py + +# Create a wheel file using pip3 wheel +RUN cd /opt/hailort/hailort/libhailort/bindings/python/platform && \ + python3 setup.py bdist_wheel --dist-dir /hailo-wheels + +# Use deps as the base image +FROM deps AS h8l-frigate + +# Copy the wheels from the wheels stage +COPY --from=h8l-wheels /h8l-wheels /deps/h8l-wheels +COPY --from=build-hailort /hailo-wheels /deps/hailo-wheels +COPY --from=build-hailort /etc/environment /etc/environment +RUN CC=$(python3 -c "import sysconfig; import shlex; cc = sysconfig.get_config_var('CC'); cc_cmd = shlex.split(cc)[0]; print(cc_cmd[:-4] if cc_cmd.endswith('-gcc') else cc_cmd)") && \ + echo "CC=$CC" >> /etc/environment + +# Install the wheels +RUN pip3 install -U /deps/h8l-wheels/*.whl +RUN pip3 install -U /deps/hailo-wheels/*.whl + +RUN . /etc/environment && \ + mv /usr/local/lib/python${PYTHON_VERSION}/dist-packages/hailo_platform/pyhailort/libhailort.so /usr/lib/${CC} && \ + cd /usr/lib/${CC}/ && \ + ln -s libhailort.so libhailort.so.4.17.0 + +# Copy base files from the rootfs stage +COPY --from=rootfs / / + +# Set environment variables for Hailo SDK +ENV PATH="/opt/hailort/bin:${PATH}" +ENV LD_LIBRARY_PATH="/usr/lib/$(if [ $TARGETARCH == "amd64" ]; then echo 'x86_64'; else echo 'aarch64'; fi )-linux-gnu:${LD_LIBRARY_PATH}" + +# Set workdir +WORKDIR /opt/frigate/ diff --git a/docker/hailo8l/h8l.hcl b/docker/hailo8l/h8l.hcl new file mode 100644 index 0000000000..a1eb82fb5e --- /dev/null +++ b/docker/hailo8l/h8l.hcl @@ -0,0 +1,27 @@ +target wheels { + dockerfile = "docker/main/Dockerfile" + platforms = ["linux/arm64","linux/amd64"] + target = "wheels" +} + +target deps { + dockerfile = "docker/main/Dockerfile" + platforms = ["linux/arm64","linux/amd64"] + target = "deps" +} + +target rootfs { + dockerfile = "docker/main/Dockerfile" + platforms = ["linux/arm64","linux/amd64"] + target = "rootfs" +} + +target h8l { + dockerfile = "docker/hailo8l/Dockerfile" + contexts = { + wheels = "target:wheels" + deps = "target:deps" + rootfs = "target:rootfs" + } + platforms = ["linux/arm64","linux/amd64"] +} diff --git a/docker/hailo8l/h8l.mk b/docker/hailo8l/h8l.mk new file mode 100644 index 0000000000..3187718029 --- /dev/null +++ b/docker/hailo8l/h8l.mk @@ -0,0 +1,15 @@ +BOARDS += h8l + +local-h8l: version + docker buildx bake --file=docker/hailo8l/h8l.hcl h8l \ + --set h8l.tags=frigate:latest-h8l \ + --load + +build-h8l: version + docker buildx bake --file=docker/hailo8l/h8l.hcl h8l \ + --set h8l.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-h8l + +push-h8l: build-h8l + docker buildx bake --file=docker/hailo8l/h8l.hcl h8l \ + --set h8l.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-h8l \ + --push \ No newline at end of file diff --git a/docker/hailo8l/pyhailort_build_scripts/generate_wheel_conf.py b/docker/hailo8l/pyhailort_build_scripts/generate_wheel_conf.py new file mode 100644 index 0000000000..a0e4987f16 --- /dev/null +++ b/docker/hailo8l/pyhailort_build_scripts/generate_wheel_conf.py @@ -0,0 +1,67 @@ +import json +import os +import platform +import sys +import sysconfig + + +def extract_toolchain_info(compiler): + # Remove the "-gcc" or "-g++" suffix if present + if compiler.endswith("-gcc") or compiler.endswith("-g++"): + compiler = compiler.rsplit("-", 1)[0] + + # Extract the toolchain and ABI part (e.g., "gnu") + toolchain_parts = compiler.split("-") + abi_conventions = next( + (part for part in toolchain_parts if part in ["gnu", "musl", "eabi", "uclibc"]), + "", + ) + + return abi_conventions + + +def generate_wheel_conf(): + conf_file_path = os.path.join( + os.path.abspath(os.path.dirname(__file__)), "wheel_conf.json" + ) + + # Extract current system and Python version information + py_version = f"cp{sys.version_info.major}{sys.version_info.minor}" + arch = platform.machine() + system = platform.system().lower() + libc_version = platform.libc_ver()[1] + + # Get the compiler information + compiler = sysconfig.get_config_var("CC") + abi_conventions = extract_toolchain_info(compiler) + + # Create the new configuration data + new_conf_data = { + "py_version": py_version, + "arch": arch, + "system": system, + "libc_version": libc_version, + "abi": abi_conventions, + "extension": { + "posix": "so", + "nt": "pyd", # Windows + }[os.name], + } + + # If the file exists, load the existing data + if os.path.isfile(conf_file_path): + with open(conf_file_path, "r") as conf_file: + conf_data = json.load(conf_file) + # Update the existing data with the new data + conf_data.update(new_conf_data) + else: + # If the file does not exist, use the new data + conf_data = new_conf_data + + # Write the updated data to the file + with open(conf_file_path, "w") as conf_file: + json.dump(conf_data, conf_file, indent=4) + + +if __name__ == "__main__": + generate_wheel_conf() diff --git a/docker/hailo8l/pyhailort_build_scripts/setup.py b/docker/hailo8l/pyhailort_build_scripts/setup.py new file mode 100644 index 0000000000..2abe07ee5f --- /dev/null +++ b/docker/hailo8l/pyhailort_build_scripts/setup.py @@ -0,0 +1,111 @@ +import json +import os + +from setuptools import find_packages, setup +from wheel.bdist_wheel import bdist_wheel as orig_bdist_wheel + + +class NonPurePythonBDistWheel(orig_bdist_wheel): + """Makes the wheel platform-dependent so it can be based on the _pyhailort architecture""" + + def finalize_options(self): + orig_bdist_wheel.finalize_options(self) + self.root_is_pure = False + + +def _get_hailort_lib_path(): + lib_filename = "libhailort.so" + lib_path = os.path.join( + os.path.abspath(os.path.dirname(__file__)), + f"hailo_platform/pyhailort/{lib_filename}", + ) + if os.path.exists(lib_path): + print(f"Found libhailort shared library at: {lib_path}") + else: + print(f"Error: libhailort shared library not found at: {lib_path}") + raise FileNotFoundError(f"libhailort shared library not found at: {lib_path}") + return lib_path + + +def _get_pyhailort_lib_path(): + conf_file_path = os.path.join( + os.path.abspath(os.path.dirname(__file__)), "wheel_conf.json" + ) + if not os.path.isfile(conf_file_path): + raise FileNotFoundError(f"Configuration file not found: {conf_file_path}") + + with open(conf_file_path, "r") as conf_file: + content = json.load(conf_file) + py_version = content["py_version"] + arch = content["arch"] + system = content["system"] + extension = content["extension"] + abi = content["abi"] + + # Construct the filename directly + lib_filename = f"_pyhailort.cpython-{py_version.split('cp')[1]}-{arch}-{system}-{abi}.{extension}" + lib_path = os.path.join( + os.path.abspath(os.path.dirname(__file__)), + f"hailo_platform/pyhailort/{lib_filename}", + ) + + if os.path.exists(lib_path): + print(f"Found _pyhailort shared library at: {lib_path}") + else: + print(f"Error: _pyhailort shared library not found at: {lib_path}") + raise FileNotFoundError( + f"_pyhailort shared library not found at: {lib_path}" + ) + + return lib_path + + +def _get_package_paths(): + packages = [] + pyhailort_lib = _get_pyhailort_lib_path() + hailort_lib = _get_hailort_lib_path() + if pyhailort_lib: + packages.append(pyhailort_lib) + if hailort_lib: + packages.append(hailort_lib) + packages.append(os.path.abspath("hailo_tutorials/notebooks/*")) + packages.append(os.path.abspath("hailo_tutorials/hefs/*")) + return packages + + +if __name__ == "__main__": + setup( + author="Hailo team", + author_email="contact@hailo.ai", + cmdclass={ + "bdist_wheel": NonPurePythonBDistWheel, + }, + description="HailoRT", + entry_points={ + "console_scripts": [ + "hailo=hailo_platform.tools.hailocli.main:main", + ] + }, + install_requires=[ + "argcomplete", + "contextlib2", + "future", + "netaddr", + "netifaces", + "verboselogs", + "numpy==1.23.3", + ], + name="hailort", + package_data={ + "hailo_platform": _get_package_paths(), + }, + packages=find_packages(), + platforms=[ + "linux_x86_64", + "linux_aarch64", + "win_amd64", + ], + url="https://hailo.ai/", + version="4.17.0", + zip_safe=False, + ) diff --git a/docker/hailo8l/requirements-wheels-h8l.txt b/docker/hailo8l/requirements-wheels-h8l.txt new file mode 100644 index 0000000000..55b67e0962 --- /dev/null +++ b/docker/hailo8l/requirements-wheels-h8l.txt @@ -0,0 +1,12 @@ +appdirs==1.4.4 +argcomplete==2.0.0 +contextlib2==0.6.0.post1 +distlib==0.3.6 +filelock==3.8.0 +future==0.18.2 +importlib-metadata==5.1.0 +importlib-resources==5.1.2 +netaddr==0.8.0 +netifaces==0.10.9 +verboselogs==1.7 +virtualenv==20.17.0 \ No newline at end of file diff --git a/docker/hailo8l/user_installation.sh b/docker/hailo8l/user_installation.sh new file mode 100644 index 0000000000..0f40bbaac1 --- /dev/null +++ b/docker/hailo8l/user_installation.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# Update package list and install dependencies +sudo apt-get update +sudo apt-get install -y build-essential cmake git wget linux-modules-extra-$(uname -r) + +arch=$(uname -m) + +if [[ $arch == "x86_64" ]]; then + sudo apt install -y linux-headers-$(uname -r); +else + sudo apt install -y linux-modules-extra-$(uname -r); +fi + +# Clone the HailoRT driver repository +git clone --depth 1 --branch v4.17.0 https://github.com/hailo-ai/hailort-drivers.git + +# Build and install the HailoRT driver +cd hailort-drivers/linux/pcie +sudo make all +sudo make install + +# Load the Hailo PCI driver +sudo modprobe hailo_pci + +# Download and install the firmware +cd ../../ +./download_firmware.sh +sudo mv hailo8_fw.4.17.0.bin /lib/firmware/hailo/hailo8_fw.bin + +# Install udev rules +sudo cp ./linux/pcie/51-hailo-udev.rules /etc/udev/rules.d/ +sudo udevadm control --reload-rules && sudo udevadm trigger + +echo "HailoRT driver installation complete." diff --git a/docker/main/Dockerfile b/docker/main/Dockerfile index ca14306f9b..3cd73cf95f 100644 --- a/docker/main/Dockerfile +++ b/docker/main/Dockerfile @@ -148,6 +148,8 @@ RUN apt-get -qq update \ gfortran openexr libatlas-base-dev libssl-dev\ libtbb2 libtbb-dev libdc1394-22-dev libopenexr-dev \ libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev \ + # sqlite3 dependencies + tclsh \ # scipy dependencies gcc gfortran libopenblas-dev liblapack-dev && \ rm -rf /var/lib/apt/lists/* @@ -161,9 +163,16 @@ RUN wget -q https://bootstrap.pypa.io/get-pip.py -O get-pip.py \ COPY docker/main/requirements.txt /requirements.txt RUN pip3 install -r /requirements.txt +# Build pysqlite3 from source to support ChromaDB +COPY docker/main/build_pysqlite3.sh /build_pysqlite3.sh +RUN /build_pysqlite3.sh + COPY docker/main/requirements-wheels.txt /requirements-wheels.txt RUN pip3 wheel --wheel-dir=/wheels -r /requirements-wheels.txt +COPY docker/main/requirements-wheels-post.txt /requirements-wheels-post.txt +RUN pip3 wheel --no-deps --wheel-dir=/wheels-post -r /requirements-wheels-post.txt + # Collect deps in a single layer FROM scratch AS deps-rootfs @@ -188,7 +197,15 @@ ARG APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=DontWarn ENV NVIDIA_VISIBLE_DEVICES=all ENV NVIDIA_DRIVER_CAPABILITIES="compute,video,utility" -ENV PATH="/usr/lib/btbn-ffmpeg/bin:/usr/local/go2rtc/bin:/usr/local/tempio/bin:/usr/local/nginx/sbin:${PATH}" +# Turn off Chroma Telemetry: https://docs.trychroma.com/telemetry#opting-out +ENV ANONYMIZED_TELEMETRY=False +# Allow resetting the chroma database +ENV ALLOW_RESET=True +# Disable tokenizer parallelism warning +ENV TOKENIZERS_PARALLELISM=true + +ENV PATH="/usr/local/go2rtc/bin:/usr/local/tempio/bin:/usr/local/nginx/sbin:${PATH}" +ENV LIBAVFORMAT_VERSION_MAJOR=60 # Install dependencies RUN --mount=type=bind,source=docker/main/install_deps.sh,target=/deps/install_deps.sh \ @@ -198,6 +215,14 @@ RUN --mount=type=bind,from=wheels,source=/wheels,target=/deps/wheels \ python3 -m pip install --upgrade pip && \ pip3 install -U /deps/wheels/*.whl +# We have to uninstall this dependency specifically +# as it will break onnxruntime-openvino +RUN pip3 uninstall -y onnxruntime + +RUN --mount=type=bind,from=wheels,source=/wheels-post,target=/deps/wheels \ + python3 -m pip install --upgrade pip && \ + pip3 install -U /deps/wheels/*.whl + COPY --from=deps-rootfs / / RUN ldconfig diff --git a/docker/main/build_pysqlite3.sh b/docker/main/build_pysqlite3.sh new file mode 100755 index 0000000000..6375b33fa2 --- /dev/null +++ b/docker/main/build_pysqlite3.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +set -euxo pipefail + +SQLITE3_VERSION="96c92aba00c8375bc32fafcdf12429c58bd8aabfcadab6683e35bbb9cdebf19e" # 3.46.0 +PYSQLITE3_VERSION="0.5.3" + +# Fetch the source code for the latest release of Sqlite. +if [[ ! -d "sqlite" ]]; then + wget https://www.sqlite.org/src/tarball/sqlite.tar.gz?r=${SQLITE3_VERSION} -O sqlite.tar.gz + tar xzf sqlite.tar.gz + cd sqlite/ + LIBS="-lm" ./configure --disable-tcl --enable-tempstore=always + make sqlite3.c + cd ../ + rm sqlite.tar.gz +fi + +# Grab the pysqlite3 source code. +if [[ ! -d "./pysqlite3" ]]; then + git clone https://github.com/coleifer/pysqlite3.git +fi + +cd pysqlite3/ +git checkout ${PYSQLITE3_VERSION} + +# Copy the sqlite3 source amalgamation into the pysqlite3 directory so we can +# create a self-contained extension module. +cp "../sqlite/sqlite3.c" ./ +cp "../sqlite/sqlite3.h" ./ + +# Create the wheel and put it in the /wheels dir. +sed -i "s|name='pysqlite3-binary'|name=PACKAGE_NAME|g" setup.py +python3 setup.py build_static +pip3 wheel . -w /wheels diff --git a/docker/main/install_deps.sh b/docker/main/install_deps.sh index cc1031fe1f..e640a61d1d 100755 --- a/docker/main/install_deps.sh +++ b/docker/main/install_deps.sh @@ -39,32 +39,54 @@ apt-get -qq install --no-install-recommends --no-install-suggests -y \ # btbn-ffmpeg -> amd64 if [[ "${TARGETARCH}" == "amd64" ]]; then - mkdir -p /usr/lib/btbn-ffmpeg + mkdir -p /usr/lib/ffmpeg/5.0 + mkdir -p /usr/lib/ffmpeg/7.0 wget -qO btbn-ffmpeg.tar.xz "https://github.com/NickM-27/FFmpeg-Builds/releases/download/autobuild-2022-07-31-12-37/ffmpeg-n5.1-2-g915ef932a3-linux64-gpl-5.1.tar.xz" - tar -xf btbn-ffmpeg.tar.xz -C /usr/lib/btbn-ffmpeg --strip-components 1 - rm -rf btbn-ffmpeg.tar.xz /usr/lib/btbn-ffmpeg/doc /usr/lib/btbn-ffmpeg/bin/ffplay + tar -xf btbn-ffmpeg.tar.xz -C /usr/lib/ffmpeg/5.0 --strip-components 1 + rm -rf btbn-ffmpeg.tar.xz /usr/lib/ffmpeg/5.0/doc /usr/lib/ffmpeg/5.0/bin/ffplay + wget -qO btbn-ffmpeg.tar.xz "https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2024-09-19-12-51/ffmpeg-n7.0.2-18-g3e6cec1286-linux64-gpl-7.0.tar.xz" + tar -xf btbn-ffmpeg.tar.xz -C /usr/lib/ffmpeg/7.0 --strip-components 1 + rm -rf btbn-ffmpeg.tar.xz /usr/lib/ffmpeg/7.0/doc /usr/lib/ffmpeg/7.0/bin/ffplay fi # ffmpeg -> arm64 if [[ "${TARGETARCH}" == "arm64" ]]; then - mkdir -p /usr/lib/btbn-ffmpeg + mkdir -p /usr/lib/ffmpeg/5.0 + mkdir -p /usr/lib/ffmpeg/7.0 wget -qO btbn-ffmpeg.tar.xz "https://github.com/NickM-27/FFmpeg-Builds/releases/download/autobuild-2022-07-31-12-37/ffmpeg-n5.1-2-g915ef932a3-linuxarm64-gpl-5.1.tar.xz" - tar -xf btbn-ffmpeg.tar.xz -C /usr/lib/btbn-ffmpeg --strip-components 1 - rm -rf btbn-ffmpeg.tar.xz /usr/lib/btbn-ffmpeg/doc /usr/lib/btbn-ffmpeg/bin/ffplay + tar -xf btbn-ffmpeg.tar.xz -C /usr/lib/ffmpeg/5.0 --strip-components 1 + rm -rf btbn-ffmpeg.tar.xz /usr/lib/ffmpeg/5.0/doc /usr/lib/ffmpeg/5.0/bin/ffplay + wget -qO btbn-ffmpeg.tar.xz "https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2024-09-19-12-51/ffmpeg-n7.0.2-18-g3e6cec1286-linuxarm64-gpl-7.0.tar.xz" + tar -xf btbn-ffmpeg.tar.xz -C /usr/lib/ffmpeg/7.0 --strip-components 1 + rm -rf btbn-ffmpeg.tar.xz /usr/lib/ffmpeg/7.0/doc /usr/lib/ffmpeg/7.0/bin/ffplay fi # arch specific packages if [[ "${TARGETARCH}" == "amd64" ]]; then - # use debian bookworm for hwaccel packages + # use debian bookworm for amd / intel-i965 driver packages echo 'deb https://deb.debian.org/debian bookworm main contrib non-free' >/etc/apt/sources.list.d/debian-bookworm.list apt-get -qq update apt-get -qq install --no-install-recommends --no-install-suggests -y \ - intel-opencl-icd \ - mesa-va-drivers radeontop libva-drm2 intel-media-va-driver-non-free i965-va-driver libmfx1 intel-gpu-tools + i965-va-driver intel-gpu-tools onevpl-tools \ + libva-drm2 \ + mesa-va-drivers radeontop + # something about this dependency requires it to be installed in a separate call rather than in the line above apt-get -qq install --no-install-recommends --no-install-suggests -y \ i965-va-driver-shaders + rm -f /etc/apt/sources.list.d/debian-bookworm.list + + # use intel apt intel packages + wget -qO - https://repositories.intel.com/gpu/intel-graphics.key | gpg --yes --dearmor --output /usr/share/keyrings/intel-graphics.gpg + echo "deb [arch=amd64 signed-by=/usr/share/keyrings/intel-graphics.gpg] https://repositories.intel.com/gpu/ubuntu jammy client" | tee /etc/apt/sources.list.d/intel-gpu-jammy.list + apt-get -qq update + apt-get -qq install --no-install-recommends --no-install-suggests -y \ + intel-opencl-icd intel-level-zero-gpu intel-media-va-driver-non-free \ + libmfx1 libmfxgen1 libvpl2 + + rm -f /usr/share/keyrings/intel-graphics.gpg + rm -f /etc/apt/sources.list.d/intel-gpu-jammy.list fi if [[ "${TARGETARCH}" == "arm64" ]]; then @@ -72,6 +94,10 @@ if [[ "${TARGETARCH}" == "arm64" ]]; then libva-drm2 mesa-va-drivers fi +# install vulkan +apt-get -qq install --no-install-recommends --no-install-suggests -y \ + libvulkan1 mesa-vulkan-drivers + apt-get purge gnupg apt-transport-https xz-utils -y apt-get clean autoclean -y apt-get autoremove --purge -y diff --git a/docker/main/requirements-wheels-post.txt b/docker/main/requirements-wheels-post.txt new file mode 100644 index 0000000000..c4ed338444 --- /dev/null +++ b/docker/main/requirements-wheels-post.txt @@ -0,0 +1,3 @@ +# ONNX +onnxruntime-openvino == 1.18.* ; platform_machine == 'x86_64' +onnxruntime == 1.18.* ; platform_machine == 'aarch64' \ No newline at end of file diff --git a/docker/main/requirements-wheels.txt b/docker/main/requirements-wheels.txt index 84c5a867c1..639d4b3c84 100644 --- a/docker/main/requirements-wheels.txt +++ b/docker/main/requirements-wheels.txt @@ -1,8 +1,8 @@ click == 8.1.* Flask == 3.0.* -Flask_Limiter == 3.7.* +Flask_Limiter == 3.8.* imutils == 0.5.* -joserfc == 0.11.* +joserfc == 1.0.* markupsafe == 2.1.* mypy == 1.6.1 numpy == 1.26.* @@ -11,13 +11,13 @@ opencv-python-headless == 4.9.0.* paho-mqtt == 2.1.* pandas == 2.2.* peewee == 3.17.* -peewee_migrate == 1.12.* +peewee_migrate == 1.13.* psutil == 5.9.* -pydantic == 2.7.* +pydantic == 2.8.* git+https://github.com/fbcotter/py3nvml#egg=py3nvml PyYAML == 6.0.* pytz == 2024.1 -pyzmq == 26.0.* +pyzmq == 26.2.* ruamel.yaml == 0.18.* tzlocal == 5.2 types-PyYAML == 6.0.* @@ -28,5 +28,15 @@ norfair == 2.2.* setproctitle == 1.3.* ws4py == 0.5.* unidecode == 1.3.* -onnxruntime == 1.18.* +# OpenVino & ONNX openvino == 2024.1.* +# Embeddings +chromadb == 0.5.0 +onnx_clip == 4.0.* +# Generative AI +google-generativeai == 0.6.* +ollama == 0.2.* +openai == 1.30.* +# push notifications +py-vapid == 1.9.* +pywebpush == 2.0.* diff --git a/docker/main/rootfs/etc/s6-overlay/s6-rc.d/chroma-log/consumer-for b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/chroma-log/consumer-for new file mode 100644 index 0000000000..4b935d3cb5 --- /dev/null +++ b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/chroma-log/consumer-for @@ -0,0 +1 @@ +chroma \ No newline at end of file diff --git a/docker/rocm/rootfs/etc/s6-overlay/s6-rc.d/compile-rocm-models/dependencies.d/download-models b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/chroma-log/dependencies.d/log-prepare similarity index 100% rename from docker/rocm/rootfs/etc/s6-overlay/s6-rc.d/compile-rocm-models/dependencies.d/download-models rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/chroma-log/dependencies.d/log-prepare diff --git a/docker/main/rootfs/etc/s6-overlay/s6-rc.d/chroma-log/pipeline-name b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/chroma-log/pipeline-name new file mode 100644 index 0000000000..71256e9ed9 --- /dev/null +++ b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/chroma-log/pipeline-name @@ -0,0 +1 @@ +chroma-pipeline \ No newline at end of file diff --git a/docker/main/rootfs/etc/s6-overlay/s6-rc.d/chroma-log/run b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/chroma-log/run new file mode 100755 index 0000000000..2e47fd3ebe --- /dev/null +++ b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/chroma-log/run @@ -0,0 +1,4 @@ +#!/command/with-contenv bash +# shellcheck shell=bash + +exec logutil-service /dev/shm/logs/chroma diff --git a/docker/main/rootfs/etc/s6-overlay/s6-rc.d/chroma-log/type b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/chroma-log/type new file mode 100644 index 0000000000..5883cff0cd --- /dev/null +++ b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/chroma-log/type @@ -0,0 +1 @@ +longrun diff --git a/docker/rocm/rootfs/etc/s6-overlay/s6-rc.d/frigate/dependencies.d/compile-rocm-models b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/chroma/dependencies.d/base similarity index 100% rename from docker/rocm/rootfs/etc/s6-overlay/s6-rc.d/frigate/dependencies.d/compile-rocm-models rename to docker/main/rootfs/etc/s6-overlay/s6-rc.d/chroma/dependencies.d/base diff --git a/docker/main/rootfs/etc/s6-overlay/s6-rc.d/chroma/finish b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/chroma/finish new file mode 100644 index 0000000000..b6206b4ccf --- /dev/null +++ b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/chroma/finish @@ -0,0 +1,28 @@ +#!/command/with-contenv bash +# shellcheck shell=bash +# Take down the S6 supervision tree when the service exits + +set -o errexit -o nounset -o pipefail + +# Logs should be sent to stdout so that s6 can collect them + +declare exit_code_container +exit_code_container=$(cat /run/s6-linux-init-container-results/exitcode) +readonly exit_code_container +readonly exit_code_service="${1}" +readonly exit_code_signal="${2}" +readonly service="ChromaDB" + +echo "[INFO] Service ${service} exited with code ${exit_code_service} (by signal ${exit_code_signal})" + +if [[ "${exit_code_service}" -eq 256 ]]; then + if [[ "${exit_code_container}" -eq 0 ]]; then + echo $((128 + exit_code_signal)) >/run/s6-linux-init-container-results/exitcode + fi +elif [[ "${exit_code_service}" -ne 0 ]]; then + if [[ "${exit_code_container}" -eq 0 ]]; then + echo "${exit_code_service}" >/run/s6-linux-init-container-results/exitcode + fi +fi + +exec /run/s6/basedir/bin/halt diff --git a/docker/main/rootfs/etc/s6-overlay/s6-rc.d/chroma/producer-for b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/chroma/producer-for new file mode 100644 index 0000000000..c17b71e87a --- /dev/null +++ b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/chroma/producer-for @@ -0,0 +1 @@ +chroma-log diff --git a/docker/main/rootfs/etc/s6-overlay/s6-rc.d/chroma/run b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/chroma/run new file mode 100644 index 0000000000..ef477d8a28 --- /dev/null +++ b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/chroma/run @@ -0,0 +1,27 @@ +#!/command/with-contenv bash +# shellcheck shell=bash +# Start the Frigate service + +set -o errexit -o nounset -o pipefail + +# Logs should be sent to stdout so that s6 can collect them + +# Tell S6-Overlay not to restart this service +s6-svc -O . + +search_enabled=`python3 /usr/local/semantic_search/get_search_settings.py | jq -r .enabled` + +# Replace the bash process with the Frigate process, redirecting stderr to stdout +exec 2>&1 + +if [[ "$search_enabled" == 'true' ]]; then + echo "[INFO] Starting ChromaDB..." + exec /usr/local/chroma run --path /config/chroma --host 127.0.0.1 +else + while true + do + sleep 9999 + continue + done + exit 0 +fi diff --git a/docker/main/rootfs/etc/s6-overlay/s6-rc.d/chroma/timeout-kill b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/chroma/timeout-kill new file mode 100644 index 0000000000..6f4f418441 --- /dev/null +++ b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/chroma/timeout-kill @@ -0,0 +1 @@ +120000 diff --git a/docker/main/rootfs/etc/s6-overlay/s6-rc.d/chroma/type b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/chroma/type new file mode 100644 index 0000000000..5883cff0cd --- /dev/null +++ b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/chroma/type @@ -0,0 +1 @@ +longrun diff --git a/docker/main/rootfs/etc/s6-overlay/s6-rc.d/frigate/dependencies.d/chroma b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/frigate/dependencies.d/chroma new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docker/main/rootfs/etc/s6-overlay/s6-rc.d/frigate/run b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/frigate/run index 50da2aef9c..eacce294fb 100755 --- a/docker/main/rootfs/etc/s6-overlay/s6-rc.d/frigate/run +++ b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/frigate/run @@ -44,8 +44,6 @@ function migrate_db_path() { echo "[INFO] Preparing Frigate..." migrate_db_path -export LIBAVFORMAT_VERSION_MAJOR=$(ffmpeg -version | grep -Po 'libavformat\W+\K\d+') - echo "[INFO] Starting Frigate..." cd /opt/frigate || echo "[ERROR] Failed to change working directory to /opt/frigate" diff --git a/docker/main/rootfs/etc/s6-overlay/s6-rc.d/go2rtc/run b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/go2rtc/run index 851d787996..9c4922d81d 100755 --- a/docker/main/rootfs/etc/s6-overlay/s6-rc.d/go2rtc/run +++ b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/go2rtc/run @@ -43,8 +43,6 @@ function get_ip_and_port_from_supervisor() { export FRIGATE_GO2RTC_WEBRTC_CANDIDATE_INTERNAL="${ip_address}:${webrtc_port}" } -export LIBAVFORMAT_VERSION_MAJOR=$(ffmpeg -version | grep -Po 'libavformat\W+\K\d+') - if [[ -f "/dev/shm/go2rtc.yaml" ]]; then echo "[INFO] Removing stale config from last run..." rm /dev/shm/go2rtc.yaml diff --git a/docker/main/rootfs/etc/s6-overlay/s6-rc.d/log-prepare/run b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/log-prepare/run index c493e320ee..0661f01c2f 100755 --- a/docker/main/rootfs/etc/s6-overlay/s6-rc.d/log-prepare/run +++ b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/log-prepare/run @@ -4,7 +4,7 @@ set -o errexit -o nounset -o pipefail -dirs=(/dev/shm/logs/frigate /dev/shm/logs/go2rtc /dev/shm/logs/nginx /dev/shm/logs/certsync) +dirs=(/dev/shm/logs/frigate /dev/shm/logs/go2rtc /dev/shm/logs/nginx /dev/shm/logs/certsync /dev/shm/logs/chroma) mkdir -p "${dirs[@]}" chown nobody:nogroup "${dirs[@]}" diff --git a/docker/main/rootfs/etc/s6-overlay/s6-rc.d/nginx/run b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/nginx/run index a6436abd41..677126a6dd 100755 --- a/docker/main/rootfs/etc/s6-overlay/s6-rc.d/nginx/run +++ b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/nginx/run @@ -38,7 +38,7 @@ function get_cpus() { fi local cpus - if [ -n "${quota}" ] && [ -n "${period}" ]; then + if [ "${period}" != "0" ] && [ -n "${quota}" ] && [ -n "${period}" ]; then cpus=$((quota / period)) if [ "$cpus" -eq 0 ]; then cpus=1 diff --git a/docker/main/rootfs/usr/local/chroma b/docker/main/rootfs/usr/local/chroma new file mode 100755 index 0000000000..5147db3877 --- /dev/null +++ b/docker/main/rootfs/usr/local/chroma @@ -0,0 +1,14 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*-s +__import__("pysqlite3") + +import re +import sys + +sys.modules["sqlite3"] = sys.modules.pop("pysqlite3") + +from chromadb.cli.cli import app + +if __name__ == "__main__": + sys.argv[0] = re.sub(r"(-script\.pyw|\.exe)?$", "", sys.argv[0]) + sys.exit(app()) diff --git a/docker/main/rootfs/usr/local/go2rtc/create_config.py b/docker/main/rootfs/usr/local/go2rtc/create_config.py index 6855b3b893..a9abbe1d1c 100644 --- a/docker/main/rootfs/usr/local/go2rtc/create_config.py +++ b/docker/main/rootfs/usr/local/go2rtc/create_config.py @@ -2,16 +2,19 @@ import json import os +import shutil import sys from pathlib import Path import yaml sys.path.insert(0, "/opt/frigate") -from frigate.const import BIRDSEYE_PIPE # noqa: E402 -from frigate.ffmpeg_presets import ( # noqa: E402 - parse_preset_hardware_acceleration_encode, +from frigate.const import ( + BIRDSEYE_PIPE, + DEFAULT_FFMPEG_VERSION, + INCLUDED_FFMPEG_VERSIONS, ) +from frigate.ffmpeg_presets import parse_preset_hardware_acceleration_encode sys.path.remove("/opt/frigate") @@ -105,16 +108,32 @@ **FRIGATE_ENV_VARS ) +# ensure ffmpeg path is set correctly +path = config.get("ffmpeg", {}).get("path", "default") +if path == "default": + if shutil.which("ffmpeg") is None: + ffmpeg_path = f"/usr/lib/ffmpeg/{DEFAULT_FFMPEG_VERSION}/bin/ffmpeg" + else: + ffmpeg_path = "ffmpeg" +elif path in INCLUDED_FFMPEG_VERSIONS: + ffmpeg_path = f"/usr/lib/ffmpeg/{path}/bin/ffmpeg" +else: + ffmpeg_path = f"{path}/bin/ffmpeg" + +if go2rtc_config.get("ffmpeg") is None: + go2rtc_config["ffmpeg"] = {"bin": ffmpeg_path} +elif go2rtc_config["ffmpeg"].get("bin") is None: + go2rtc_config["ffmpeg"]["bin"] = ffmpeg_path + # need to replace ffmpeg command when using ffmpeg4 -if int(os.environ["LIBAVFORMAT_VERSION_MAJOR"]) < 59: - if go2rtc_config.get("ffmpeg") is None: - go2rtc_config["ffmpeg"] = { - "rtsp": "-fflags nobuffer -flags low_delay -stimeout 5000000 -user_agent go2rtc/ffmpeg -rtsp_transport tcp -i {input}" - } - elif go2rtc_config["ffmpeg"].get("rtsp") is None: +if int(os.environ.get("LIBAVFORMAT_VERSION_MAJOR", "59") or "59") < 59: + if go2rtc_config["ffmpeg"].get("rtsp") is None: go2rtc_config["ffmpeg"]["rtsp"] = ( "-fflags nobuffer -flags low_delay -stimeout 5000000 -user_agent go2rtc/ffmpeg -rtsp_transport tcp -i {input}" ) +else: + if go2rtc_config.get("ffmpeg") is None: + go2rtc_config["ffmpeg"] = {"path": ""} for name in go2rtc_config.get("streams", {}): stream = go2rtc_config["streams"][name] @@ -145,7 +164,7 @@ birdseye: dict[str, any] = config.get("birdseye") input = f"-f rawvideo -pix_fmt yuv420p -video_size {birdseye.get('width', 1280)}x{birdseye.get('height', 720)} -r 10 -i {BIRDSEYE_PIPE}" - ffmpeg_cmd = f"exec:{parse_preset_hardware_acceleration_encode(config.get('ffmpeg', {}).get('hwaccel_args'), input, '-rtsp_transport tcp -f rtsp {output}')}" + ffmpeg_cmd = f"exec:{parse_preset_hardware_acceleration_encode(ffmpeg_path, config.get('ffmpeg', {}).get('hwaccel_args'), input, '-rtsp_transport tcp -f rtsp {output}')}" if go2rtc_config.get("streams"): go2rtc_config["streams"]["birdseye"] = ffmpeg_cmd diff --git a/docker/main/rootfs/usr/local/semantic_search/get_search_settings.py b/docker/main/rootfs/usr/local/semantic_search/get_search_settings.py new file mode 100644 index 0000000000..e4ec4ea1c7 --- /dev/null +++ b/docker/main/rootfs/usr/local/semantic_search/get_search_settings.py @@ -0,0 +1,28 @@ +"""Prints the semantic_search config as json to stdout.""" + +import json +import os + +import yaml + +config_file = os.environ.get("CONFIG_FILE", "/config/config.yml") + +# Check if we can use .yaml instead of .yml +config_file_yaml = config_file.replace(".yml", ".yaml") +if os.path.isfile(config_file_yaml): + config_file = config_file_yaml + +try: + with open(config_file) as f: + raw_config = f.read() + + if config_file.endswith((".yaml", ".yml")): + config: dict[str, any] = yaml.safe_load(raw_config) + elif config_file.endswith(".json"): + config: dict[str, any] = json.loads(raw_config) +except FileNotFoundError: + config: dict[str, any] = {} + +search_config: dict[str, any] = config.get("semantic_search", {"enabled": False}) + +print(json.dumps(search_config)) diff --git a/docker/rockchip/Dockerfile b/docker/rockchip/Dockerfile index 84a3cc4427..e1b43c2553 100644 --- a/docker/rockchip/Dockerfile +++ b/docker/rockchip/Dockerfile @@ -22,5 +22,6 @@ ADD https://github.com/MarcA711/rknn-toolkit2/releases/download/v2.0.0/librknnrt RUN rm -rf /usr/lib/btbn-ffmpeg/bin/ffmpeg RUN rm -rf /usr/lib/btbn-ffmpeg/bin/ffprobe -ADD --chmod=111 https://github.com/MarcA711/Rockchip-FFmpeg-Builds/releases/download/6.1-5/ffmpeg /usr/lib/btbn-ffmpeg/bin/ -ADD --chmod=111 https://github.com/MarcA711/Rockchip-FFmpeg-Builds/releases/download/6.1-5/ffprobe /usr/lib/btbn-ffmpeg/bin/ +ADD --chmod=111 https://github.com/MarcA711/Rockchip-FFmpeg-Builds/releases/download/6.1-5/ffmpeg /usr/lib/ffmpeg/6.0/bin/ +ADD --chmod=111 https://github.com/MarcA711/Rockchip-FFmpeg-Builds/releases/download/6.1-5/ffprobe /usr/lib/ffmpeg/6.0/bin/ +ENV PATH="/usr/lib/ffmpeg/6.0/bin/:${PATH}" diff --git a/docker/rockchip/rk.mk b/docker/rockchip/rk.mk index 0d9bde16ad..c8278f68b9 100644 --- a/docker/rockchip/rk.mk +++ b/docker/rockchip/rk.mk @@ -1,10 +1,15 @@ BOARDS += rk local-rk: version - docker buildx bake --load --file=docker/rockchip/rk.hcl --set rk.tags=frigate:latest-rk rk + docker buildx bake --file=docker/rockchip/rk.hcl rk \ + --set rk.tags=frigate:latest-rk \ + --load build-rk: version - docker buildx bake --file=docker/rockchip/rk.hcl --set rk.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-rk rk + docker buildx bake --file=docker/rockchip/rk.hcl rk \ + --set rk.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-rk push-rk: build-rk - docker buildx bake --push --file=docker/rockchip/rk.hcl --set rk.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-rk rk \ No newline at end of file + docker buildx bake --file=docker/rockchip/rk.hcl rk \ + --set rk.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-rk \ + --push \ No newline at end of file diff --git a/docker/rocm/Dockerfile b/docker/rocm/Dockerfile index d13bcaead3..a1d6ce832d 100644 --- a/docker/rocm/Dockerfile +++ b/docker/rocm/Dockerfile @@ -23,11 +23,11 @@ COPY docker/rocm/rocm-pin-600 /etc/apt/preferences.d/ RUN apt-get update -RUN apt-get -y install --no-install-recommends migraphx +RUN apt-get -y install --no-install-recommends migraphx hipfft roctracer RUN apt-get -y install --no-install-recommends migraphx-dev RUN mkdir -p /opt/rocm-dist/opt/rocm-$ROCM/lib -RUN cd /opt/rocm-$ROCM/lib && cp -dpr libMIOpen*.so* libamd*.so* libhip*.so* libhsa*.so* libmigraphx*.so* librocm*.so* librocblas*.so* /opt/rocm-dist/opt/rocm-$ROCM/lib/ +RUN cd /opt/rocm-$ROCM/lib && cp -dpr libMIOpen*.so* libamd*.so* libhip*.so* libhsa*.so* libmigraphx*.so* librocm*.so* librocblas*.so* libroctracer*.so* librocfft*.so* /opt/rocm-dist/opt/rocm-$ROCM/lib/ RUN cd /opt/rocm-dist/opt/ && ln -s rocm-$ROCM rocm RUN mkdir -p /opt/rocm-dist/etc/ld.so.conf.d/ @@ -69,7 +69,11 @@ RUN apt-get -y install libnuma1 WORKDIR /opt/frigate/ COPY --from=rootfs / / -COPY docker/rocm/rootfs/ / + +COPY docker/rocm/requirements-wheels-rocm.txt /requirements.txt +RUN python3 -m pip install --upgrade pip \ + && pip3 uninstall -y onnxruntime-openvino \ + && pip3 install -r /requirements.txt ####################################################################### FROM scratch AS rocm-dist @@ -101,6 +105,3 @@ ENV HSA_OVERRIDE_GFX_VERSION=$HSA_OVERRIDE_GFX_VERSION ####################################################################### FROM rocm-prelim-hsa-override$HSA_OVERRIDE as rocm-deps -# Request yolov8 download at startup -ENV DOWNLOAD_YOLOV8=1 - diff --git a/docker/rocm/requirements-wheels-rocm.txt b/docker/rocm/requirements-wheels-rocm.txt new file mode 100644 index 0000000000..89d0e6096d --- /dev/null +++ b/docker/rocm/requirements-wheels-rocm.txt @@ -0,0 +1 @@ +onnxruntime-rocm @ https://github.com/NickM-27/frigate-onnxruntime-rocm/releases/download/v1.0.0/onnxruntime_rocm-1.17.3-cp39-cp39-linux_x86_64.whl \ No newline at end of file diff --git a/docker/rocm/rocm.mk b/docker/rocm/rocm.mk index 2d3d034ee5..c92a458f50 100644 --- a/docker/rocm/rocm.mk +++ b/docker/rocm/rocm.mk @@ -4,14 +4,50 @@ BOARDS += rocm ROCM_CHIPSETS:=gfx900:9.0.0 gfx1030:10.3.0 gfx1100:11.0.0 local-rocm: version - $(foreach chipset,$(ROCM_CHIPSETS),AMDGPU=$(word 1,$(subst :, ,$(chipset))) HSA_OVERRIDE_GFX_VERSION=$(word 2,$(subst :, ,$(chipset))) HSA_OVERRIDE=1 docker buildx bake --load --file=docker/rocm/rocm.hcl --set rocm.tags=frigate:latest-rocm-$(word 1,$(subst :, ,$(chipset))) rocm;) - unset HSA_OVERRIDE_GFX_VERSION && HSA_OVERRIDE=0 AMDGPU=gfx docker buildx bake --load --file=docker/rocm/rocm.hcl --set rocm.tags=frigate:latest-rocm rocm + $(foreach chipset,$(ROCM_CHIPSETS), \ + AMDGPU=$(word 1,$(subst :, ,$(chipset))) \ + HSA_OVERRIDE_GFX_VERSION=$(word 2,$(subst :, ,$(chipset))) \ + HSA_OVERRIDE=1 \ + docker buildx bake --file=docker/rocm/rocm.hcl rocm \ + --set rocm.tags=frigate:latest-rocm-$(word 1,$(subst :, ,$(chipset))) \ + --load \ + &&) true + + unset HSA_OVERRIDE_GFX_VERSION && \ + HSA_OVERRIDE=0 \ + AMDGPU=gfx \ + docker buildx bake --file=docker/rocm/rocm.hcl rocm \ + --set rocm.tags=frigate:latest-rocm \ + --load build-rocm: version - $(foreach chipset,$(ROCM_CHIPSETS),AMDGPU=$(word 1,$(subst :, ,$(chipset))) HSA_OVERRIDE_GFX_VERSION=$(word 2,$(subst :, ,$(chipset))) HSA_OVERRIDE=1 docker buildx bake --file=docker/rocm/rocm.hcl --set rocm.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-rocm-$(chipset) rocm;) - unset HSA_OVERRIDE_GFX_VERSION && HSA_OVERRIDE=0 AMDGPU=gfx docker buildx bake --file=docker/rocm/rocm.hcl --set rocm.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-rocm rocm + $(foreach chipset,$(ROCM_CHIPSETS), \ + AMDGPU=$(word 1,$(subst :, ,$(chipset))) \ + HSA_OVERRIDE_GFX_VERSION=$(word 2,$(subst :, ,$(chipset))) \ + HSA_OVERRIDE=1 \ + docker buildx bake --file=docker/rocm/rocm.hcl rocm \ + --set rocm.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-rocm-$(chipset) \ + &&) true + + unset HSA_OVERRIDE_GFX_VERSION && \ + HSA_OVERRIDE=0 \ + AMDGPU=gfx \ + docker buildx bake --file=docker/rocm/rocm.hcl rocm \ + --set rocm.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-rocm push-rocm: build-rocm - $(foreach chipset,$(ROCM_CHIPSETS),AMDGPU=$(word 1,$(subst :, ,$(chipset))) HSA_OVERRIDE_GFX_VERSION=$(word 2,$(subst :, ,$(chipset))) HSA_OVERRIDE=1 docker buildx bake --push --file=docker/rocm/rocm.hcl --set rocm.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-rocm-$(chipset) rocm;) - unset HSA_OVERRIDE_GFX_VERSION && HSA_OVERRIDE=0 AMDGPU=gfx docker buildx bake --push --file=docker/rocm/rocm.hcl --set rocm.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-rocm rocm + $(foreach chipset,$(ROCM_CHIPSETS), \ + AMDGPU=$(word 1,$(subst :, ,$(chipset))) \ + HSA_OVERRIDE_GFX_VERSION=$(word 2,$(subst :, ,$(chipset))) \ + HSA_OVERRIDE=1 \ + docker buildx bake --file=docker/rocm/rocm.hcl rocm \ + --set rocm.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-rocm-$(chipset) \ + --push \ + &&) true + unset HSA_OVERRIDE_GFX_VERSION && \ + HSA_OVERRIDE=0 \ + AMDGPU=gfx \ + docker buildx bake --file=docker/rocm/rocm.hcl rocm \ + --set rocm.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-rocm \ + --push diff --git a/docker/rocm/rootfs/etc/s6-overlay/s6-rc.d/compile-rocm-models/run b/docker/rocm/rootfs/etc/s6-overlay/s6-rc.d/compile-rocm-models/run deleted file mode 100755 index f7b084ad78..0000000000 --- a/docker/rocm/rootfs/etc/s6-overlay/s6-rc.d/compile-rocm-models/run +++ /dev/null @@ -1,20 +0,0 @@ -#!/command/with-contenv bash -# shellcheck shell=bash -# Compile YoloV8 ONNX files into ROCm MIGraphX files - -OVERRIDE=$(cd /opt/frigate && python3 -c 'import frigate.detectors.plugins.rocm as rocm; print(rocm.auto_override_gfx_version())') - -if ! test -z "$OVERRIDE"; then - echo "Using HSA_OVERRIDE_GFX_VERSION=${OVERRIDE}" - export HSA_OVERRIDE_GFX_VERSION=$OVERRIDE -fi - -for onnx in /config/model_cache/yolov8/*.onnx -do - mxr="${onnx%.onnx}.mxr" - if ! test -f $mxr; then - echo "processing $onnx into $mxr" - /opt/rocm/bin/migraphx-driver compile $onnx --optimize --gpu --enable-offload-copy --binary -o $mxr - fi -done - diff --git a/docker/rocm/rootfs/etc/s6-overlay/s6-rc.d/compile-rocm-models/type b/docker/rocm/rootfs/etc/s6-overlay/s6-rc.d/compile-rocm-models/type deleted file mode 100644 index bdd22a1850..0000000000 --- a/docker/rocm/rootfs/etc/s6-overlay/s6-rc.d/compile-rocm-models/type +++ /dev/null @@ -1 +0,0 @@ -oneshot diff --git a/docker/rocm/rootfs/etc/s6-overlay/s6-rc.d/compile-rocm-models/up b/docker/rocm/rootfs/etc/s6-overlay/s6-rc.d/compile-rocm-models/up deleted file mode 100644 index 8fdcef491a..0000000000 --- a/docker/rocm/rootfs/etc/s6-overlay/s6-rc.d/compile-rocm-models/up +++ /dev/null @@ -1 +0,0 @@ -/etc/s6-overlay/s6-rc.d/compile-rocm-models/run diff --git a/docker/rpi/Dockerfile b/docker/rpi/Dockerfile index 581ca7ff89..9860e65ecb 100644 --- a/docker/rpi/Dockerfile +++ b/docker/rpi/Dockerfile @@ -12,5 +12,7 @@ RUN rm -rf /usr/lib/btbn-ffmpeg/ RUN --mount=type=bind,source=docker/rpi/install_deps.sh,target=/deps/install_deps.sh \ /deps/install_deps.sh +ENV LIBAVFORMAT_VERSION_MAJOR=58 + WORKDIR /opt/frigate/ COPY --from=rootfs / / diff --git a/docker/rpi/rpi.mk b/docker/rpi/rpi.mk index c1282b0119..290b30c31f 100644 --- a/docker/rpi/rpi.mk +++ b/docker/rpi/rpi.mk @@ -1,10 +1,15 @@ BOARDS += rpi local-rpi: version - docker buildx bake --load --file=docker/rpi/rpi.hcl --set rpi.tags=frigate:latest-rpi rpi + docker buildx bake --file=docker/rpi/rpi.hcl rpi \ + --set rpi.tags=frigate:latest-rpi \ + --load build-rpi: version - docker buildx bake --file=docker/rpi/rpi.hcl --set rpi.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-rpi rpi + docker buildx bake --file=docker/rpi/rpi.hcl rpi \ + --set rpi.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-rpi push-rpi: build-rpi - docker buildx bake --push --file=docker/rpi/rpi.hcl --set rpi.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-rpi rpi \ No newline at end of file + docker buildx bake --file=docker/rpi/rpi.hcl rpi \ + --set rpi.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-rpi \ + --push diff --git a/docker/tensorrt/Dockerfile.amd64 b/docker/tensorrt/Dockerfile.amd64 index 075726eda8..61d3264c91 100644 --- a/docker/tensorrt/Dockerfile.amd64 +++ b/docker/tensorrt/Dockerfile.amd64 @@ -3,6 +3,8 @@ # https://askubuntu.com/questions/972516/debian-frontend-environment-variable ARG DEBIAN_FRONTEND=noninteractive +ARG TRT_BASE=nvcr.io/nvidia/tensorrt:23.03-py3 + # Make this a separate target so it can be built/cached optionally FROM wheels as trt-wheels ARG DEBIAN_FRONTEND @@ -12,12 +14,28 @@ ARG TARGETARCH COPY docker/tensorrt/requirements-amd64.txt /requirements-tensorrt.txt RUN mkdir -p /trt-wheels && pip3 wheel --wheel-dir=/trt-wheels -r /requirements-tensorrt.txt +# Build CuDNN +FROM ${TRT_BASE} AS cudnn-deps + +ARG COMPUTE_LEVEL + +RUN apt-get update \ + && apt-get install -y git build-essential + +RUN wget https://developer.download.nvidia.com/compute/cuda/repos/debian11/x86_64/cuda-keyring_1.1-1_all.deb \ +&& dpkg -i cuda-keyring_1.1-1_all.deb \ +&& apt-get update \ +&& apt-get -y install cuda-toolkit \ +&& rm -rf /var/lib/apt/lists/* + FROM tensorrt-base AS frigate-tensorrt ENV TRT_VER=8.5.3 RUN --mount=type=bind,from=trt-wheels,source=/trt-wheels,target=/deps/trt-wheels \ pip3 install -U /deps/trt-wheels/*.whl && \ ldconfig +COPY --from=cudnn-deps /usr/local/cuda-12.6 /usr/local/cuda +ENV LD_LIBRARY_PATH=/usr/local/lib/python3.9/dist-packages/tensorrt:/usr/local/cuda/lib64:/usr/local/lib/python3.9/dist-packages/nvidia/cufft/lib WORKDIR /opt/frigate/ COPY --from=rootfs / / @@ -26,6 +44,7 @@ FROM devcontainer AS devcontainer-trt COPY --from=trt-deps /usr/local/lib/libyolo_layer.so /usr/local/lib/libyolo_layer.so COPY --from=trt-deps /usr/local/src/tensorrt_demos /usr/local/src/tensorrt_demos +COPY --from=cudnn-deps /usr/local/cuda-12.6 /usr/local/cuda COPY docker/tensorrt/detector/rootfs/ / COPY --from=trt-deps /usr/local/lib/libyolo_layer.so /usr/local/lib/libyolo_layer.so RUN --mount=type=bind,from=trt-wheels,source=/trt-wheels,target=/deps/trt-wheels \ diff --git a/docker/tensorrt/requirements-amd64.txt b/docker/tensorrt/requirements-amd64.txt index 214202e432..b5ad4fcbdb 100644 --- a/docker/tensorrt/requirements-amd64.txt +++ b/docker/tensorrt/requirements-amd64.txt @@ -8,5 +8,7 @@ nvidia-cuda-runtime-cu12 == 12.1.*; platform_machine == 'x86_64' nvidia-cuda-runtime-cu11 == 11.8.*; platform_machine == 'x86_64' nvidia-cublas-cu11 == 11.11.3.6; platform_machine == 'x86_64' nvidia-cudnn-cu11 == 8.6.0.*; platform_machine == 'x86_64' +nvidia-cufft-cu11==10.*; platform_machine == 'x86_64' onnx==1.14.0; platform_machine == 'x86_64' -protobuf==3.20.3; platform_machine == 'x86_64' \ No newline at end of file +onnxruntime-gpu==1.17.*; platform_machine == 'x86_64' +protobuf==3.20.3; platform_machine == 'x86_64' diff --git a/docker/tensorrt/trt.mk b/docker/tensorrt/trt.mk index ad2425c812..455e1ee110 100644 --- a/docker/tensorrt/trt.mk +++ b/docker/tensorrt/trt.mk @@ -7,20 +7,35 @@ JETPACK4_ARGS := ARCH=arm64 BASE_IMAGE=$(JETPACK4_BASE) SLIM_BASE=$(JETPACK4_BAS JETPACK5_ARGS := ARCH=arm64 BASE_IMAGE=$(JETPACK5_BASE) SLIM_BASE=$(JETPACK5_BASE) TRT_BASE=$(JETPACK5_BASE) local-trt: version - $(X86_DGPU_ARGS) docker buildx bake --load --file=docker/tensorrt/trt.hcl --set tensorrt.tags=frigate:latest-tensorrt tensorrt + $(X86_DGPU_ARGS) docker buildx bake --file=docker/tensorrt/trt.hcl tensorrt \ + --set tensorrt.tags=frigate:latest-tensorrt \ + --load local-trt-jp4: version - $(JETPACK4_ARGS) docker buildx bake --load --file=docker/tensorrt/trt.hcl --set tensorrt.tags=frigate:latest-tensorrt-jp4 tensorrt + $(JETPACK4_ARGS) docker buildx bake --file=docker/tensorrt/trt.hcl tensorrt \ + --set tensorrt.tags=frigate:latest-tensorrt-jp4 \ + --load local-trt-jp5: version - $(JETPACK5_ARGS) docker buildx bake --load --file=docker/tensorrt/trt.hcl --set tensorrt.tags=frigate:latest-tensorrt-jp5 tensorrt + $(JETPACK5_ARGS) docker buildx bake --file=docker/tensorrt/trt.hcl tensorrt \ + --set tensorrt.tags=frigate:latest-tensorrt-jp5 \ + --load build-trt: - $(X86_DGPU_ARGS) docker buildx bake --file=docker/tensorrt/trt.hcl --set tensorrt.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-tensorrt tensorrt - $(JETPACK4_ARGS) docker buildx bake --file=docker/tensorrt/trt.hcl --set tensorrt.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-tensorrt-jp4 tensorrt - $(JETPACK5_ARGS) docker buildx bake --file=docker/tensorrt/trt.hcl --set tensorrt.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-tensorrt-jp5 tensorrt + $(X86_DGPU_ARGS) docker buildx bake --file=docker/tensorrt/trt.hcl tensorrt \ + --set tensorrt.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-tensorrt + $(JETPACK4_ARGS) docker buildx bake --file=docker/tensorrt/trt.hcl tensorrt \ + --set tensorrt.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-tensorrt-jp4 + $(JETPACK5_ARGS) docker buildx bake --file=docker/tensorrt/trt.hcl tensorrt \ + --set tensorrt.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-tensorrt-jp5 push-trt: build-trt - $(X86_DGPU_ARGS) docker buildx bake --push --file=docker/tensorrt/trt.hcl --set tensorrt.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-tensorrt tensorrt - $(JETPACK4_ARGS) docker buildx bake --push --file=docker/tensorrt/trt.hcl --set tensorrt.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-tensorrt-jp4 tensorrt - $(JETPACK5_ARGS) docker buildx bake --push --file=docker/tensorrt/trt.hcl --set tensorrt.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-tensorrt-jp5 tensorrt + $(X86_DGPU_ARGS) docker buildx bake --file=docker/tensorrt/trt.hcl tensorrt \ + --set tensorrt.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-tensorrt \ + --push + $(JETPACK4_ARGS) docker buildx bake --file=docker/tensorrt/trt.hcl tensorrt \ + --set tensorrt.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-tensorrt-jp4 \ + --push + $(JETPACK5_ARGS) docker buildx bake --file=docker/tensorrt/trt.hcl tensorrt \ + --set tensorrt.tags=$(IMAGE_REPO):${GITHUB_REF_NAME}-$(COMMIT_HASH)-tensorrt-jp5 \ + --push diff --git a/docs/docs/configuration/advanced.md b/docs/docs/configuration/advanced.md index b237d4b662..1c99ec1c50 100644 --- a/docs/docs/configuration/advanced.md +++ b/docs/docs/configuration/advanced.md @@ -41,7 +41,7 @@ environment_vars: ### `database` -Event and recording information is managed in a sqlite database at `/config/frigate.db`. If that database is deleted, recordings will be orphaned and will need to be cleaned up manually. They also won't show up in the Media Browser within Home Assistant. +Tracked object and recording information is managed in a sqlite database at `/config/frigate.db`. If that database is deleted, recordings will be orphaned and will need to be cleaned up manually. They also won't show up in the Media Browser within Home Assistant. If you are storing your database on a network share (SMB, NFS, etc), you may get a `database is locked` error message on startup. You can customize the location of the database in the config if necessary. @@ -162,15 +162,15 @@ listen [::]:5000 ipv6only=off; ### Custom ffmpeg build -Included with Frigate is a build of ffmpeg that works for the vast majority of users. However, there exists some hardware setups which have incompatibilities with the included build. In this case, a docker volume mapping can be used to overwrite the included ffmpeg build with an ffmpeg build that works for your specific hardware setup. +Included with Frigate is a build of ffmpeg that works for the vast majority of users. However, there exists some hardware setups which have incompatibilities with the included build. In this case, statically built ffmpeg binary can be downloaded to /config and used. To do this: -1. Download your ffmpeg build and uncompress to a folder on the host (let's use `/home/appdata/frigate/custom-ffmpeg` for this example). +1. Download your ffmpeg build and uncompress to the Frigate config folder. 2. Update your docker-compose or docker CLI to include `'/home/appdata/frigate/custom-ffmpeg':'/usr/lib/btbn-ffmpeg':'ro'` in the volume mappings. 3. Restart Frigate and the custom version will be used if the mapping was done correctly. -NOTE: The folder that is mapped from the host needs to be the folder that contains `/bin`. So if the full structure is `/home/appdata/frigate/custom-ffmpeg/bin/ffmpeg` then `/home/appdata/frigate/custom-ffmpeg` needs to be mapped to `/usr/lib/btbn-ffmpeg`. +NOTE: The folder that is set for the config needs to be the folder that contains `/bin`. So if the full structure is `/home/appdata/frigate/custom-ffmpeg/bin/ffmpeg` then the `ffmpeg -> path` field should be `/config/custom-ffmpeg/bin`. ### Custom go2rtc version diff --git a/docs/docs/configuration/camera_specific.md b/docs/docs/configuration/camera_specific.md index a3619c5fbe..689465d901 100644 --- a/docs/docs/configuration/camera_specific.md +++ b/docs/docs/configuration/camera_specific.md @@ -187,4 +187,4 @@ ffmpeg: ### TP-Link VIGI Cameras -TP-Link VIGI cameras need some adjustments to the main stream settings on the camera itself to avoid issues. The stream needs to be configured as `H264` with `Smart Coding` set to `off`. Without these settings you may have problems when trying to watch recorded events. For example Firefox will stop playback after a few seconds and show the following error message: `The media playback was aborted due to a corruption problem or because the media used features your browser did not support.`. +TP-Link VIGI cameras need some adjustments to the main stream settings on the camera itself to avoid issues. The stream needs to be configured as `H264` with `Smart Coding` set to `off`. Without these settings you may have problems when trying to watch recorded footage. For example Firefox will stop playback after a few seconds and show the following error message: `The media playback was aborted due to a corruption problem or because the media used features your browser did not support.`. diff --git a/docs/docs/configuration/cameras.md b/docs/docs/configuration/cameras.md index 52361e9bf4..c1c7d7cba8 100644 --- a/docs/docs/configuration/cameras.md +++ b/docs/docs/configuration/cameras.md @@ -7,7 +7,7 @@ title: Camera Configuration Several inputs can be configured for each camera and the role of each input can be mixed and matched based on your needs. This allows you to use a lower resolution stream for object detection, but create recordings from a higher resolution stream, or vice versa. -A camera is enabled by default but can be temporarily disabled by using `enabled: False`. Existing events and recordings can still be accessed. Live streams, recording and detecting are not working. Camera specific configurations will be used. +A camera is enabled by default but can be temporarily disabled by using `enabled: False`. Existing tracked objects and recordings can still be accessed. Live streams, recording and detecting are not working. Camera specific configurations will be used. Each role can only be assigned to one input per camera. The options for roles are as follows: @@ -46,6 +46,14 @@ cameras: side: ... ``` +:::note + +If you only define one stream in your `inputs` and do not assign a `detect` role to it, Frigate will automatically assign it the `detect` role. Frigate will always decode a stream to support motion detection, Birdseye, the API image endpoints, and other features, even if you have disabled object detection with `enabled: False` in your config's `detect` section. + +If you plan to use Frigate for recording only, it is still recommended to define a `detect` role for a low resolution stream to minimize resource usage from the required stream decoding. + +::: + For camera model specific settings check the [camera specific](camera_specific.md) infos. ## Setting up camera PTZ controls diff --git a/docs/docs/configuration/genai.md b/docs/docs/configuration/genai.md new file mode 100644 index 0000000000..26954effec --- /dev/null +++ b/docs/docs/configuration/genai.md @@ -0,0 +1,149 @@ +--- +id: genai +title: Generative AI +--- + +Generative AI can be used to automatically generate descriptions based on the thumbnails of your tracked objects. This helps with [Semantic Search](/configuration/semantic_search) in Frigate by providing detailed text descriptions as a basis of the search query. + +Semantic Search must be enabled to use Generative AI. Descriptions are accessed via the _Explore_ view in the Frigate UI by clicking on a tracked object's thumbnail. + +## Configuration + +Generative AI can be enabled for all cameras or only for specific cameras. There are currently 3 providers available to integrate with Frigate. + +If the provider you choose requires an API key, you may either directly paste it in your configuration, or store it in an environment variable prefixed with `FRIGATE_`. + +```yaml +genai: + enabled: True + provider: gemini + api_key: "{FRIGATE_GEMINI_API_KEY}" + model: gemini-1.5-flash + +cameras: + front_camera: ... + indoor_camera: + genai: # <- disable GenAI for your indoor camera + enabled: False +``` + +## Ollama + +[Ollama](https://ollama.com/) allows you to self-host large language models and keep everything running locally. It provides a nice API over [llama.cpp](https://github.com/ggerganov/llama.cpp). It is highly recommended to host this server on a machine with an Nvidia graphics card, or on a Apple silicon Mac for best performance. Most of the 7b parameter 4-bit vision models will fit inside 8GB of VRAM. There is also a [docker container](https://hub.docker.com/r/ollama/ollama) available. + +### Supported Models + +You must use a vision capable model with Frigate. Current model variants can be found [in their model library](https://ollama.com/library). At the time of writing, this includes `llava`, `llava-llama3`, `llava-phi3`, and `moondream`. + +:::note + +You should have at least 8 GB of RAM available (or VRAM if running on GPU) to run the 7B models, 16 GB to run the 13B models, and 32 GB to run the 33B models. + +::: + +### Configuration + +```yaml +genai: + enabled: True + provider: ollama + base_url: http://localhost:11434 + model: llava +``` + +## Google Gemini + +Google Gemini has a free tier allowing [15 queries per minute](https://ai.google.dev/pricing) to the API, which is more than sufficient for standard Frigate usage. + +### Supported Models + +You must use a vision capable model with Frigate. Current model variants can be found [in their documentation](https://ai.google.dev/gemini-api/docs/models/gemini). At the time of writing, this includes `gemini-1.5-pro` and `gemini-1.5-flash`. + +### Get API Key + +To start using Gemini, you must first get an API key from [Google AI Studio](https://aistudio.google.com). + +1. Accept the Terms of Service +2. Click "Get API Key" from the right hand navigation +3. Click "Create API key in new project" +4. Copy the API key for use in your config + +### Configuration + +```yaml +genai: + enabled: True + provider: gemini + api_key: "{FRIGATE_GEMINI_API_KEY}" + model: gemini-1.5-flash +``` + +## OpenAI + +OpenAI does not have a free tier for their API. With the release of gpt-4o, pricing has been reduced and each generation should cost fractions of a cent if you choose to go this route. + +### Supported Models + +You must use a vision capable model with Frigate. Current model variants can be found [in their documentation](https://platform.openai.com/docs/models). At the time of writing, this includes `gpt-4o` and `gpt-4-turbo`. + +### Get API Key + +To start using OpenAI, you must first [create an API key](https://platform.openai.com/api-keys) and [configure billing](https://platform.openai.com/settings/organization/billing/overview). + +### Configuration + +```yaml +genai: + enabled: True + provider: openai + api_key: "{FRIGATE_OPENAI_API_KEY}" + model: gpt-4o +``` + +## Custom Prompts + +Frigate sends multiple frames from the tracked object along with a prompt to your Generative AI provider asking it to generate a description. The default prompt is as follows: + +``` +Describe the {label} in the sequence of images with as much detail as possible. Do not describe the background. +``` + +:::tip + +Prompts can use variable replacements like `{label}`, `{sub_label}`, and `{camera}` to substitute information from the tracked object as part of the prompt. + +::: + +You are also able to define custom prompts in your configuration. + +```yaml +genai: + enabled: True + provider: ollama + base_url: http://localhost:11434 + model: llava + prompt: "Describe the {label} in these images from the {camera} security camera." + object_prompts: + person: "Describe the main person in these images (gender, age, clothing, activity, etc). Do not include where the activity is occurring (sidewalk, concrete, driveway, etc)." + car: "Label the primary vehicle in these images with just the name of the company if it is a delivery vehicle, or the color make and model." +``` + +Prompts can also be overriden at the camera level to provide a more detailed prompt to the model about your specific camera, if you desire. + +```yaml +cameras: + front_door: + genai: + prompt: "Describe the {label} in these images from the {camera} security camera at the front door of a house, aimed outward toward the street." + object_prompts: + person: "Describe the main person in these images (gender, age, clothing, activity, etc). Do not include where the activity is occurring (sidewalk, concrete, driveway, etc). If delivering a package, include the company the package is from." + cat: "Describe the cat in these images (color, size, tail). Indicate whether or not the cat is by the flower pots. If the cat is chasing a mouse, make up a name for the mouse." +``` + +### Experiment with prompts + +Many providers also have a public facing chat interface for their models. Download a couple of different thumbnails or snapshots from Frigate and try new things in the playground to get descriptions to your liking before updating the prompt in Frigate. + +- OpenAI - [ChatGPT](https://chatgpt.com) +- Gemini - [Google AI Studio](https://aistudio.google.com) +- Ollama - [Open WebUI](https://docs.openwebui.com/) diff --git a/docs/docs/configuration/hardware_acceleration.md b/docs/docs/configuration/hardware_acceleration.md index 0b62a0f088..867d555d83 100644 --- a/docs/docs/configuration/hardware_acceleration.md +++ b/docs/docs/configuration/hardware_acceleration.md @@ -65,24 +65,33 @@ Or map in all the `/dev/video*` devices. ## Intel-based CPUs -### Via VAAPI - -VAAPI supports automatic profile selection so it will work automatically with both H.264 and H.265 streams. VAAPI is recommended for all generations of Intel-based CPUs. +**Recommended hwaccel Preset** -```yaml -ffmpeg: - hwaccel_args: preset-vaapi -``` +| CPU Generation | Intel Driver | Recommended Preset | Notes | +| -------------- | ------------ | ------------------ | ----------------------------------- | +| gen1 - gen7 | i965 | preset-vaapi | qsv is not supported | +| gen8 - gen12 | iHD | preset-vaapi | preset-intel-qsv-* can also be used | +| gen13+ | iHD / Xe | preset-intel-qsv-* | | +| Intel Arc GPU | iHD / Xe | preset-intel-qsv-* | | :::note -With some of the processors, like the J4125, the default driver `iHD` doesn't seem to work correctly for hardware acceleration. You may need to change the driver to `i965` by adding the following environment variable `LIBVA_DRIVER_NAME=i965` to your docker-compose file or [in the `frigate.yaml` for HA OS users](advanced.md#environment_vars). +The default driver is `iHD`. You may need to change the driver to `i965` by adding the following environment variable `LIBVA_DRIVER_NAME=i965` to your docker-compose file or [in the `frigate.yaml` for HA OS users](advanced.md#environment_vars). + +See [The Intel Docs](https://www.intel.com/content/www/us/en/support/articles/000005505/processors.html to figure out what generation your CPU is.) ::: -### Via Quicksync (>=10th Generation only) +### Via VAAPI + +VAAPI supports automatic profile selection so it will work automatically with both H.264 and H.265 streams. + +```yaml +ffmpeg: + hwaccel_args: preset-vaapi +``` -If VAAPI does not work for you, you can try QSV if your processor supports it. QSV must be set specifically based on the video encoding of the stream. +### Via Quicksync #### H.264 streams diff --git a/docs/docs/configuration/index.md b/docs/docs/configuration/index.md index d1e382e40d..a0b58558d2 100644 --- a/docs/docs/configuration/index.md +++ b/docs/docs/configuration/index.md @@ -56,6 +56,11 @@ go2rtc: password: "{FRIGATE_GO2RTC_RTSP_PASSWORD}" ``` +```yaml +genai: + api_key: "{FRIGATE_GENAI_API_KEY}" +``` + ## Common configuration examples Here are some common starter configuration examples. Refer to the [reference config](./reference.md) for detailed information about all the config values. @@ -67,7 +72,7 @@ Here are some common starter configuration examples. Refer to the [reference con - Hardware acceleration for decoding video - USB Coral detector - Save all video with any detectable motion for 7 days regardless of whether any objects were detected or not -- Continue to keep all video if it was during any event for 30 days +- Continue to keep all video if it qualified as an alert or detection for 30 days - Save snapshots for 30 days - Motion mask for the camera timestamp @@ -90,10 +95,12 @@ record: retain: days: 7 mode: motion - events: + alerts: retain: - default: 30 - mode: motion + days: 30 + detections: + retain: + days: 30 snapshots: enabled: True @@ -123,7 +130,7 @@ cameras: - VAAPI hardware acceleration for decoding video - USB Coral detector - Save all video with any detectable motion for 7 days regardless of whether any objects were detected or not -- Continue to keep all video if it was during any event for 30 days +- Continue to keep all video if it qualified as an alert or detection for 30 days - Save snapshots for 30 days - Motion mask for the camera timestamp @@ -144,10 +151,12 @@ record: retain: days: 7 mode: motion - events: + alerts: + retain: + days: 30 + detections: retain: - default: 30 - mode: motion + days: 30 snapshots: enabled: True @@ -177,7 +186,7 @@ cameras: - VAAPI hardware acceleration for decoding video - OpenVino detector - Save all video with any detectable motion for 7 days regardless of whether any objects were detected or not -- Continue to keep all video if it was during any event for 30 days +- Continue to keep all video if it qualified as an alert or detection for 30 days - Save snapshots for 30 days - Motion mask for the camera timestamp @@ -209,10 +218,12 @@ record: retain: days: 7 mode: motion - events: + alerts: + retain: + days: 30 + detections: retain: - default: 30 - mode: motion + days: 30 snapshots: enabled: True diff --git a/docs/docs/configuration/motion_detection.md b/docs/docs/configuration/motion_detection.md index 0f48f62b27..0844c04a80 100644 --- a/docs/docs/configuration/motion_detection.md +++ b/docs/docs/configuration/motion_detection.md @@ -13,11 +13,11 @@ Once motion is detected, it tries to group up nearby areas of motion together in The default motion settings should work well for the majority of cameras, however there are cases where tuning motion detection can lead to better and more optimal results. Each camera has its own environment with different variables that affect motion, this means that the same motion settings will not fit all of your cameras. -Before tuning motion it is important to understand the goal. In an optimal configuration, motion from people and cars would be detected, but not grass moving, lighting changes, timestamps, etc. If your motion detection is too sensitive, you will experience higher CPU loads and greater false positives from the increased rate of object detection. If it is not sensitive enough, you will miss events. +Before tuning motion it is important to understand the goal. In an optimal configuration, motion from people and cars would be detected, but not grass moving, lighting changes, timestamps, etc. If your motion detection is too sensitive, you will experience higher CPU loads and greater false positives from the increased rate of object detection. If it is not sensitive enough, you will miss objects that you want to track. ## Create Motion Masks -First, mask areas with regular motion not caused by the objects you want to detect. The best way to find candidates for motion masks is by watching the debug stream with motion boxes enabled. Good use cases for motion masks are timestamps or tree limbs and large bushes that regularly move due to wind. When possible, avoid creating motion masks that would block motion detection for objects you want to track **even if they are in locations where you don't want events**. Motion masks should not be used to avoid detecting objects in specific areas. More details can be found [in the masks docs.](/configuration/masks.md). +First, mask areas with regular motion not caused by the objects you want to detect. The best way to find candidates for motion masks is by watching the debug stream with motion boxes enabled. Good use cases for motion masks are timestamps or tree limbs and large bushes that regularly move due to wind. When possible, avoid creating motion masks that would block motion detection for objects you want to track **even if they are in locations where you don't want alerts or detections**. Motion masks should not be used to avoid detecting objects in specific areas. More details can be found [in the masks docs.](/configuration/masks.md). ## Prepare For Testing @@ -29,7 +29,7 @@ Now that things are set up, find a time to tune that represents normal circumsta :::note -Remember that motion detection is just used to determine when object detection should be used. You should aim to have motion detection sensitive enough that you won't miss events from objects you want to detect with object detection. The goal is to prevent object detection from running constantly for every small pixel change in the image. Windy days are still going to result in lots of motion being detected. +Remember that motion detection is just used to determine when object detection should be used. You should aim to have motion detection sensitive enough that you won't miss objects you want to detect with object detection. The goal is to prevent object detection from running constantly for every small pixel change in the image. Windy days are still going to result in lots of motion being detected. ::: @@ -94,7 +94,7 @@ motion: :::tip -Some cameras like doorbell cameras may have missed detections when someone walks directly in front of the camera and the lightning_threshold causes motion detection to be re-calibrated. In this case, it may be desirable to increase the `lightning_threshold` to ensure these events are not missed. +Some cameras like doorbell cameras may have missed detections when someone walks directly in front of the camera and the lightning_threshold causes motion detection to be re-calibrated. In this case, it may be desirable to increase the `lightning_threshold` to ensure these objects are not missed. ::: diff --git a/docs/docs/configuration/notifications.md b/docs/docs/configuration/notifications.md new file mode 100644 index 0000000000..9225ea6e87 --- /dev/null +++ b/docs/docs/configuration/notifications.md @@ -0,0 +1,42 @@ +--- +id: notifications +title: Notifications +--- + +# Notifications + +Frigate offers native notifications using the [WebPush Protocol](https://web.dev/articles/push-notifications-web-push-protocol) which uses the [VAPID spec](https://tools.ietf.org/html/draft-thomson-webpush-vapid) to deliver notifications to web apps using encryption. + +## Setting up Notifications + +In order to use notifications the following requirements must be met: + +- Frigate must be accessed via a secure https connection +- A supported browser must be used. Currently Chrome, Firefox, and Safari are known to be supported. +- In order for notifications to be usable externally, Frigate must be accessible externally + +### Configuration + +To configure notifications, go to the Frigate WebUI -> Settings -> Notifications and enable, then fill out the fields and save. + +### Registration + +Once notifications are enabled, press the `Register for Notifications` button on all devices that you would like to receive notifications on. This will register the background worker. After this Frigate must be restarted and then notifications will begin to be sent. + +## Supported Notifications + +Currently notifications are only supported for review alerts. More notifications will be supported in the future. + +:::note + +Currently, only Chrome supports images in notifications. Safari and Firefox will only show a title and message in the notification. + +::: + +## Reduce Notification Latency + +Different platforms handle notifications differently, some settings changes may be required to get optimal notification delivery. + +### Android + +Most Android phones have battery optimization settings. To get reliable Notification delivery the browser (Chrome, Firefox) should have battery optimizations disabled. If Frigate is running as a PWA then the Frigate app should have battery optimizations disabled as well. \ No newline at end of file diff --git a/docs/docs/configuration/object_detectors.md b/docs/docs/configuration/object_detectors.md index 8e5dab36bc..174d7a5727 100644 --- a/docs/docs/configuration/object_detectors.md +++ b/docs/docs/configuration/object_detectors.md @@ -3,9 +3,32 @@ id: object_detectors title: Object Detectors --- +# Supported Hardware + +Frigate supports multiple different detectors that work on different types of hardware: + +**Most Hardware** +- [Coral EdgeTPU](#edge-tpu-detector): The Google Coral EdgeTPU is available in USB and m.2 format allowing for a wide range of compatibility with devices. +- [Hailo](#hailo-8l): The Hailo8 AI Acceleration module is available in m.2 format with a HAT for RPi devices, offering a wide range of compatibility with devices. + +**AMD** +- [ROCm](#amdrocm-gpu-detector): ROCm can run on AMD Discrete GPUs to provide efficient object detection. +- [ONNX](#onnx): ROCm will automatically be detected and used as a detector in the `-rocm` Frigate image when a supported ONNX model is configured. + +**Intel** +- [OpenVino](#openvino-detector): OpenVino can run on Intel Arc GPUs, Intel integrated GPUs, and Intel CPUs to provide efficient object detection. +- [ONNX](#onnx): OpenVINO will automatically be detected and used as a detector in the default Frigate image when a supported ONNX model is configured. + +**Nvidia** +- [TensortRT](#nvidia-tensorrt-detector): TensorRT can run on Nvidia GPUs, using one of many default models. +- [ONNX](#onnx): TensorRT will automatically be detected and used as a detector in the `-tensorrt` Frigate image when a supported ONNX model is configured. + +**Rockchip** +- [RKNN](#rockchip-platform): RKNN models can run on Rockchip devices with included NPUs. + # Officially Supported Detectors -Frigate provides the following builtin detector types: `cpu`, `edgetpu`, `openvino`, `tensorrt`, and `rknn`. By default, Frigate will use a single CPU detector. Other detectors may require additional configuration as described below. When using multiple detectors they will run in dedicated processes, but pull from a common queue of detection requests from across all cameras. +Frigate provides the following builtin detector types: `cpu`, `edgetpu`, `openvino`, `tensorrt`, `rknn`, and `hailo8l`. By default, Frigate will use a single CPU detector. Other detectors may require additional configuration as described below. When using multiple detectors they will run in dedicated processes, but pull from a common queue of detection requests from across all cameras. ## CPU Detector (not recommended) @@ -122,6 +145,22 @@ The OpenVINO device to be used is specified using the `"device"` attribute accor OpenVINO is supported on 6th Gen Intel platforms (Skylake) and newer. It will also run on AMD CPUs despite having no official support for it. A supported Intel platform is required to use the `GPU` device with OpenVINO. For detailed system requirements, see [OpenVINO System Requirements](https://docs.openvino.ai/2024/about-openvino/release-notes-openvino/system-requirements.html) +:::tip + +When using many cameras one detector may not be enough to keep up. Multiple detectors can be defined assuming GPU resources are available. An example configuration would be: + +```yaml +detectors: + ov_0: + type: openvino + device: GPU + ov_1: + type: openvino + device: GPU +``` + +::: + ### Supported Models #### SSDLite MobileNet v2 @@ -278,6 +317,173 @@ model: height: 320 ``` +## AMD/ROCm GPU detector + +### Setup + +The `rocm` detector supports running YOLO-NAS models on AMD GPUs. Use a frigate docker image with `-rocm` suffix, for example `ghcr.io/blakeblackshear/frigate:stable-rocm`. + +### Docker settings for GPU access + +ROCm needs access to the `/dev/kfd` and `/dev/dri` devices. When docker or frigate is not run under root then also `video` (and possibly `render` and `ssl/_ssl`) groups should be added. + +When running docker directly the following flags should be added for device access: + +```bash +$ docker run --device=/dev/kfd --device=/dev/dri \ + ... +``` + +When using docker compose: + +```yaml +services: + frigate: +--- +devices: + - /dev/dri + - /dev/kfd +``` + +For reference on recommended settings see [running ROCm/pytorch in Docker](https://rocm.docs.amd.com/projects/install-on-linux/en/develop/how-to/3rd-party/pytorch-install.html#using-docker-with-pytorch-pre-installed). + +### Docker settings for overriding the GPU chipset + +Your GPU might work just fine without any special configuration but in many cases they need manual settings. AMD/ROCm software stack comes with a limited set of GPU drivers and for newer or missing models you will have to override the chipset version to an older/generic version to get things working. + +Also AMD/ROCm does not "officially" support integrated GPUs. It still does work with most of them just fine but requires special settings. One has to configure the `HSA_OVERRIDE_GFX_VERSION` environment variable. See the [ROCm bug report](https://github.com/ROCm/ROCm/issues/1743) for context and examples. + +For the rocm frigate build there is some automatic detection: + +- gfx90c -> 9.0.0 +- gfx1031 -> 10.3.0 +- gfx1103 -> 11.0.0 + +If you have something else you might need to override the `HSA_OVERRIDE_GFX_VERSION` at Docker launch. Suppose the version you want is `9.0.0`, then you should configure it from command line as: + +```bash +$ docker run -e HSA_OVERRIDE_GFX_VERSION=9.0.0 \ + ... +``` + +When using docker compose: + +```yaml +services: + frigate: +... +environment: + HSA_OVERRIDE_GFX_VERSION: "9.0.0" +``` + +Figuring out what version you need can be complicated as you can't tell the chipset name and driver from the AMD brand name. + +- first make sure that rocm environment is running properly by running `/opt/rocm/bin/rocminfo` in the frigate container -- it should list both the CPU and the GPU with their properties +- find the chipset version you have (gfxNNN) from the output of the `rocminfo` (see below) +- use a search engine to query what `HSA_OVERRIDE_GFX_VERSION` you need for the given gfx name ("gfxNNN ROCm HSA_OVERRIDE_GFX_VERSION") +- override the `HSA_OVERRIDE_GFX_VERSION` with relevant value +- if things are not working check the frigate docker logs + +#### Figuring out if AMD/ROCm is working and found your GPU + +```bash +$ docker exec -it frigate /opt/rocm/bin/rocminfo +``` + +#### Figuring out your AMD GPU chipset version: + +We unset the `HSA_OVERRIDE_GFX_VERSION` to prevent an existing override from messing up the result: + +```bash +$ docker exec -it frigate /bin/bash -c '(unset HSA_OVERRIDE_GFX_VERSION && /opt/rocm/bin/rocminfo |grep gfx)' +``` + +### Supported Models + +There is no default model provided, the following formats are supported: + +#### YOLO-NAS + +[YOLO-NAS](https://github.com/Deci-AI/super-gradients/blob/master/YOLONAS.md) models are supported, but not included by default. You can build and download a compatible model with pre-trained weights using [this notebook](https://github.com/frigate/blob/dev/notebooks/YOLO_NAS_Pretrained_Export.ipynb) [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/blakeblackshear/frigate/blob/dev/notebooks/YOLO_NAS_Pretrained_Export.ipynb). + +:::warning + +The pre-trained YOLO-NAS weights from DeciAI are subject to their license and can't be used commercially. For more information, see: https://docs.deci.ai/super-gradients/latest/LICENSE.YOLONAS.html + +::: + +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. + +After placing the downloaded onnx model in your config folder, you can use the following configuration: + +```yaml +detectors: + onnx: + type: rocm + +model: + model_type: yolonas + width: 320 # <--- should match whatever was set in notebook + height: 320 # <--- should match whatever was set in notebook + input_pixel_format: bgr + path: /config/yolo_nas_s.onnx + labelmap_path: /labelmap/coco-80.txt +``` + +Note that the labelmap uses a subset of the complete COCO label set that has only 80 objects. + +## ONNX + +ONNX is an open format for building machine learning models, Frigate supports running ONNX models on CPU, OpenVINO, and TensorRT. On startup Frigate will automatically try to use a GPU if one is available. + +:::tip + +When using many cameras one detector may not be enough to keep up. Multiple detectors can be defined assuming GPU resources are available. An example configuration would be: + +```yaml +detectors: + onnx_0: + type: onnx + onnx_1: + type: onnx +``` + +::: + +### Supported Models + +There is no default model provided, the following formats are supported: + +#### YOLO-NAS + +[YOLO-NAS](https://github.com/Deci-AI/super-gradients/blob/master/YOLONAS.md) models are supported, but not included by default. You can build and download a compatible model with pre-trained weights using [this notebook](https://github.com/frigate/blob/dev/notebooks/YOLO_NAS_Pretrained_Export.ipynb) [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/blakeblackshear/frigate/blob/dev/notebooks/YOLO_NAS_Pretrained_Export.ipynb). + +:::warning + +The pre-trained YOLO-NAS weights from DeciAI are subject to their license and can't be used commercially. For more information, see: https://docs.deci.ai/super-gradients/latest/LICENSE.YOLONAS.html + +::: + +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. + +After placing the downloaded onnx model in your config folder, you can use the following configuration: + +```yaml +detectors: + onnx: + type: onnx + +model: + model_type: yolonas + width: 320 # <--- should match whatever was set in notebook + height: 320 # <--- should match whatever was set in notebook + input_pixel_format: bgr + path: /config/yolo_nas_s.onnx + labelmap_path: /labelmap/coco-80.txt +``` + +Note that the labelmap uses a subset of the complete COCO label set that has only 80 objects. + ## Deepstack / CodeProject.AI Server Detector The Deepstack / CodeProject.AI Server detector for Frigate allows you to integrate Deepstack and CodeProject.AI object detection capabilities into Frigate. CodeProject.AI and DeepStack are open-source AI platforms that can be run on various devices such as the Raspberry Pi, Nvidia Jetson, and other compatible hardware. It is important to note that the integration is performed over the network, so the inference times may not be as fast as native Frigate detectors, but it still provides an efficient and reliable solution for object detection and tracking. @@ -386,3 +592,25 @@ $ cat /sys/kernel/debug/rknpu/load - All models are automatically downloaded and stored in the folder `config/model_cache/rknn_cache`. After upgrading Frigate, you should remove older models to free up space. - You can also provide your own `.rknn` model. You should not save your own models in the `rknn_cache` folder, store them directly in the `model_cache` folder or another subfolder. To convert a model to `.rknn` format see the `rknn-toolkit2` (requires a x86 machine). Note, that there is only post-processing for the supported models. + +## Hailo-8l + +This detector is available for use with Hailo-8 AI Acceleration Module. + +### Configuration + +```yaml +detectors: + hailo8l: + type: hailo8l + device: PCIe + model: + path: /config/model_cache/h8l_cache/ssd_mobilenet_v1.hef + +model: + width: 300 + height: 300 + input_tensor: nhwc + input_pixel_format: bgr + model_type: ssd +``` diff --git a/docs/docs/configuration/object_filters.md b/docs/docs/configuration/object_filters.md index 3339df9043..ca72600944 100644 --- a/docs/docs/configuration/object_filters.md +++ b/docs/docs/configuration/object_filters.md @@ -20,15 +20,13 @@ For object filters in your configuration, any single detection below `min_score` In frame 2, the score is below the `min_score` value, so Frigate ignores it and it becomes a 0.0. The computed score is the median of the score history (padding to at least 3 values), and only when that computed score crosses the `threshold` is the object marked as a true positive. That happens in frame 4 in the example. -show image of snapshot vs event with differing scores - ### Minimum Score -Any detection below `min_score` will be immediately thrown out and never tracked because it is considered a false positive. If `min_score` is too low then false positives may be detected and tracked which can confuse the object tracker and may lead to wasted resources. If `min_score` is too high then lower scoring true positives like objects that are further away or partially occluded may be thrown out which can also confuse the tracker and cause valid events to be lost or disjointed. +Any detection below `min_score` will be immediately thrown out and never tracked because it is considered a false positive. If `min_score` is too low then false positives may be detected and tracked which can confuse the object tracker and may lead to wasted resources. If `min_score` is too high then lower scoring true positives like objects that are further away or partially occluded may be thrown out which can also confuse the tracker and cause valid tracked objects to be lost or disjointed. ### Threshold -`threshold` is used to determine that the object is a true positive. Once an object is detected with a score >= `threshold` object is considered a true positive. If `threshold` is too low then some higher scoring false positives may create an event. If `threshold` is too high then true positive events may be missed due to the object never scoring high enough. +`threshold` is used to determine that the object is a true positive. Once an object is detected with a score >= `threshold` object is considered a true positive. If `threshold` is too low then some higher scoring false positives may create an tracked object. If `threshold` is too high then true positive tracked objects may be missed due to the object never scoring high enough. ## Object Shape @@ -52,7 +50,7 @@ Conceptually, a ratio of 1 is a square, 0.5 is a "tall skinny" box, and 2 is a " ### Zones -[Required zones](/configuration/zones.md) can be a great tool to reduce false positives that may be detected in the sky or other areas that are not of interest. The required zones will only create events for objects that enter the zone. +[Required zones](/configuration/zones.md) can be a great tool to reduce false positives that may be detected in the sky or other areas that are not of interest. The required zones will only create tracked objects for objects that enter the zone. ### Object Masks diff --git a/docs/docs/configuration/record.md b/docs/docs/configuration/record.md index 09ae420f97..e0e42f22ff 100644 --- a/docs/docs/configuration/record.md +++ b/docs/docs/configuration/record.md @@ -3,7 +3,7 @@ id: record title: Recording --- -Recordings can be enabled and are stored at `/media/frigate/recordings`. The folder structure for the recordings is `YYYY-MM-DD/HH//MM.SS.mp4` in **UTC time**. These recordings are written directly from your camera stream without re-encoding. Each camera supports a configurable retention policy in the config. Frigate chooses the largest matching retention value between the recording retention and the event retention when determining if a recording should be removed. +Recordings can be enabled and are stored at `/media/frigate/recordings`. The folder structure for the recordings is `YYYY-MM-DD/HH//MM.SS.mp4` in **UTC time**. These recordings are written directly from your camera stream without re-encoding. Each camera supports a configurable retention policy in the config. Frigate chooses the largest matching retention value between the recording retention and the tracked object retention when determining if a recording should be removed. New recording segments are written from the camera stream to cache, they are only moved to disk if they match the setup recording retention policy. @@ -13,7 +13,7 @@ H265 recordings can be viewed in Chrome 108+, Edge and Safari only. All other br ### Most conservative: Ensure all video is saved -For users deploying Frigate in environments where it is important to have contiguous video stored even if there was no detectable motion, the following config will store all video for 3 days. After 3 days, only video containing motion and overlapping with events will be retained until 30 days have passed. +For users deploying Frigate in environments where it is important to have contiguous video stored even if there was no detectable motion, the following config will store all video for 3 days. After 3 days, only video containing motion and overlapping with alerts or detections will be retained until 30 days have passed. ```yaml record: @@ -21,9 +21,13 @@ record: retain: days: 3 mode: all - events: + alerts: retain: - default: 30 + days: 30 + mode: motion + detections: + retain: + days: 30 mode: motion ``` @@ -37,25 +41,28 @@ record: retain: days: 3 mode: motion - events: + alerts: + retain: + days: 30 + mode: motion + detections: retain: - default: 30 + days: 30 mode: motion ``` -### Minimum: Events only +### Minimum: Alerts only -If you only want to retain video that occurs during an event, this config will discard video unless an event is ongoing. +If you only want to retain video that occurs during a tracked object, this config will discard video unless an alert is ongoing. ```yaml record: enabled: True retain: days: 0 - mode: all - events: + alerts: retain: - default: 30 + days: 30 mode: motion ``` @@ -65,7 +72,7 @@ As of Frigate 0.12 if there is less than an hour left of storage, the oldest 2 h ## Configuring Recording Retention -Frigate supports both continuous and event based recordings with separate retention modes and retention periods. +Frigate supports both continuous and tracked object based recordings with separate retention modes and retention periods. :::tip @@ -86,25 +93,28 @@ record: Continuous recording supports different retention modes [which are described below](#what-do-the-different-retain-modes-mean) -### Event Recording +### Object Recording -If you only used clips in previous versions with recordings disabled, you can use the following config to get the same behavior. This is also the default behavior when recordings are enabled. +The number of days to record review items can be specified for review items classified as alerts as well as tracked objects. ```yaml record: enabled: True - events: + alerts: + retain: + days: 10 # <- number of days to keep alert recordings + detections: retain: - default: 10 # <- number of days to keep event recordings + days: 10 # <- number of days to keep detections recordings ``` -This configuration will retain recording segments that overlap with events and have active tracked objects for 10 days. Because multiple events can reference the same recording segments, this avoids storing duplicate footage for overlapping events and reduces overall storage needs. +This configuration will retain recording segments that overlap with alerts and detections for 10 days. Because multiple tracked objects can reference the same recording segments, this avoids storing duplicate footage for overlapping tracked objects and reduces overall storage needs. **WARNING**: Recordings still must be enabled in the config. If a camera has recordings disabled in the config, enabling via the methods listed above will have no effect. ## What do the different retain modes mean? -Frigate saves from the stream with the `record` role in 10 second segments. These options determine which recording segments are kept for continuous recording (but can also affect events). +Frigate saves from the stream with the `record` role in 10 second segments. These options determine which recording segments are kept for continuous recording (but can also affect tracked objects). Let's say you have Frigate configured so that your doorbell camera would retain the last **2** days of continuous recording. @@ -112,11 +122,7 @@ Let's say you have Frigate configured so that your doorbell camera would retain - With the `motion` option the only parts of those 48 hours would be segments that Frigate detected motion. This is the middle ground option that won't keep all 48 hours, but will likely keep all segments of interest along with the potential for some extra segments. - With the `active_objects` option the only segments that would be kept are those where there was a true positive object that was not considered stationary. -The same options are available with events. Let's consider a scenario where you drive up and park in your driveway, go inside, then come back out 4 hours later. - -- With the `all` option all segments for the duration of the event would be saved for the event. This event would have 4 hours of footage. -- With the `motion` option all segments for the duration of the event with motion would be saved. This means any segment where a car drove by in the street, person walked by, lighting changed, etc. would be saved. -- With the `active_objects` it would only keep segments where the object was active. In this case the only segments that would be saved would be the ones where the car was driving up, you going inside, you coming outside, and the car driving away. Essentially reducing the 4 hours to a minute or two of event footage. +The same options are available with alerts and detections, except it will only save the recordings when it overlaps with a review item of that type. A configuration example of the above retain modes where all `motion` segments are stored for 7 days and `active objects` are stored for 14 days would be as follows: @@ -126,33 +132,18 @@ record: retain: days: 7 mode: motion - events: + alerts: retain: - default: 14 + days: 14 mode: active_objects -``` - -The above configuration example can be added globally or on a per camera basis. - -### Object Specific Retention - -You can also set specific retention length for an object type. The below configuration example builds on from above but also specifies that recordings of dogs only need to be kept for 2 days and recordings of cars should be kept for 7 days. - -```yaml -record: - enabled: True - retain: - days: 7 - mode: motion - events: + detections: retain: - default: 14 + days: 14 mode: active_objects - objects: - dog: 2 - car: 7 ``` +The above configuration example can be added globally or on a per camera basis. + ## Can I have "continuous" recordings, but only at certain times? Using Frigate UI, HomeAssistant, or MQTT, cameras can be automated to only record in certain situations or at certain times. diff --git a/docs/docs/configuration/reference.md b/docs/docs/configuration/reference.md index a90a3241e2..020e599798 100644 --- a/docs/docs/configuration/reference.md +++ b/docs/docs/configuration/reference.md @@ -210,6 +210,10 @@ birdseye: # Optional: ffmpeg configuration # More information about presets at https://docs.frigate.video/configuration/ffmpeg_presets ffmpeg: + # Optional: ffmpeg binry path (default: shown below) + # can also be set to `7.0` or `5.0` to specify one of the included versions + # or can be set to any path that holds `bin/ffmpeg` & `bin/ffprobe` + path: "default" # Optional: global ffmpeg args (default: shown below) global_args: -hide_banner -loglevel warning -threads 2 # Optional: global hwaccel args (default: auto detect) @@ -271,13 +275,13 @@ detect: # especially when using separate streams for detect and record. # Use this setting to make the timeline bounding boxes more closely align # with the recording. The value can be positive or negative. - # TIP: Imagine there is an event clip with a person walking from left to right. - # If the event timeline bounding box is consistently to the left of the person + # TIP: Imagine there is an tracked object clip with a person walking from left to right. + # If the tracked object lifecycle bounding box is consistently to the left of the person # then the value should be decreased. Similarly, if a person is walking from # left to right and the bounding box is consistently ahead of the person # then the value should be increased. # TIP: This offset is dynamic so you can change the value and it will update existing - # events, this makes it easy to tune. + # tracked objects, this makes it easy to tune. # WARNING: Fast moving objects will likely not have the bounding box align. annotation_offset: 0 @@ -372,6 +376,14 @@ motion: # Optional: Delay when updating camera motion through MQTT from ON -> OFF (default: shown below). mqtt_off_delay: 30 +# Optional: Notification Configuration +notifications: + # Optional: Enable notification service (default: shown below) + enabled: False + # Optional: Email for push service to reach out to + # NOTE: This is required to use notifications + email: "admin@example.com" + # Optional: Record configuration # NOTE: Can be overridden at the camera level record: @@ -386,9 +398,9 @@ record: sync_recordings: False # Optional: Retention settings for recording retain: - # Optional: Number of days to retain recordings regardless of events (default: shown below) - # NOTE: This should be set to 0 and retention should be defined in events section below - # if you only want to retain recordings of events. + # Optional: Number of days to retain recordings regardless of tracked objects (default: shown below) + # NOTE: This should be set to 0 and retention should be defined in alerts and detections section below + # if you only want to retain recordings of alerts and detections. days: 0 # Optional: Mode for retention. Available options are: all, motion, and active_objects # all - save all recording segments regardless of activity @@ -411,34 +423,48 @@ record: # Optional: Quality of recording preview (default: shown below). # Options are: very_low, low, medium, high, very_high quality: medium - # Optional: Event recording settings - events: - # Optional: Number of seconds before the event to include (default: shown below) + # Optional: alert recording settings + alerts: + # Optional: Number of seconds before the alert to include (default: shown below) pre_capture: 5 - # Optional: Number of seconds after the event to include (default: shown below) + # Optional: Number of seconds after the alert to include (default: shown below) post_capture: 5 - # Optional: Objects to save recordings for. (default: all tracked objects) - objects: - - person - # Optional: Retention settings for recordings of events + # Optional: Retention settings for recordings of alerts retain: - # Required: Default retention days (default: shown below) - default: 10 + # Required: Retention days (default: shown below) + days: 14 # Optional: Mode for retention. (default: shown below) - # all - save all recording segments for events regardless of activity - # motion - save all recordings segments for events with any detected motion - # active_objects - save all recording segments for event with active/moving objects + # all - save all recording segments for alerts regardless of activity + # motion - save all recordings segments for alerts with any detected motion + # active_objects - save all recording segments for alerts with active/moving objects + # + # NOTE: If the retain mode for the camera is more restrictive than the mode configured + # here, the segments will already be gone by the time this mode is applied. + # For example, if the camera retain mode is "motion", the segments without motion are + # never stored, so setting the mode to "all" here won't bring them back. + mode: motion + # Optional: detection recording settings + detections: + # Optional: Number of seconds before the detection to include (default: shown below) + pre_capture: 5 + # Optional: Number of seconds after the detection to include (default: shown below) + post_capture: 5 + # Optional: Retention settings for recordings of detections + retain: + # Required: Retention days (default: shown below) + days: 14 + # Optional: Mode for retention. (default: shown below) + # all - save all recording segments for detections regardless of activity + # motion - save all recordings segments for detections with any detected motion + # active_objects - save all recording segments for detections with active/moving objects # # NOTE: If the retain mode for the camera is more restrictive than the mode configured # here, the segments will already be gone by the time this mode is applied. # For example, if the camera retain mode is "motion", the segments without motion are # never stored, so setting the mode to "all" here won't bring them back. mode: motion - # Optional: Per object retention days - objects: - person: 15 -# Optional: Configuration for the jpg snapshots written to the clips directory for each event +# Optional: Configuration for the jpg snapshots written to the clips directory for each tracked object # NOTE: Can be overridden at the camera level snapshots: # Optional: Enable writing jpg snapshot to /media/frigate/clips (default: shown below) @@ -465,8 +491,37 @@ snapshots: # Optional: quality of the encoded jpeg, 0-100 (default: shown below) quality: 70 +# Optional: Configuration for semantic search capability +semantic_search: + # Optional: Enable semantic search (default: shown below) + enabled: False + # Optional: Re-index embeddings database from historical tracked objects (default: shown below) + reindex: False + +# Optional: Configuration for AI generated tracked object descriptions +# NOTE: Semantic Search must be enabled for this to do anything. +# WARNING: Depending on the provider, this will send thumbnails over the internet +# to Google or OpenAI's LLMs to generate descriptions. It can be overridden at +# the camera level (enabled: False) to enhance privacy for indoor cameras. +genai: + # Optional: Enable AI description generation (default: shown below) + enabled: False + # Required if enabled: Provider must be one of ollama, gemini, or openai + provider: ollama + # Required if provider is ollama. May also be used for an OpenAI API compatible backend with the openai provider. + base_url: http://localhost::11434 + # Required if gemini or openai + api_key: "{FRIGATE_GENAI_API_KEY}" + # Optional: The default prompt for generating descriptions. Can use replacement + # variables like "label", "sub_label", "camera" to make more dynamic. (default: shown below) + prompt: "Describe the {label} in the sequence of images with as much detail as possible. Do not describe the background." + # Optional: Object specific prompts to customize description results + # Format: {label}: {prompt} + object_prompts: + person: "My special person prompt." + # Optional: Restream configuration -# Uses https://github.com/AlexxIT/go2rtc (v1.8.3) +# Uses https://github.com/AlexxIT/go2rtc (v1.9.2) go2rtc: # Optional: jsmpeg stream configuration for WebUI @@ -613,8 +668,8 @@ cameras: user: admin # Optional: password for login. password: admin - # Optional: Ignores time synchronization mismatches between the camera and the server during authentication. - # Using NTP on both ends is recommended and this should only be set to True in a "safe" environment due to the security risk it represents. + # Optional: Ignores time synchronization mismatches between the camera and the server during authentication. + # Using NTP on both ends is recommended and this should only be set to True in a "safe" environment due to the security risk it represents. ignore_time_mismatch: False # Optional: PTZ camera object autotracking. Keeps a moving object in # the center of the frame by automatically moving the PTZ camera. @@ -657,6 +712,18 @@ cameras: # By default the cameras are sorted alphabetically. order: 0 + # Optional: Configuration for AI generated tracked object descriptions + genai: + # Optional: Enable AI description generation (default: shown below) + enabled: False + # Optional: The default prompt for generating descriptions. Can use replacement + # variables like "label", "sub_label", "camera" to make more dynamic. (default: shown below) + prompt: "Describe the {label} in the sequence of images with as much detail as possible. Do not describe the background." + # Optional: Object specific prompts to customize description results + # Format: {label}: {prompt} + object_prompts: + person: "My special person prompt." + # Optional ui: # Optional: Set a timezone to use in the UI (default: use browser local time) diff --git a/docs/docs/configuration/restream.md b/docs/docs/configuration/restream.md index f9d4e40946..2110509725 100644 --- a/docs/docs/configuration/restream.md +++ b/docs/docs/configuration/restream.md @@ -21,7 +21,7 @@ Birdseye RTSP restream can be accessed at `rtsp://:8554/birdseye`. ```yaml birdseye: - restream: true + restream: True ``` ### Securing Restream With Authentication diff --git a/docs/docs/configuration/review.md b/docs/docs/configuration/review.md index 4a39924ebf..f8e6dfff50 100644 --- a/docs/docs/configuration/review.md +++ b/docs/docs/configuration/review.md @@ -7,13 +7,13 @@ The Review page of the Frigate UI is for quickly reviewing historical footage of Review items are filterable by date, object type, and camera. -### Review items vs. events +### Review items vs. tracked objects (formerly "events") In Frigate 0.13 and earlier versions, the UI presented "events". An event was synonymous with a tracked or detected object. In Frigate 0.14 and later, a review item is a time period where any number of tracked objects were active. For example, consider a situation where two people walked past your house. One was walking a dog. At the same time, a car drove by on the street behind them. -In this scenario, Frigate 0.13 and earlier would show 4 events in the UI - one for each person, another for the dog, and yet another for the car. You would have had 4 separate videos to watch even though they would have all overlapped. +In this scenario, Frigate 0.13 and earlier would show 4 "events" in the UI - one for each person, another for the dog, and yet another for the car. You would have had 4 separate videos to watch even though they would have all overlapped. In 0.14 and later, all of that is bundled into a single review item which starts and ends to capture all of that activity. Reviews for a single camera cannot overlap. Once you have watched that time period on that camera, it is marked as reviewed. diff --git a/docs/docs/configuration/semantic_search.md b/docs/docs/configuration/semantic_search.md new file mode 100644 index 0000000000..a82b9cccaa --- /dev/null +++ b/docs/docs/configuration/semantic_search.md @@ -0,0 +1,44 @@ +--- +id: semantic_search +title: Using Semantic Search +--- + +Semantic Search in Frigate allows you to find tracked objects within your review items using either the image itself, a user-defined text description, or an automatically generated one. This feature works by creating _embeddings_ — numerical vector representations — for both the images and text descriptions of your tracked objects. By comparing these embeddings, Frigate assesses their similarities to deliver relevant search results. + +Frigate has support for two models to create embeddings, both of which run locally: [OpenAI CLIP](https://openai.com/research/clip) and [all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2). Embeddings are then saved to a local instance of [ChromaDB](https://trychroma.com). + +Semantic Search is accessed via the _Explore_ view in the Frigate UI. + +## Configuration + +Semantic search is disabled by default, and must be enabled in your config file before it can be used. Semantic Search is a global configuration setting. + +```yaml +semantic_search: + enabled: True + reindex: False +``` + +:::tip + +The embeddings database can be re-indexed from the existing tracked objects in your database by adding `reindex: True` to your `semantic_search` configuration. Depending on the number of tracked objects you have, it can take a long while to complete and may max out your CPU while indexing. Make sure to set the config back to `False` before restarting Frigate again. + +If you are enabling the Search feature for the first time, be advised that Frigate does not automatically index older tracked objects. You will need to enable the `reindex` feature in order to do that. + +::: + +### OpenAI CLIP + +This model is able to embed both images and text into the same vector space, which allows `image -> image` and `text -> image` similarity searches. Frigate uses this model on tracked objects to encode the thumbnail image and store it in Chroma. When searching for tracked objects via text in the search box, Frigate will perform a `text -> image` similarity search against this embedding. When clicking "Find Similar" in the tracked object detail pane, Frigate will perform an `image -> image` similarity search to retrieve the closest matching thumbnails. + +### all-MiniLM-L6-v2 + +This is a sentence embedding model that has been fine tuned on over 1 billion sentence pairs. This model is used to embed tracked object descriptions and perform searches against them. Descriptions can be created, viewed, and modified on the Search page when clicking on the gray tracked object chip at the top left of each review item. See [the Generative AI docs](/configuration/genai.md) for more information on how to automatically generate tracked object descriptions. + +## Usage + +1. Semantic search is used in conjunction with the other filters available on the Search page. Use a combination of traditional filtering and semantic search for the best results. +2. The comparison between text and image embedding distances generally means that results matching `description` will appear first, even if a `thumbnail` embedding may be a better match. Play with the "Search Type" filter to help find what you are looking for. +3. Make your search language and tone closely match your descriptions. If you are using thumbnail search, phrase your query as an image caption. +4. Semantic search on thumbnails tends to return better results when matching large subjects that take up most of the frame. Small things like "cat" tend to not work well. +5. Experiment! Find a tracked object you want to test and start typing keywords to see what works for you. diff --git a/docs/docs/configuration/zones.md b/docs/docs/configuration/zones.md index e8a9a49fd9..aef6b0a5b2 100644 --- a/docs/docs/configuration/zones.md +++ b/docs/docs/configuration/zones.md @@ -64,7 +64,7 @@ cameras: ### Restricting zones to specific objects -Sometimes you want to limit a zone to specific object types to have more granular control of when events/snapshots are saved. The following example will limit one zone to person objects and the other to cars. +Sometimes you want to limit a zone to specific object types to have more granular control of when alerts, detections, and snapshots are saved. The following example will limit one zone to person objects and the other to cars. ```yaml cameras: @@ -80,7 +80,7 @@ cameras: - car ``` -Only car objects can trigger the `front_yard_street` zone and only person can trigger the `entire_yard`. You will get events for person objects that enter anywhere in the yard, and events for cars only if they enter the street. +Only car objects can trigger the `front_yard_street` zone and only person can trigger the `entire_yard`. Objects will be tracked for any `person` that enter anywhere in the yard, and for cars only if they enter the street. ### Zone Loitering diff --git a/docs/docs/frigate/glossary.md b/docs/docs/frigate/glossary.md index 5be40f249e..bd039554c9 100644 --- a/docs/docs/frigate/glossary.md +++ b/docs/docs/frigate/glossary.md @@ -16,10 +16,6 @@ A box returned from the object detection model that outlines an object in the fr - A gray thin line indicates that object is detected as being stationary - A thick line indicates that object is the subject of autotracking (when enabled). -## Event - -The time period starting when a tracked object entered the frame and ending when it left the frame, including any time that the object remained still. Events are saved when it is considered a [true positive](#threshold) and meets the requirements for a snapshot or recording to be saved. - ## False Positive An incorrect detection of an object type. For example a dog being detected as a person, a chair being detected as a dog, etc. A person being detected in an area you want to ignore is not a false positive. @@ -64,6 +60,10 @@ The threshold is the median score that an object must reach in order to be consi The top score for an object is the highest median score for an object. +## Tracked Object ("event" in previous versions) + +The time period starting when a tracked object entered the frame and ending when it left the frame, including any time that the object remained still. Tracked objects are saved when it is considered a [true positive](#threshold) and meets the requirements for a snapshot or recording to be saved. + ## Zone Zones are areas of interest, zones can be used for notifications and for limiting the areas where Frigate will create an [event](#event). [See the zone docs for more info](/configuration/zones) diff --git a/docs/docs/frigate/hardware.md b/docs/docs/frigate/hardware.md index 602cc906f0..ef647e4747 100644 --- a/docs/docs/frigate/hardware.md +++ b/docs/docs/frigate/hardware.md @@ -87,6 +87,10 @@ Inference speeds will vary greatly depending on the GPU and the model used. | Quadro P400 2GB | 20 - 25 ms | | Quadro P2000 | ~ 12 ms | +#### AMD GPUs + +With the [rocm](../configuration/object_detectors.md#amdrocm-gpu-detector) detector Frigate can take advantage of many AMD GPUs. + ### Community Supported: #### Nvidia Jetson @@ -107,6 +111,12 @@ Frigate supports hardware video processing on all Rockchip boards. However, hard The inference time of a rk3588 with all 3 cores enabled is typically 25-30 ms for yolo-nas s. +#### Hailo-8l PCIe + +Frigate supports the Hailo-8l M.2 card on any hardware but currently it is only tested on the Raspberry Pi5 PCIe hat from the AI kit. + +The inference time for the Hailo-8L chip at time of writing is around 17-21 ms for the SSD MobileNet Version 1 model. + ## What does Frigate use the CPU for and what does it use a detector for? (ELI5 Version) This is taken from a [user question on reddit](https://www.reddit.com/r/homeassistant/comments/q8mgau/comment/hgqbxh5/?utm_source=share&utm_medium=web2x&context=3). Modified slightly for clarity. diff --git a/docs/docs/frigate/installation.md b/docs/docs/frigate/installation.md index c291697aa3..200b48e60a 100644 --- a/docs/docs/frigate/installation.md +++ b/docs/docs/frigate/installation.md @@ -73,23 +73,23 @@ Users of the Snapcraft build of Docker cannot use storage locations outside your Frigate utilizes shared memory to store frames during processing. The default `shm-size` provided by Docker is **64MB**. -The default shm size of **64MB** is fine for setups with **2 cameras** detecting at **720p**. If Frigate is exiting with "Bus error" messages, it is likely because you have too many high resolution cameras and you need to specify a higher shm size, using [`--shm-size`](https://docs.docker.com/engine/reference/run/#runtime-constraints-on-resources) (or [`service.shm_size`](https://docs.docker.com/compose/compose-file/compose-file-v2/#shm_size) in docker-compose). +The default shm size of **128MB** is fine for setups with **2 cameras** detecting at **720p**. If Frigate is exiting with "Bus error" messages, it is likely because you have too many high resolution cameras and you need to specify a higher shm size, using [`--shm-size`](https://docs.docker.com/engine/reference/run/#runtime-constraints-on-resources) (or [`service.shm_size`](https://docs.docker.com/compose/compose-file/compose-file-v2/#shm_size) in docker-compose). -The Frigate container also stores logs in shm, which can take up to **30MB**, so make sure to take this into account in your math as well. +The Frigate container also stores logs in shm, which can take up to **40MB**, so make sure to take this into account in your math as well. -You can calculate the necessary shm size for each camera with the following formula using the resolution specified for detect: +You can calculate the **minimum** shm size for each camera with the following formula using the resolution specified for detect: ```console # Replace and -$ python -c 'print("{:.2f}MB".format(( * * 1.5 * 9 + 270480) / 1048576))' +$ python -c 'print("{:.2f}MB".format(( * * 1.5 * 10 + 270480) / 1048576))' # Example for 1280x720 -$ python -c 'print("{:.2f}MB".format((1280 * 720 * 1.5 * 9 + 270480) / 1048576))' -12.12MB +$ python -c 'print("{:.2f}MB".format((1280 * 720 * 1.5 * 10 + 270480) / 1048576))' +13.44MB # Example for eight cameras detecting at 1280x720, including logs -$ python -c 'print("{:.2f}MB".format(((1280 * 720 * 1.5 * 9 + 270480) / 1048576) * 8 + 30))' -126.99MB +$ python -c 'print("{:.2f}MB".format(((1280 * 720 * 1.5 * 10 + 270480) / 1048576) * 8 + 40))' +136.99MB ``` The shm size cannot be set per container for Home Assistant add-ons. However, this is probably not required since by default Home Assistant Supervisor allocates `/dev/shm` with half the size of your total memory. If your machine has 8GB of memory, chances are that Frigate will have access to up to 4GB without any additional configuration. @@ -100,6 +100,38 @@ By default, the Raspberry Pi limits the amount of memory available to the GPU. I Additionally, the USB Coral draws a considerable amount of power. If using any other USB devices such as an SSD, you will experience instability due to the Pi not providing enough power to USB devices. You will need to purchase an external USB hub with it's own power supply. Some have reported success with this (affiliate link). +### Hailo-8L + +The Hailo-8L is an M.2 card typically connected to a carrier board for PCIe, which then connects to the Raspberry Pi 5 as part of the AI Kit. However, it can also be used on other boards equipped with an M.2 M key edge connector. + +#### Installation + +For Raspberry Pi 5 users with the AI Kit, installation is straightforward. Simply follow this [guide](https://www.raspberrypi.com/documentation/accessories/ai-kit.html#ai-kit-installation) to install the driver and software. + +For other installations, follow these steps for installation: + +1. Install the driver from the [Hailo GitHub repository](https://github.com/hailo-ai/hailort-drivers). A convenient script for Linux is available to clone the repository, build the driver, and install it. +2. Copy or download [this script](https://github.com/blakeblackshear/frigate/blob/41c9b13d2fffce508b32dfc971fa529b49295fbd/docker/hailo8l/user_installation.sh). +3. Ensure it has execution permissions with `sudo chmod +x install_hailo8l_driver.sh` +4. Run the script with `./install_hailo8l_driver.sh` + +#### Setup + +To set up Frigate, follow the default installation instructions, but use a Docker image with the `-h8l` suffix, for example: `ghcr.io/blakeblackshear/frigate:stable-h8l` + +Next, grant Docker permissions to access your hardware by adding the following lines to your `docker-compose.yml` file: + +```yaml +devices: + - /dev/hailo0 +``` + +If you are using `docker run`, add this option to your command `--device /dev/hailo0` + +#### Configuration + +Finally, configure [hardware object detection](/configuration/object_detectors#hailo-8l) to complete the setup. + ### Rockchip platform Make sure that you use a linux distribution that comes with the rockchip BSP kernel 5.10 or 6.1 and necessary drivers (especially rkvdec2 and rknpu). To check, enter the following commands: @@ -222,6 +254,7 @@ The community supported docker image tags for the current stable version are: - `stable-rocm-gfx900` - AMD gfx900 driver only - `stable-rocm-gfx1030` - AMD gfx1030 driver only - `stable-rocm-gfx1100` - AMD gfx1100 driver only + - `stable-h8l` - Frigate build for the Hailo-8L M.2 PICe Raspberry Pi 5 hat ## Home Assistant Addon diff --git a/docs/docs/guides/getting_started.md b/docs/docs/guides/getting_started.md index b74cb93774..908e0ce1b9 100644 --- a/docs/docs/guides/getting_started.md +++ b/docs/docs/guides/getting_started.md @@ -238,7 +238,7 @@ Now that you know where you need to mask, use the "Mask & Zone creator" in the o :::warning -Note that motion masks should not be used to mark out areas where you do not want objects to be detected or to reduce false positives. They do not alter the image sent to object detection, so you can still get events and detections in areas with motion masks. These only prevent motion in these areas from initiating object detection. +Note that motion masks should not be used to mark out areas where you do not want objects to be detected or to reduce false positives. They do not alter the image sent to object detection, so you can still get tracked objects, alerts, and detections in areas with motion masks. These only prevent motion in these areas from initiating object detection. ::: @@ -294,7 +294,15 @@ cameras: If you don't have separate streams for detect and record, you would just add the record role to the list on the first input. -By default, Frigate will retain video of all events for 10 days. The full set of options for recording can be found [here](../configuration/reference.md). +:::note + +If you only define one stream in your `inputs` and do not assign a `detect` role to it, Frigate will automatically assign it the `detect` role. Frigate will always decode a stream to support motion detection, Birdseye, the API image endpoints, and other features, even if you have disabled object detection with `enabled: False` in your config's `detect` section. + +If you only plan to use Frigate for recording, it is still recommended to define a `detect` role for a low resolution stream to minimize resource usage from the required stream decoding. + +::: + +By default, Frigate will retain video of all tracked objects for 10 days. The full set of options for recording can be found [here](../configuration/reference.md). ### Step 7: Complete config @@ -309,4 +317,3 @@ Now that you have a working install, you can use the following documentation for 3. [Review](../configuration/review.md) 4. [Masks](../configuration/masks.md) 5. [Home Assistant Integration](../integrations/home-assistant.md) - Integrate with Home Assistant - diff --git a/docs/docs/guides/ha_notifications.md b/docs/docs/guides/ha_notifications.md index cc729af042..a92dab10f1 100644 --- a/docs/docs/guides/ha_notifications.md +++ b/docs/docs/guides/ha_notifications.md @@ -7,11 +7,11 @@ The best way to get started with notifications for Frigate is to use the [Bluepr It is generally recommended to trigger notifications based on the `frigate/reviews` mqtt topic. This provides the event_id(s) needed to fetch [thumbnails/snapshots/clips](../integrations/home-assistant.md#notification-api) and other useful information to customize when and where you want to receive alerts. The data is published in the form of a change feed, which means you can reference the "previous state" of the object in the `before` section and the "current state" of the object in the `after` section. You can see an example [here](../integrations/mqtt.md#frigateevents). -Here is a simple example of a notification automation of events which will update the existing notification for each change. This means the image you see in the notification will update as Frigate finds a "better" image. +Here is a simple example of a notification automation of tracked objects which will update the existing notification for each change. This means the image you see in the notification will update as Frigate finds a "better" image. ```yaml automation: - - alias: Notify of events + - alias: Notify of tracked object trigger: platform: mqtt topic: frigate/events diff --git a/docs/docs/integrations/api.md b/docs/docs/integrations/api.md index a0208bc010..edbb3d8811 100644 --- a/docs/docs/integrations/api.md +++ b/docs/docs/integrations/api.md @@ -189,15 +189,15 @@ Example parameters: ### `GET /api//