Skynet w/ Raspberry Pi: TensorFlow

This is the sixth part in a multiple part series on adding some object detection to my Raspberry Pi.

Part 1: Introduction
Part 2: SD Card Setup
Part 3: Pi Install
Part 4: Software
Part 5: Raspberry Pi Camera
Part 6: Installing TensorFlow
Part 7: MobileNetV2
Part 8: Conclusion

Introduction

In this section I will go through the issues that I had while trying to install TFv2. It all comes down to the version of pip NOT recognizing the manylinux2010 tag that comes with TFv2.

Limitations

The issue comes up because TF requires pip version 19 or above so that it will recognize the manylinux20010 tag that is on the wheel download.

PIP

Manually trying to install the latest (20) version of pip causes all sorts of issues as mentioned here.

I was lucky enough to find this post about being able to upgrade pip in a virtual environment. So, that is what I did.

Virtual Environment

  • Created the virtual environment: python3 -m venv /home/pi/venv
  • Activated the environment: source /home/pi/venv/bin/activate
  • Checked pip to see that I was still on version 18: pip --version
  • Upgraded to the latest version: pip install --upgrade pip

And…. it still didn’t find it. So, I went to PyPi and downloaded the cp37 whl file and renamed it from ‘manylinux2010’ to ‘manylinux1’ which IS supported.

Still didn’t work. It turns out TF isn’t build for the ARM processors yet.

ARM TensorFlow

Since I needed to find a TF install I reached out and Leigh came to the rescue. She had a repo that she forked that had a whl file I could use. I downloaded that file and then ran an install off of it.

After all of the my next issue was the error 'load_weights' requires h5py when loading weights from HDF5.

H5PY

To solve my current issue I needed to go to the PIWheel site and install from there.

Conclusion

This project has gotten a little larger than I thought. I will continue to work through some errors and hopefully get something up and running.

Code: https://github.com/ehennis/Blog/tree/master/ImageDetection

Skynet w/ Raspberry Pi: PiCamera

This is the fifth part in a multiple part series on adding some object detection to my Raspberry Pi.

Part 1: Introduction
Part 2: SD Card Setup
Part 3: Pi Install
Part 4: Software
Part 5: Raspberry Pi Camera
Part 6: Installing TensorFlow
Part 7: MobileNetV2
Part 8: Conclusion

Introduction

In this section I will cover getting your camera all set up and running. I will be following this guide.

Camera Connection

After connecting the cable I had to go into the ‘Preferences’ and then ‘Raspberry Pi Configuration’ menu. At that point, go to the ‘Interfaces’ tab and make sure ‘Camera’ is Enabled.

After a reboot, I was able to use the command lines raspistill and raspivid to take pictures/videos of my daughter I knew everything was hooked up right.

Python Integration

Testing the code in Python is as simple as importing the camera using from picamera import PiCamera. Using that we can call camera.start_preview() and .stop_preview(). One thing to note is that since I am on VNC I won’t actually see the preview. But, I am still able to call camera.capture to validate that I can save an image.

Conclusion

Well, that is another short post about getting everything ready. I am sure I will have more changes once I get the model picked out and see what I need to change in order to feed in the input.

Code: https://github.com/ehennis/Blog/tree/master/ImageDetection

Skynet w/ Rapberry Pi: Software

This is the fourth entry in my 8 part series on adding some object detection to my Raspberry Pi.

Part 1: Introduction
Part 2: SD Card Setup
Part 3: Pi Install
Part 4: Software
Part 5: Raspberry Pi Camera
Part 6: Installing TensorFlow
Part 7: MobileNetV2
Part 8: Conclusion

Introduction

In this section I am going to cover the “other” parts of the Pi installation that I need. This will include some preferences as well as getting python up and running.

Personal Preferences

First, I am going to primarily develop on the Pi using VNC. In my last post, I talked about getting VNC access. While it works out of the box it is less than ideal when your screen resolution is the size of a note card. To change the default resolution:

  • Run sudo raspi-config to have the Pi settings come up
  • Navigate to **Advanced Options**
  • Resolution

From here you can change to whatever you like. I did 1024×720 since that is plenty big. Just know that the higher the resolution the more the Pi has to work.

Python Installation

While python is installed I will need to add some updates. I am using the guide from Raspberry Pi here. After running sudo apt update I am able to download the Python3 camera library using sudo apt install python3-picamera. Based on your install of the OS this might already be ready.

RaspberryPi comes with Thonny for an IDE if you want to go that route. I am undecided how I will go about doing all of this work. It will probably be a combination of local development, Thonny on the Pi, and some command line work.

I did have to install TensorFlow v2. To do that I went into the Tools menu of Thonny and searching PyPi for ‘Tensorflow’. It found v2.1.0 and as I tried to install it there was a message about only seeing versions 1.14 and below. This is because of an issue with the ARM processor that is running on the Pi. I explain in part 5 in more detail but I was able to find an ARM built whl.

Conclusion

This was another short post but there were a few additions that I wanted to add to my previous post that didn’t really fit in.

My next post will be setting up the camera. This will include hooking up the hardware as well as writing a little bit of test code.

Code: https://github.com/ehennis/Blog/tree/master/ImageDetection