Baltic Robbo Battles 2021 – object detection and classification – next round

This time approach is different – to use ready-to use model on RaspberryPI and try to detect objects. I followed this tutorial:

https://pylessons.com/YOLOv3-TF2-RaspberryPi/

and this tutorial was also helpful during installation of TensorFlow on RaspberryPI: https://qengineering.eu/install-tensorflow-2.2.0-on-raspberry-pi-4.html

and here are my steps:

  1. install required components on RaspberryPI – Python 3.7.1 ,Tensorflow 2.2.0, Keras,OpenCV:
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt install python3-pip
pip3 install --upgrade pip
sudo apt-get install -y libhdf5-dev libc-ares-dev libeigen3-dev gcc gfortran python-dev libgfortran5 \
                          libatlas3-base libatlas-base-dev libopenblas-dev libopenblas-base libblas-dev \
                          liblapack-dev cython libatlas-base-dev openmpi-bin libopenmpi-dev python3-dev python3-venv
						  
sudo apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev libavcodec-dev libavformat-dev libswscale-dev libv4l-dev libxvidcore-dev libx264-dev qt4-dev-tools libatlas-base-dev
apt-get install libssl-dev
apt-get install make build-essential libssl-dev zlib1g-dev libbz2-dev libsqlite3-dev
sudo apt-get install libssl1.0
mkdir ~/libssl1.0-dev
cd ~/libssl1.0-dev
apt-get download libssl1.0-dev
ar x libssl1.0-dev* data.tar.xz
tar -xf data.tar.xz --strip-components=2


# Second, specifically get your current system's SSL headers
# and make symbolic-links

libcrypto=$(ls /usr/lib/arm-linux-gnueabihf/ | grep libcrypto.so......)
libssl=$(ls /usr/lib/arm-linux-gnueabihf/ | grep libssl.so......)

ln -s /usr/lib/arm-linux-gnueabihf/${libcrypto} ~/libssl1.0-dev/lib/x86_64-linux-gnu
ln -s /usr/lib/arm-linux-gnueabihf/${libssl} ~/libssl1.0-dev/lib/x86_64-linux-gnu

 
sudo pip3 install keras_applications==1.0.8 --no-deps
$ sudo pip3 install keras_preprocessing==1.1.0 --no-deps
$ sudo pip3 install h5py==2.9.0
$ sudo pip3 install pybind11
pip3 install -U --user six wheel mock

$ sudo -H pip3 install --upgrade setuptools
# install gdown to download from Google drive
$ pip3 install gdown
# copy binairy
$ sudo cp ~/.local/bin/gdown /usr/local/bin/gdown
# download the wheel
$ gdown https://drive.google.com/uc?id=11mujzVaFqa7R1_lB7q0kVPW22Ol51MPg
# install TensorFlow (± 63 min @1950 MHz)
sudo -H pip3 install tensorflow-2.2.0-cp37-cp37m-linux_armv7l.whl wrapt --upgrade --ignore-installed
apt-get install libstdc++6
sudo reboot

When I had environement installed – it took in my case 3h;(, I started playing with TensorFlow on RaspberryPI.

First of all check this:

>>> import tensorflow as tf
>>> print(tf.__version__)
2.2.0

Now download demo of YOLOv3 object detection using:

 git clone https://github.com/pythonlessons/TensorFlow-2.x-YOLOv3.git

Install additional dependencies (including pandas and numpy):

sudo pip3 install numpy>=1.18.2
sudo pip3 install scipy>=1.4.1
sudo pip3 install wget>=3.2
sudo pip3 install seaborn>=0.10.0
sudo pip3 install tqdm==4.43.0
sudo pip3 install pandas
sudo pip3 install awscli
sudo pip3 install urllib3
pip install opencv-python

Now I downloaded tiny weights of YOLOv3 model ( I have also RaspberryPI3):

# yolov3-tiny
wget -P model_data https://pjreddie.com/media/files/yolov3-tiny.weights

I have already Pico camera installed and which was installed acc. to this tutorial:

https://www.raspberrypi.org/documentation/configuration/camera.md

After running first demo I have following results as shown on the pictures:

This is exemplary image. As shown – people and kites are recognized very well.

Here is image from my camera – live view:

Dodaj komentarz

Twój adres e-mail nie zostanie opublikowany.