Darknet with NNPACK

May 15, 2020 ยท View on GitHub

NNPACK was used to optimize AlexeyAB/darknet without using a GPU. It is useful for embedded devices using ARM CPUs.

Build from Raspberry Pi 4

Log in to Raspberry Pi using SSH.
Install PeachPy and confu

sudo pip install --upgrade git+https://github.com/Maratyszcza/PeachPy
sudo pip install --upgrade git+https://github.com/Maratyszcza/confu

Install Ninja

git clone https://github.com/ninja-build/ninja.git
cd ninja
git checkout release
./configure.py --bootstrap
export NINJA_PATH=$PWD

Install clang

sudo apt-get install clang

Install NNPACK-darknet

git clone https://github.com/digitalbrain79/NNPACK-darknet.git
cd NNPACK-darknet
confu setup
python ./configure.py --backend auto
$NINJA_PATH/ninja
sudo cp -a lib/* /usr/lib/
sudo cp include/nnpack.h /usr/include/
sudo cp deps/pthreadpool/include/pthreadpool.h /usr/include/

Build darknet-nnpack

git clone https://github.com/digitalbrain79/darknet-nnpack.git
cd darknet-nnpack
make

Test

COCO trained weights files can be downloaded from the AlexeyAB/darknet.

COCO
./darknet detector test cfg/coco.data [cfg file] [weights file] [image path]
Pascal VOC
./darknet detector test cfg/voc.data [cfg file] [weights file] [image path]

Results

COCO

cfgBuild OptionsmAPPrediction Time (seconds)
yolov3-tiny.cfgNNPACK=133.11.1
yolov3-tiny.cfgNNPACK=014.5
yolov3-tiny-prn.cfgNNPACK=133.10.86
yolov3-tiny-prn.cfgNNPACK=09.3

Pascal VOC

cfgBuild OptionsmAPPrediction Time (seconds)Weights file
yolov3-tiny-voc.cfgNNPACK=165.91.0yolov3-tiny-voc.weights
yolov3-tiny-voc.cfgNNPACK=014.0
yolov3-tiny-prn-voc.cfgNNPACK=165.20.77yolov3-tiny-prn-voc.weights
yolov3-tiny-prn-voc.cfgNNPACK=08.9
Gaussian_yolov3-tiny-voc.cfgNNPACK=165.71.0Gaussian_yolov3-tiny-voc.weights

Raspberry Pi OS Image

Download OS image from here

sudo dd bs=4M if=darknet-nnpack.img of=/dev/sdX conv=fsyn