Want to up your robotics game and give it the ability to detect objects? Maybe implement a security camera that can see and identify certain items? Now that the Raspberry Pi is fast enough to do machine learning, adding these features is fairly straightforward.
This guide will show you the steps to get TensorFlow 2 installed on your Raspberry Pi 4 or 5 and perform some object detection using the TensorFlow Lite Python Interpreter, which is faster than the full TensorFlow interpreter.
There are two main setup paths to choose from. The first option is with a PiTFT if you want to have a larger display. The second option is with the BrainCraft HAT, which has a built-in display and audio along several other components such as DotStar LEDs, a Joystick, and ports.
To start with, you will need a Raspberry Pi 4 or 5. Since TensorFlow object detection is processing intensive, you should use at least the 4GB model.
You will need a camera for the Raspberry Pi to see with.
For the Raspberry Pi 5, you will also need a camera cable, which has a different size than the one that comes with the camera.
If you want to get a HAT that has everything you need besides the camera including display, sound, and cooling, you'll want to pick up the BrainCraft HAT.
You will also need a display so you can see what it's detecting. You can use any of our displays with the Raspberry Pi, but the 3.5" display is Adafruit's biggest.
But our other PiTFT's will also work just fine
The Raspberry Pi 4 can run a little hot, especially when TensorFlow is doing a lot of data crunching. If you don't have the BrainCraft hat with the built-in fan, we recommend the Pimoroni Fan SHIM.
Or this mini 5V fan
Or if you have the Pi 5, you can use an official cooler.
Or tall heatsink
In order to fit the fan/heatsink along with the display, you will need a GPIO stacking header.
The flex cable that comes with the camera is a bit on the short side, so you may want a longer cable as well.