Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nvidia Jetson Nano gstreamer + TensorRT support #2548

Closed
Closed
Show file tree
Hide file tree
Changes from 156 commits
Commits
Show all changes
165 commits
Select commit Hold shift + click to select a range
61c62d4
version tick
blakeblackshear Oct 6, 2021
b63c56d
only save recordings when an event is in progress
blakeblackshear Oct 23, 2021
8f101cc
improve box merging and keep tracking
blakeblackshear Oct 30, 2021
d17bd74
reduce detection rate for stationary objects
blakeblackshear Oct 30, 2021
24cc63d
drop high overlap detections
blakeblackshear Oct 31, 2021
5bec438
config option for stationary detection interval
blakeblackshear Oct 31, 2021
58117e2
check for overlapping motion boxes
blakeblackshear Nov 4, 2021
9dc6c42
improve contrast
blakeblackshear Nov 4, 2021
57dcb29
consolidate regions
blakeblackshear Nov 4, 2021
ff667b0
remove min frame height of 180 and increase contour area
blakeblackshear Nov 4, 2021
d554175
no longer make motion settings dynamic
blakeblackshear Nov 7, 2021
bd7755f
revamp process clip
blakeblackshear Nov 7, 2021
8f43a2d
use resolution of clip
blakeblackshear Nov 8, 2021
4422e86
clarify shm in docs
blakeblackshear Nov 8, 2021
1c1c28d
create ffmpeg commands on startup
blakeblackshear Nov 8, 2021
cdd3000
fix ffmpeg config for env vars
blakeblackshear Nov 9, 2021
c7faef8
don't modify ffmpeg_cmd object
blakeblackshear Nov 9, 2021
3541f96
error handling for the recording maintainer
blakeblackshear Nov 9, 2021
51fb532
set retain when setting switches from frontend
blakeblackshear Nov 9, 2021
14c74e4
more robust cache management
blakeblackshear Nov 11, 2021
b912851
fix default motion comment
blakeblackshear Nov 15, 2021
ae96804
revert switch to b/w frame prep
blakeblackshear Nov 17, 2021
1ebb8a5
avoid divide by zero
blakeblackshear Nov 17, 2021
19a6978
avoid proactive messages with retain_days 0 and handle first pass
blakeblackshear Nov 17, 2021
c7d4743
better cache handling
blakeblackshear Nov 17, 2021
585efe1
keep 5 segments in cache
blakeblackshear Nov 19, 2021
3d556cc
warn if no wait time
blakeblackshear Nov 19, 2021
a3301e0
avoid running ffprobe for each segment multiple times
blakeblackshear Nov 19, 2021
e6d2df5
add duration to cache
blakeblackshear Nov 19, 2021
63b7465
ensure stationary interval is greater than 0
blakeblackshear Nov 20, 2021
494e5ac
use snapshot url to support in progress events
blakeblackshear Nov 20, 2021
77c66d4
ensure duration > 0 for segments
blakeblackshear Nov 21, 2021
7a2a85d
log error messages on vod endpoints
blakeblackshear Nov 21, 2021
ae3c01f
handle missing file edge case
blakeblackshear Nov 21, 2021
77c1f1b
cleanup missing files from database once per hour
blakeblackshear Nov 21, 2021
c1155af
ensure cache copies when events have ended
blakeblackshear Nov 21, 2021
26241b0
no need to expire recordings every minute
blakeblackshear Dec 5, 2021
92e08b9
sync recordings with disk once on startup
blakeblackshear Dec 5, 2021
af00132
fix process_clip
blakeblackshear Dec 5, 2021
f3efc06
retain frame data for recording maintenance
blakeblackshear Dec 11, 2021
63f8034
pass processed tracked objects
blakeblackshear Dec 11, 2021
9f18629
switch to retain config instead of retain_days
blakeblackshear Dec 11, 2021
cbb2882
refactor segment stats logic
blakeblackshear Dec 11, 2021
df0246a
warn when retention mismatch
blakeblackshear Dec 11, 2021
18fd50d
store objects and motion counts in the db
blakeblackshear Dec 11, 2021
b19a028
expire overlapping segments based on mode
blakeblackshear Dec 11, 2021
589432b
update docs
blakeblackshear Dec 11, 2021
fcb4aae
limit vod response cache
blakeblackshear Dec 12, 2021
a5c13e7
Add temperature of coral tpu to telemetry mqtt message
mattthewclayton Nov 29, 2021
156e1a4
Allow for ".yaml" (#2244)
jcgoette Dec 12, 2021
251d29a
#2117 change entered_zones from set to list so that they are not auto…
ryanm101 Dec 12, 2021
95bdf9f
check for apex dir
blakeblackshear Dec 12, 2021
609b436
fix migrations
blakeblackshear Dec 13, 2021
db1255a
disable disk sync on startup
blakeblackshear Dec 13, 2021
1569ce7
Change JPEG mime type (#2543)
tjhorner Dec 30, 2021
9edf383
safe refactoring (#2552)
yury-sannikov Dec 31, 2021
bd8e238
Run python unit tests in a github actions (#2589)
yury-sannikov Jan 14, 2022
4a49720
gstreamer work in progress / cofr
Dec 13, 2021
dd2c1cd
temporal gstreamer setup
Dec 13, 2021
93edf4e
frigate config
Dec 13, 2021
d90f239
downgrade to python3.6
Dec 15, 2021
6f2b200
docker L4T
Dec 15, 2021
b0c314a
exploratory
Dec 17, 2021
3ba91f0
add converter to generate ssd_mobilenet_v2_coco
Dec 21, 2021
6ad9813
add converter to generate yolo4 models
Dec 22, 2021
86af2a5
return to Python 3.8
Dec 26, 2021
47f3d7c
refactor edgetpu to accept more detector types
Dec 27, 2021
76d46fe
make TensorRT works (and break edgetpu)
Dec 28, 2021
477334d
fix ffmpeg config
Dec 31, 2021
c7b3330
bump
Dec 31, 2021
f8118ad
complete edgetpu refactoring
Jan 2, 2022
3c6fe81
implement source auto detection for gstreamer
Jan 4, 2022
d5dd82f
refactor GStreamer + autodetect
Jan 6, 2022
1aa6cca
recording for GStreamer
Jan 7, 2022
e2c5bfe
add unit tests for gstreamer
Jan 8, 2022
fbbcad4
docker refactoring
Jan 11, 2022
1c9749b
Makefile updates and refactoring
Jan 11, 2022
6930946
reduce Makefile changes
Jan 11, 2022
d5d4aa2
reduce docker changes
Jan 11, 2022
ab659ff
fix ffmpeg build for aarch64
Jan 11, 2022
2c62c7f
gstreamer improvements
Jan 12, 2022
c742c27
fix aarch64 tests
Jan 20, 2022
34f8018
fix validator tests
Jan 20, 2022
254e346
fixx ffmpeg install on amd64
Jan 23, 2022
469d1c3
fix ffmpeg install on amd64 x2
Jan 23, 2022
4771079
fix ffmpeg install on amd64 x3 (sorry)
Jan 23, 2022
a5dcc51
rework gstreamer
Feb 2, 2022
273f803
Event Datepicker (#2428)
Feb 2, 2022
667cfed
rework gstreamer autodetext + add audio for recordings
Feb 4, 2022
040d8c9
require url safe camera names
blakeblackshear Feb 2, 2022
326b368
cleanup clean snapshots on event deletion too
blakeblackshear Feb 2, 2022
944b918
if recording not on disk, delete from db and return
blakeblackshear Feb 2, 2022
82c6009
improve method for determining position
blakeblackshear Feb 4, 2022
92f9195
randomize the region multiplier for variation
blakeblackshear Feb 4, 2022
077d900
require a position change to be an active object
blakeblackshear Feb 5, 2022
307068a
scan the frame on startup
blakeblackshear Feb 5, 2022
037f866
default periodic checks to never
blakeblackshear Feb 5, 2022
955c277
dont stop scanning when there are other regions
blakeblackshear Feb 5, 2022
f801930
use iou instead of centroid
blakeblackshear Feb 5, 2022
2b7d38f
avoid extra tracking work on stationary frames
blakeblackshear Feb 5, 2022
0916481
make expire interval configurable for users wanting to minimize i/o
blakeblackshear Feb 5, 2022
23c70ac
update stationary interval docs
blakeblackshear Feb 5, 2022
e6ec5cb
make motion the default retain mode
blakeblackshear Feb 5, 2022
b1e84ca
allow dash in camera name
blakeblackshear Feb 5, 2022
7b4cb95
package updates for docs
blakeblackshear Feb 6, 2022
794a9ff
upgrade npm in dev container
blakeblackshear Feb 6, 2022
21cc29b
add additional info for non-H264 cameras
blakeblackshear Feb 6, 2022
21f1a98
add new properties to the docs
blakeblackshear Feb 6, 2022
50b5d40
add stacktrace to config validation errors
blakeblackshear Feb 6, 2022
3600ebc
adjust error messages on ffmpeg crash
blakeblackshear Feb 6, 2022
499f75e
set has_clip to false when recordings fail
blakeblackshear Feb 6, 2022
2d5ec25
invert active_count logic
blakeblackshear Feb 6, 2022
5a2076f
improve warning for retain modes
blakeblackshear Feb 6, 2022
1a3f21e
note for future
blakeblackshear Feb 6, 2022
f57501d
avoid rare divide by zero
blakeblackshear Feb 6, 2022
47e0e1d
add example for ios camera live feed notification
blakeblackshear Feb 6, 2022
5e156f8
update addon urls
blakeblackshear Feb 6, 2022
02c91d4
clarify that zones are based on the bottom center
blakeblackshear Feb 6, 2022
acc1022
remove outdated output args tip
blakeblackshear Feb 6, 2022
4e23967
clarify addon versions
blakeblackshear Feb 6, 2022
24f9937
fix resolution on reolink example
blakeblackshear Feb 6, 2022
9a0d276
allow motion based retention when detect is disabled
blakeblackshear Feb 6, 2022
ad4929c
increment motionless_count
blakeblackshear Feb 6, 2022
3617a62
only update db entry when a stored property changes
blakeblackshear Feb 8, 2022
8670a3d
publish an update on position changes
blakeblackshear Feb 8, 2022
0b02f20
make stationary_threshold configurable
blakeblackshear Feb 8, 2022
64f80a4
signal an update when object becomes stationary
blakeblackshear Feb 8, 2022
a3fa3cb
update an object once per minute
blakeblackshear Feb 9, 2022
54b88fb
Add in progress events to recordings view
hunterjm Feb 9, 2022
45b56bd
Update package-lock.json
hunterjm Feb 9, 2022
9ecc792
Fix playback rate resetting to 1 on source change
hunterjm Feb 9, 2022
0911b4f
gstreamer improvements
Feb 9, 2022
baf8343
fix unit tests
Feb 9, 2022
1f28011
Merge remote-tracking branch 'origin/release-0.10.0' into gstreamer
Feb 9, 2022
a1afc1c
fix merge error
Feb 9, 2022
62c1a61
remove invalid warning
blakeblackshear Feb 9, 2022
54d1a22
Allow download of in progress clips
hunterjm Feb 9, 2022
1171770
Only send significant update once when motionless count reaches the d…
hunterjm Feb 9, 2022
4deb365
Fix duration for long events and playback rate for top of the hour
hunterjm Feb 9, 2022
adbc54b
selectively increment position changes
blakeblackshear Feb 10, 2022
7934f86
fix the bounding box calculation position at 10
blakeblackshear Feb 11, 2022
4e52461
set stationary_threshold default to 5x fps
blakeblackshear Feb 11, 2022
95ab22d
bump default stationary_threshold to 10s
blakeblackshear Feb 11, 2022
6b2bae0
stop forcing detection all the way to stationary_threshold
blakeblackshear Feb 11, 2022
334e28f
use second stream in docs example
blakeblackshear Feb 12, 2022
ee01396
update birdseye to handle stationary objects
blakeblackshear Feb 12, 2022
889835a
Always show recording link even if recordings are currently disabled …
NickM-27 Feb 12, 2022
304ffa8
refactor stationary config into section
blakeblackshear Feb 13, 2022
3be0b91
deregister based on max_frames setting
blakeblackshear Feb 13, 2022
e5714f5
add missing optional comment in docs
blakeblackshear Feb 13, 2022
79e7341
GStreamer documentation
Feb 17, 2022
85ad8ec
Merge remote-tracking branch 'origin/release-0.10.0' into gstreamer
Feb 17, 2022
1240a07
Merge remote-tracking branch 'origin/release-0.11.0' into gstreamer
Feb 22, 2022
265c400
support multiple rtsp/rtmp URI schemes
Feb 22, 2022
dca84c5
fix PR build
Feb 22, 2022
8ac1232
fix build no 2
Feb 22, 2022
0795017
Merge remote-tracking branch 'origin/release-0.11.0' into gstreamer
Mar 15, 2022
a55e230
migrate l4t wheels to Python3.9
Mar 17, 2022
3bd67f5
update dockerfile
Mar 23, 2022
11a1ff0
update makefile
Mar 23, 2022
5f580b6
Merge remote-tracking branch 'origin/release-0.11.0' into gstreamer
Mar 23, 2022
07a2697
ffmpeg
Mar 23, 2022
403bee8
gstreamer for l4t only
Mar 23, 2022
846586d
apply good defauls for the tensorrt and change ffmpeg to decoder
Mar 30, 2022
e037bcf
fix the create_tensor_input cv2 resize
Apr 5, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build and run tests
run: make run_tests PLATFORM="linux/arm64/v8" ARCH="aarch64"
run: make run_tests PLATFORM="linux/arm64/v8" ARCH="aarch64" FFMPEG_ARCH="arm64"

docker_tests_on_amd64:
runs-on: ubuntu-latest
Expand All @@ -67,4 +67,4 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build and run tests
run: make run_tests PLATFORM="linux/amd64" ARCH="amd64"
run: make run_tests PLATFORM="linux/amd64" ARCH="amd64" FFMPEG_ARCH="amd64"
25 changes: 24 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,29 @@ aarch64_frigate: version web

aarch64_all: aarch64_wheels aarch64_ffmpeg aarch64_frigate

aarch64_l4t_assets:
mkdir -p $$(pwd)/.l4t_assets
cp ./converters/yolo4/plugin/* .l4t_assets/
cp ./converters/yolo4/model/yolov4-tiny-416.trt .l4t_assets/yolov4-tiny-416.trt
cp ./converters/yolo4/model/yolov4-tiny-288.trt .l4t_assets/yolov4-tiny-288.trt
# cp ./converters/yolo4/model/yolov4-416.trt .l4t_assets/yolov4-416.trt
# cp ./converters/yolo4/model/yolov4-288.trt .l4t_assets/yolov4-288.trt

aarch64_l4t_wheels:
@docker build --tag frigate-wheels-l4t --file docker/Dockerfile.wheels.l4t .
# Run l4t wheels using nvidia runtime
@docker rm frigate.wheels.l4t || true
@docker run --name frigate.wheels.l4t -it --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=all -e NVIDIA_DRIVER_CAPABILITIES=compute,utility,video --privileged frigate-wheels-l4t
# Commit changes to the container
@CONTAINER_ID=`docker ps -n 1 --format "{{.ID}}"`
@docker commit $$CONTAINER_ID frigate.wheels.l4t frigate-wheels-l4t:latest
@docker rm frigate.wheels.l4t || true

aarch64_l4t_frigate: # aarch64_l4t_wheels aarch64_l4t_assets
docker build --tag frigate-base-l4t --build-arg BASE_IMAGE=timongentzsch/l4t-ubuntu20-opencv:latest --build-arg FFMPEG_ARCH=arm64 --build-arg ARCH=aarch64 --build-arg WHEELS_VERSION=1.0.3 --build-arg NGINX_VERSION=1.0.2 --file docker/Dockerfile.base .
nvidia-docker build --tag frigate.l4t --build-arg NGINX_VERSION=1.0.2 --file docker/Dockerfile.aarch64.l4t .


armv7_wheels:
docker build --tag blakeblackshear/frigate-wheels:1.0.3-armv7 --file docker/Dockerfile.wheels .

Expand All @@ -68,7 +91,7 @@ run_tests:
@sed -i "s/FROM frigate-base/#/g" docker/Dockerfile.test
@echo "" >> docker/Dockerfile.test
@echo "RUN python3 -m unittest" >> docker/Dockerfile.test
@docker buildx build --platform=$(PLATFORM) --tag frigate-base --build-arg NGINX_VERSION=1.0.2 --build-arg FFMPEG_VERSION=1.0.0 --build-arg ARCH=$(ARCH) --build-arg WHEELS_VERSION=1.0.3 --file docker/Dockerfile.test .
@docker buildx build --platform=$(PLATFORM) --tag frigate-base --build-arg NGINX_VERSION=1.0.2 --build-arg FFMPEG_VERSION=1.0.0 --build-arg ARCH=$(ARCH) --build-arg FFMPEG_ARCH=$(FFMPEG_ARCH) --build-arg WHEELS_VERSION=1.0.3 --file docker/Dockerfile.test .
@rm docker/Dockerfile.test

.PHONY: web run_tests
10 changes: 10 additions & 0 deletions converters/ssd_mobilenet_v2_coco/Dockerfile.l4t.tf15
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM nvcr.io/nvidia/l4t-tensorflow:r32.6.1-tf1.15-py3

RUN apt-get update && apt-get install -y git sudo
RUN git clone https://github.com/jkjung-avt/tensorrt_demos.git /tensorrt_demos

ADD 0001-fix-trt.patch /tensorrt_demos/0001-fix-trt.patch
RUN cd /tensorrt_demos && \
git apply 0001-fix-trt.patch

ADD run.sh /run.sh
14 changes: 14 additions & 0 deletions converters/ssd_mobilenet_v2_coco/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

A build.sh file will convert pre-trained tensorflow Single-Shot Multibox Detector (SSD) models through UFF to TensorRT engine to do real-time object detection with the TensorRT engine.

Output will be copied to the ./model folder


Note:

This will consume pretty significant amound of memory. You might consider extending swap on Jetson Nano

Usage:

cd ./frigate/converters/ssd_mobilenet_v2_coco/
./build.sh
52 changes: 52 additions & 0 deletions converters/ssd_mobilenet_v2_coco/assets/0001-fix-trt.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
From 40953eaae8ca55838e046325b257faaff0bbe33f Mon Sep 17 00:00:00 2001
From: YS <ys@gm.com>
Date: Tue, 21 Dec 2021 21:01:35 +0300
Subject: [PATCH] fix trt

---
ssd/build_engine.py | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/ssd/build_engine.py b/ssd/build_engine.py
index 65729a9..e4a55c8 100644
--- a/ssd/build_engine.py
+++ b/ssd/build_engine.py
@@ -17,7 +17,6 @@ import uff
import tensorrt as trt
import graphsurgeon as gs

-
DIR_NAME = os.path.dirname(__file__)
LIB_FILE = os.path.abspath(os.path.join(DIR_NAME, 'libflattenconcat.so'))
MODEL_SPECS = {
@@ -286,19 +285,23 @@ def main():
text=True,
debug_mode=DEBUG_UFF)
with trt.Builder(TRT_LOGGER) as builder, builder.create_network() as network, trt.UffParser() as parser:
- builder.max_workspace_size = 1 << 28
+ config = builder.create_builder_config()
+ config.max_workspace_size = 1 << 28
builder.max_batch_size = 1
- builder.fp16_mode = True
+ config.set_flag(trt.BuilderFlag.FP16)

parser.register_input('Input', INPUT_DIMS)
parser.register_output('MarkOutput_0')
parser.parse(spec['tmp_uff'], network)
- engine = builder.build_cuda_engine(network)
+
+ plan = builder.build_serialized_network(network, config)
+
+ with trt.Runtime(TRT_LOGGER) as runtime:
+ engine = runtime.deserialize_cuda_engine(plan)

buf = engine.serialize()
with open(spec['output_bin'], 'wb') as f:
f.write(buf)

-
if __name__ == '__main__':
main()
--
2.17.1

6 changes: 6 additions & 0 deletions converters/ssd_mobilenet_v2_coco/assets/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
set -xe
cd /tensorrt_demos/ssd
./install.sh
python3 build_engine.py ssd_mobilenet_v2_coco
cp /tensorrt_demos/ssd/TRT_ssd_mobilenet_v2_coco.bin /model/TRT_ssd_mobilenet_v2_coco.bin
15 changes: 15 additions & 0 deletions converters/ssd_mobilenet_v2_coco/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

mkdir -p $(pwd)/model

docker build --tag models.ssd_v2_coco --file ./Dockerfile.l4t.tf15 ./assets/

sudo docker run --rm -it --name models.ssd_v2_coco \
--mount type=tmpfs,target=/tmp/cache,tmpfs-size=1000000000 \
-v $(pwd)/model:/model:rw \
-v /tmp/argus_socket:/tmp/argus_socket \
-e NVIDIA_VISIBLE_DEVICES=all \
-e NVIDIA_DRIVER_CAPABILITIES=compute,utility,video \
--runtime=nvidia \
--privileged \
models.ssd_v2_coco /run.sh
14 changes: 14 additions & 0 deletions converters/yolo4/Dockerfile.l4t.tf15
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM nvcr.io/nvidia/l4t-tensorflow:r32.6.1-tf1.15-py3

RUN apt-get update && apt-get install -y git sudo
RUN git clone https://github.com/jkjung-avt/tensorrt_demos.git /tensorrt_demos

RUN cd /tensorrt_demos/yolo && ./install_pycuda.sh
RUN apt-get update && apt-get install -y cmake build-essential unzip
ADD install_protobuf.sh /install_protobuf.sh
RUN /install_protobuf.sh
RUN pip3 install onnx==1.4.1
RUN cd /tensorrt_demos/yolo && ./download_yolo.sh
ADD run.sh /run.sh


45 changes: 45 additions & 0 deletions converters/yolo4/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Following the https://github.com/jkjung-avt/tensorrt_demos#demo-5-yolov4


A build.sh file will convert pre-trained yolov3 and yolov4 models through ONNX to TensorRT engines. The implementation with a "yolo_layer" plugin has been updated to speed up inference time of the yolov3/yolov4 models.

Current "yolo_layer" plugin implementation is based on TensorRT's IPluginV2IOExt. It only works for TensorRT 6+. "yolo_layer" developed plugin by referencing similar plugin code by wang-xinyu and dongfangduoshou123. So big thanks to both of them.


Output will be copied to the ./model folder



## Available models

| TensorRT engine | mAP @<br>IoU=0.5:0.95 | mAP @<br>IoU=0.5 | FPS on Nano |
|:------------------------|:---------------------:|:------------------:|:-----------:|
| yolov3-tiny-288 (FP16) | 0.077 | 0.158 | 35.8 |
| yolov3-tiny-416 (FP16) | 0.096 | 0.202 | 25.5 |
| yolov3-288 (FP16) | 0.331 | 0.601 | 8.16 |
| yolov3-416 (FP16) | 0.373 | 0.664 | 4.93 |
| yolov3-608 (FP16) | 0.376 | 0.665 | 2.53 |
| yolov3-spp-288 (FP16) | 0.339 | 0.594 | 8.16 |
| yolov3-spp-416 (FP16) | 0.391 | 0.664 | 4.82 |
| yolov3-spp-608 (FP16) | 0.410 | 0.685 | 2.49 |
| yolov4-tiny-288 (FP16) | 0.179 | 0.344 | 36.6 |
| yolov4-tiny-416 (FP16) | 0.196 | 0.387 | 25.5 |
| yolov4-288 (FP16) | 0.376 | 0.591 | 7.93 |
| yolov4-416 (FP16) | 0.459 | 0.700 | 4.62 |
| yolov4-608 (FP16) | 0.488 | 0.736 | 2.35 |
| yolov4-csp-256 (FP16) | 0.336 | 0.502 | 12.8 |
| yolov4-csp-512 (FP16) | 0.436 | 0.630 | 4.26 |
| yolov4x-mish-320 (FP16) | 0.400 | 0.581 | 4.79 |
| yolov4x-mish-640 (FP16) | 0.470 | 0.668 | 1.46 |


Please update frigate/converters/yolo4/assets/run.sh to add necessary models

Note:

This will consume pretty significant amound of memory. You might consider extending swap on Jetson Nano

Usage:

cd ./frigate/converters/yolo4/
./build.sh
45 changes: 45 additions & 0 deletions converters/yolo4/assets/install_protobuf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

set -e

folder=${HOME}/src
mkdir -p $folder

echo "** Install requirements"
sudo apt-get install -y autoconf libtool

echo "** Download protobuf-3.8.0 sources"
cd $folder
if [ ! -f protobuf-python-3.8.0.zip ]; then
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.8.0/protobuf-python-3.8.0.zip
fi
if [ ! -f protoc-3.8.0-linux-aarch_64.zip ]; then
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.8.0/protoc-3.8.0-linux-aarch_64.zip
fi

echo "** Install protoc"
unzip protobuf-python-3.8.0.zip
unzip protoc-3.8.0-linux-aarch_64.zip -d protoc-3.8.0
sudo cp protoc-3.8.0/bin/protoc /usr/local/bin/protoc

echo "** Build and install protobuf-3.8.0 libraries"
export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp
cd protobuf-3.8.0/
./autogen.sh
./configure --prefix=/usr/local
make -j$(nproc)
make check
sudo make install
sudo ldconfig

echo "** Update python3 protobuf module"
# remove previous installation of python3 protobuf module
sudo apt-get install -y python3-pip
sudo pip3 uninstall -y protobuf
sudo pip3 install Cython
cd python/
python3 setup.py build --cpp_implementation
python3 setup.py test --cpp_implementation
sudo python3 setup.py install --cpp_implementation

echo "** Build protobuf-3.8.0 successfully"
15 changes: 15 additions & 0 deletions converters/yolo4/assets/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

set -xe
cd /tensorrt_demos/plugins && make
cp /tensorrt_demos/plugins/libyolo_layer.so /plugin/libyolo_layer.so

cd /tensorrt_demos/yolo
for model in yolov4-tiny-288 \
yolov4-tiny-416 \
yolov4-288 \
yolov4-416 ; do
python3 yolo_to_onnx.py -m ${model}
python3 onnx_to_tensorrt.py -m ${model}
cp /tensorrt_demos/yolo/${model}.trt /model/${model}.trt
done
17 changes: 17 additions & 0 deletions converters/yolo4/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

mkdir -p $(pwd)/model
mkdir -p $(pwd)/plugin

docker build --tag models.yolo4 --file ./Dockerfile.l4t.tf15 ./assets/

sudo docker run --rm -it --name models.yolo4 \
--mount type=tmpfs,target=/tmp/cache,tmpfs-size=1000000000 \
-v $(pwd)/model:/model:rw \
-v $(pwd)/plugin:/plugin:rw \
-v /tmp/argus_socket:/tmp/argus_socket \
-e NVIDIA_VISIBLE_DEVICES=all \
-e NVIDIA_DRIVER_CAPABILITIES=compute,utility,video \
--runtime=nvidia \
--privileged \
models.yolo4 /run.sh
43 changes: 43 additions & 0 deletions docker/Dockerfile.aarch64.l4t
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FROM frigate-wheels-l4t:latest as wheelsl4t
FROM frigate-base-l4t
LABEL maintainer "blakeb@blakeshome.com"

COPY --from=wheelsl4t /wheels/. /wheels/

ENV DEBIAN_FRONTEND=noninteractive
# Install packages for apt repo
RUN apt-get -qq update \
&& apt-get -qq install --no-install-recommends -y \
git \
# ffmpeg runtime dependencies
libgomp1 \
# runtime dependencies
libopenexr24 \
libgstreamer1.0-0 \
libgstreamer-plugins-base1.0-0 \
libopenblas-base \
libjpeg-turbo8 \
libpng16-16 \
libtiff5 \
libdc1394-22 \
&& rm -rf /var/lib/apt/lists/* \
&& (apt-get autoremove -y; apt-get autoclean -y)

# Install tensorrt and pycuda
RUN pip3 install -U /wheels/*.whl

# Yolo4 model and plugins
ADD .l4t_assets /yolo4/

# s6-overlay
ADD https://github.com/just-containers/s6-overlay/releases/download/v2.2.0.3/s6-overlay-aarch64-installer /tmp/
RUN chmod +x /tmp/s6-overlay-aarch64-installer && /tmp/s6-overlay-aarch64-installer /

# Set up library path for the GStreamer
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/aarch64-linux-gnu/tegra

ENTRYPOINT ["/init"]

CMD ["python3", "-u", "-m", "frigate"]

COPY frigate frigate/
Loading