Skynet w/ Raspberry Pi: Conclusion

This is the FINAL 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

It seems odd to have an “introduction” in my conclusion post but I like to keep the format the same (I copy the previous post to create this one!). I will just talk about some high level issues and some other topics and then wrap this whole thing up.

Issues

I guess I will start with the issues that I had during this build.

SD Card

First, I don’t use SD cards very often so that caused some issues when the hardware bit caused my card to become read only. Had I known about this “feature” I would have been able to keep my 64GB card for future projects. It would have also allowed me to not get into the 32GB limit partition limitation.

ARM

Second, while I never thought about it I really should have known that the ARM processor would cause some issues. I guess my blind trust in PIP lead me to think it could do anything including ignoring the processor.

Thankfully, the python/TF community is awesome and someone did all the hard work for me and created a TF library that would run on the Pi.

Image Detection

My final issue was with the actual image detection. This was 100% on my and not the model. With my personal life getting crazier by the day thanks to a 3 year old I didn’t do all the research I would have liked. I really should have gone through the whitepaper and see what/how the model was trained. This would allow me to get a feel for what images I should expect to detect.

Future

Conferences

My immediate goal for this project was to use it to get into a few conferences. My first conference application was for KCDC and I have yet to hear back but I am assuming I won’t get in. My second was a repeat of last year with the Twin Cities Code Camp but their deadline was February 14th at midnight and I took that as the night of the 14th and not the morning so I was 8 hours late. I don’t know if I will try and get back out to Denver again this year or not.

I decided that if I don’t get into any conferences this year I will put that part of my life on hold. The travel was interesting but with a young family it wasn’t worth going so far away. Maybe in a few years I will try and pick it back up.

Custom Training

As far as the project goes, I would like to do some custom training and see if it could pick out members of my family or something along those lines. I do have FishButler in the Google Play Store that could use some fish detection.

Conclusion

Conclusion to by conclusion post! Turtles all the way down.

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

Skynet w/ Raspberry Pi: MobileNetV2

This is the seventh 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 MobileNetV2. This is a built in model in Keras that with a single setting I can have it be fully trained on ImageNet.

ImageNet

Using this model pre-trained on ImageNet couldn’t be any easier. I just set the ‘weights’ parameter to ‘ImageNet’ and I am off and running. It did take me some time to figure out WHAT images were used based on the labels but after that it was easy as can be.

Conclusion

Not much in this post since it was so simple!

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

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