Before you begin

To work through this guide, you need the following:

  • A Raspberry Pi 3 or 4 device. This guide was developed using a Raspberry Pi 4 with Raspbian 10 OS.
  • On your Raspberry Pi:

    • You must check out and build Arm NN version 20.05 or newer for your Raspberry Pi.
    • You must install the PyArmNN package.

      Note: The Read Me, contains useful information. You must have SWIG installed.

      Note: For complete and up-to-date installation information, always refer to the previous README links. However, for your convenience, at the end of this section we provide a list of the commands we used to install Arm NN and PyArmNN.

  • On your computer:

    • You must have fire_detection.tflite, generated from this guide and converted to a TensorFlow Lite model.
    • To convert your file to TensorFlow Lite model, use the following code:

      tflite_convert \
      --output_file=/tmp/fire_detection.tflite  \

      Note: You must convert your file to a tflite model on a machine running Windows or Linux.

      Note: This Git hub repository has already converted the TensorFlow Lite model.

The following code builds Arm NN and installs PyArmNN:

  • Code to build Arm NN and install PyArmNN
    # Increase virtual memory swapfile allocation
    sudo vi /etc/dphys-swapfile
    # Find the following line:
    #    CONF_SWAPSIZE=100
    # Change this line to:
    #    CONF_SWAPSIZE=1024
    sudo /etc/init.d/dphys-swapfile stop
    sudo /etc/init.d/dphys-swapfile start
    # Install SCONS and CMAKE
    sudo apt-get update
    sudo apt-get install scons
    sudo apt-get install cmake
    mkdir armnn-tflite && cd armnn-tflite
    export BASEDIR=`pwd`
    git clone
    git clone
    tar xf boost_1_64_0.tar.bz2
    git clone -b v3.5.0
    git clone
    cd tensorflow/
    git checkout 590d6eef7e91a6a7392c8ffffb7b58f2e0c8bc6b
    git clone
    cd $BASEDIR/ComputeLibrary
    scons extra_cxx_flags="-fPIC" benchmark_tests=0 validation_tests=0 neon=1
    cd $BASEDIR/boost_1_64_0
    ./b2 --build-dir=$BASEDIR/boost_1_64_0/build toolset=gcc link=static cxxflags=-fPIC --with-filesystem --with-test --with-log --with-program_options install --prefix=$BASEDIR/boost
    cd $BASEDIR/protobuf
    git submodule update --init --recursive
    sudo apt-get install autoconf
    sudo apt-get install libtool
    ./configure --prefix=$BASEDIR/protobuf-host
    make install
    cd $BASEDIR/tensorflow
    ../armnn/scripts/ ../tensorflow-protobuf ../protobuf-host
    cd $BASEDIR
    git clone
    cd $BASEDIR/flatbuffers
    cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release
    #Install SWIG
    sudo apt-get install libpcre3 libpcre3-dev
    cd $BASEDIR
    mkdir swig
    cd swig
    chmod 777 swig-4.0.2.tar.gz
    tar -xzvf swig-4.0.2.tar.gz
    cd swig-4.0.2/
    ./configure --prefix=/home/pi/armnn-tflite/swigtool/
    sudo make
    sudo make install
    sudo vi /etc/profile
    # Add the following lines to /etc/profile
    #   export SWIG_PATH=/home/pi/armnn-tflite/swigtool/bin
    #   export PATH=$SWIG_PATH:$PATH
    source /etc/profile
    # Build Arm NN
    cd $BASEDIR/armnn
    mkdir build
    cd build
    cp $BASEDIR/armnn/build/*.so $BASEDIR/armnn/
    cd /home/pi/armnn-tflite/armnn/src/dynamic/sample
    mkdir build
    cd build
    cmake -DBOOST_ROOT=$BASEDIR/boost  -DBoost_SYSTEM_LIBRARY=$BASEDIR/boost/lib/libboost_system.a -DBoost_FILESYSTEM_LIBRARY=$BASEDIR/boost/lib/libboost_filesystem.a -DARMNN_PATH=$BASEDIR/armnn/ ..
    # Install PYARMNN
    # Following instructions for "Standalone build" from:
    export SWIG_EXECUTABLE=$BASEDIR/swigtool/bin/swig
    export ARMNN_INCLUDE=$BASEDIR/armnn/include/
    export ARMNN_LIB=$BASEDIR/armnn/build/
    cd $BASEDIR/armnn/python/pyarmnn
    sudo apt-get install python3.6-dev build-essential checkinstall libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
    python3 clean --all
    python3 -v
    python3 build_ext --inplace
    python3 sdist
    python3 bdist_wheel
    pip3 install dist/pyarmnn-21.0.0-cp37-cp37m-linux_armv7l.whl 
    sudo pip3 install opencv-python== 
    sudo apt-get install libcblas-dev
    sudo apt-get install libhdf5-dev
    sudo apt-get install libhdf5-serial-dev
    sudo apt-get install libatlas-base-dev
    sudo apt-get install libjasper-dev 
    sudo apt-get install libqtgui4 
    sudo apt-get install libqt4-test
Previous Next