mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-02 09:15:22 +03:00
add converter to generate yolo4 models
This commit is contained in:
parent
7af0e81e9f
commit
0f0b217a56
14
converters/yolo4/Dockerfile.l4t.tf15
Normal file
14
converters/yolo4/Dockerfile.l4t.tf15
Normal file
@ -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
converters/yolo4/README.md
Normal file
45
converters/yolo4/README.md
Normal file
@ -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
converters/yolo4/assets/install_protobuf.sh
Executable file
45
converters/yolo4/assets/install_protobuf.sh
Executable file
@ -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"
|
||||||
14
converters/yolo4/assets/run.sh
Executable file
14
converters/yolo4/assets/run.sh
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -xe
|
||||||
|
cd /tensorrt_demos/plugins && make
|
||||||
|
|
||||||
|
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
|
||||||
15
converters/yolo4/build.sh
Executable file
15
converters/yolo4/build.sh
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
mkdir -p $(pwd)/model
|
||||||
|
|
||||||
|
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 /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
|
||||||
Loading…
Reference in New Issue
Block a user