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.

Raspberry Pi 4 or 5 Computer & Camera

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 really need a Pi 4 or better, TensorFlow vision recognition will not run on anything slower!
Angled shot of green Raspberry Pi 5 microcontroller.
The Raspberry Pi 5 is the newest Raspberry Pi computer, and the Pi Foundation knows you can always make a good thing better! And what could make the Pi 5 better than the...
Angled shot of Raspberry Pi 4
The Raspberry Pi 4 Model B is the newest Raspberry Pi computer made, and the Pi Foundation knows you can always make a good thing better! And what could make the Pi 4 better...

You will need a camera for the Raspberry Pi to see with.

Overhead shot of green, square camera module with cable.
Raspberry Pi Camera Module 3 is a compact camera from Raspberry Pi. Featuring autofocus and a 12-megapixel sensor, and supported by Raspberry Pi's Picamera2 Python library, Camera...
Angled shot of Raspberry Pi Camera Board v2 - 8 Megapixels connected to a flex cable and a Raspberry Pi.
Snap, snap! The Camera v2 is the new official camera board released by the Raspberry Pi Foundation!The Raspberry Pi Camera Board v2 is a high quality 8...

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.

Angled shot of Raspberry Pi 5 connected to HQ camera.
This 200mm long camera cable is specifically designed to work with the Raspberry Pi 5 series. Just...

All-in One BrainCraft HAT

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.

Video of a white hand hovering a coffe mug over a Adafruit BrainCraft HAT thats connected to a Raspberry Pi 4. Display detects that its a coffee mug.
The idea behind the BrainCraft HAT is that you’d be able to “craft brains” for Machine Learning on the EDGE, with Microcontrollers & Microcomputers. On ASK...

Display Output

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.

Top down view of a white hand touching the display of a PiTFT - Assembled 480x320 3.5" TFT+Touchscreen for Raspberry Pi.
Is this not the cutest, little display for the Raspberry Pi? It features a 3.5" display with 480x320 16-bit color pixels and a resistive touch overlay so is...

But our other PiTFT's will also work just fine

Pink polished finger touching the screen of a PiTFT Plus 320x240 3.2" TFT + Resistive Touchscreen.
Is this not the cutest little display for the Raspberry Pi? It features a 3.2" display with 320x240 16-bit color pixels and a resistive touch overlay. The plate uses the high...
Red polished white finger touching the PiTFT Plus Assembled 320x240 2.8" TFT + Resistive Touchscreen.
Is this not the cutest little display for the Raspberry Pi? It features a 2.8" display with 320x240 16-bit color pixels and a resistive touch overlay. The plate uses the high...
Black polished white finger touching Adafruit PiTFT 2.4" HAT display in a Adafruit PiTFT 2.4" HAT Mini Kit.
Is this not the cutest little display for the Raspberry Pi? It features a 2.4" display with 320x240 16-bit color pixels and a resistive touch overlay. The HAT uses the high speed...
Top down view of a Adafruit PiTFT 2.2" HAT Mini Kit with desktop image on the display.
The cute PiTFT got even more adorable with this little primary display for Raspberry Pi in HAT form! It features a 2.2" display with 320x240 16-bit color pixels. The HAT uses the...

Cooling It Down

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

Miniature 5V Cooling Fan for Raspberry Pi and Other Computers
Looking for another way to keep your Raspberry Pi cool? Hook up this 5V Mini Cooling...

Or if you have the Pi 5, you can use an official cooler.

Angled shot of a cooling fan installed on a green microcontroller.
The Raspberry Pi 5 Active Cooler is compatible with the Raspberry Pi 5 and the

Or tall heatsink

Square aluminum heat sink with 20 fins
Looking for the best heat sink for your Raspberry Pi? Check out this nice and tall 15x15x15mm Heat...

In order to fit the fan/heatsink along with the display, you will need a GPIO stacking header.

GPIO Stacking Header for Pi A+/B+/Pi 2/Pi 3
Connect your own PCB to a Raspberry Pi B+ and stack on top with this normal-height female header with extra long pins.  The female header part is about 8.5mm tall, good for small...

Longer Camera Cable

The flex cable that comes with the camera is a bit on the short side, so you may want a longer cable as well.

angled shot of green, credit-card-sized microcontroller connected via a 500mm long FPC ribbon cable to a camera module.
This 500mm long camera cable is specifically designed to work with the Raspberry Pi 5 series. Just plug...
Angled shot of Flex Cable for Raspberry Pi Camera or Display - 24" / 610mm.
This cable will let you swap out the stock 150mm long flex cable from a Raspberry Pi Camera (either 'classic' or 'NoIR' type) or Raspberry Pi Display for a...
Angled shot of Flex Cable for Raspberry Pi Camera or Display - 18" / 457mm.
This cable will let you swap out the stock 150mm long flex cable from a Raspberry Pi Camera (either 'classic' or 'NoIR' type) or Raspberry Pi Display for a different...

This guide was first published on Sep 04, 2019. It was last updated on Mar 08, 2024.

This page (Overview) was last updated on Mar 08, 2024.

Text editor powered by tinymce.