# Running TensorFlow Lite Object Recognition on the Raspberry Pi 4 or Pi 5

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/080/374/medium800/camera_guide_image.jpg?1567552337)

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.

Warning: 

### Raspberry Pi 5 - 4 GB RAM

[Raspberry Pi 5 - 4 GB RAM](https://www.adafruit.com/product/5812)
The Raspberry Pi 5&nbsp;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 4? How about a&nbsp;_faster_ processor, USB 3.0 ports, and an updated Gigabit Ethernet chip with PoE...

In Stock
[Buy Now](https://www.adafruit.com/product/5812)
[Related Guides to the Product](https://learn.adafruit.com/products/5812/guides)
![Angled shot of green Raspberry Pi 5 microcontroller.](https://cdn-shop.adafruit.com/640x480/5812-01.jpg)

### Raspberry Pi 4 Model B - 4 GB RAM

[Raspberry Pi 4 Model B - 4 GB RAM](https://www.adafruit.com/product/4296)
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 than the 3? How about a&nbsp;_faster_ processor, USB 3.0 ports, and updated Gigabit Ethernet chip with...

Out of Stock
[Buy Now](https://www.adafruit.com/product/4296)
[Related Guides to the Product](https://learn.adafruit.com/products/4296/guides)
![Angled shot of Raspberry Pi 4](https://cdn-shop.adafruit.com/640x480/4296-11.jpg)

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

### Raspberry Pi Camera Module 3 Standard

[Raspberry Pi Camera Module 3 Standard](https://www.adafruit.com/product/5657)
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 Module 3 gives you excellent image quality with precise control.

**Camera Module 3 Standard...**

In Stock
[Buy Now](https://www.adafruit.com/product/5657)
[Related Guides to the Product](https://learn.adafruit.com/products/5657/guides)
![Angled shot of camera module assembled onto a Raspberry Pi 4 computer.](https://cdn-shop.adafruit.com/640x480/5657-04.jpg)

### Raspberry Pi Camera Board v2 - 8 Megapixels

[Raspberry Pi Camera Board v2 - 8 Megapixels](https://www.adafruit.com/product/3099)
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 megapixel Sony IMX219 image sensor custom designed add-on board for Raspberry Pi, featuring a fixed focus lens....

In Stock
[Buy Now](https://www.adafruit.com/product/3099)
[Related Guides to the Product](https://learn.adafruit.com/products/3099/guides)
![Angled shot of Raspberry Pi Camera Board v2 - 8 Megapixels connected to a flex cable and a Raspberry Pi.](https://cdn-shop.adafruit.com/640x480/3099-02.jpg)

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.

### Raspberry Pi 5 FPC Camera Cable - 22-pin 0.5mm to 15-pin 1mm

[Raspberry Pi 5 FPC Camera Cable - 22-pin 0.5mm to 15-pin 1mm](https://www.adafruit.com/product/5818)
This&nbsp; **200mm&nbsp;long** &nbsp; **camera cable** &nbsp;is specifically designed to work with the&nbsp; **Raspberry Pi 5** &nbsp;series.&nbsp;Just plug it into your Pi 5's camera port and then the other end into one of the official&nbsp;<a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/5818)
[Related Guides to the Product](https://learn.adafruit.com/products/5818/guides)
![Angled shot of Raspberry Pi 5 connected to HQ camera.](https://cdn-shop.adafruit.com/640x480/5818-04.jpg)

## 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.

### Adafruit BrainCraft HAT - Machine Learning for Raspberry Pi 4

[Adafruit BrainCraft HAT - Machine Learning for Raspberry Pi 4](https://www.adafruit.com/product/4374)
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&nbsp;ASK AN ENGINEER, our founder & engineer chatted with&nbsp;Pete Warden, the technical lead of the mobile,...

In Stock
[Buy Now](https://www.adafruit.com/product/4374)
[Related Guides to the Product](https://learn.adafruit.com/products/4374/guides)
![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. ](https://cdn-shop.adafruit.com/product-videos/640x480/4374-00.jpg)

## 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.

### PiTFT - Assembled 480x320 3.5" TFT+Touchscreen for Raspberry Pi

[PiTFT - Assembled 480x320 3.5" TFT+Touchscreen for Raspberry Pi](https://www.adafruit.com/product/2097)
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 slightly larger than [our popular original](https://www.adafruit.com/product/1601). The plate uses the...

Out of Stock
[Buy Now](https://www.adafruit.com/product/2097)
[Related Guides to the Product](https://learn.adafruit.com/products/2097/guides)
![Top down view of a white hand touching the display of a PiTFT - Assembled 480x320 3.5" TFT+Touchscreen for Raspberry Pi.](https://cdn-shop.adafruit.com/640x480/2097-05.jpg)

But our other PiTFT's will also work just fine

### PiTFT Plus 320x240 3.2" TFT + Resistive Touchscreen

[PiTFT Plus 320x240 3.2" TFT + Resistive Touchscreen](https://www.adafruit.com/product/2616)
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&nbsp;touch overlay. The plate uses the high speed SPI interface on the Pi and can use the mini display as a console, X window port, displaying images or...

Out of Stock
[Buy Now](https://www.adafruit.com/product/2616)
[Related Guides to the Product](https://learn.adafruit.com/products/2616/guides)
![Pink polished finger touching the screen of a PiTFT Plus 320x240 3.2" TFT + Resistive Touchscreen. ](https://cdn-shop.adafruit.com/640x480/2616-00.jpg)

### PiTFT Plus Assembled 320x240 2.8" TFT + Resistive Touchscreen

[PiTFT Plus Assembled 320x240 2.8" TFT + Resistive Touchscreen](https://www.adafruit.com/product/2298)
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&nbsp;touch overlay. The plate uses the high speed SPI interface on the Pi and can use the mini display as a console, X window port, displaying images or...

Out of Stock
[Buy Now](https://www.adafruit.com/product/2298)
[Related Guides to the Product](https://learn.adafruit.com/products/2298/guides)
![Red polished white finger touching the PiTFT Plus Assembled 320x240 2.8" TFT + Resistive Touchscreen. ](https://cdn-shop.adafruit.com/640x480/2298-16.jpg)

### Adafruit PiTFT 2.4" HAT Mini Kit - 320x240 TFT Touchscreen

[Adafruit PiTFT 2.4" HAT Mini Kit - 320x240 TFT Touchscreen](https://www.adafruit.com/product/2455)
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 SPI interface on the Pi and can use the mini display as a console, X window port, displaying images or video...

Out of Stock
[Buy Now](https://www.adafruit.com/product/2455)
[Related Guides to the Product](https://learn.adafruit.com/products/2455/guides)
![Black polished white finger touching Adafruit PiTFT 2.4" HAT display in a Adafruit PiTFT 2.4" HAT Mini Kit.](https://cdn-shop.adafruit.com/640x480/2455-08.jpg)

### Adafruit PiTFT 2.2" HAT Mini Kit - 320x240 2.2" TFT - No Touch

[Adafruit PiTFT 2.2" HAT Mini Kit - 320x240 2.2" TFT - No Touch](https://www.adafruit.com/product/2315)
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 high-speed SPI interface on the Pi and can use the mini display as a console, X window port, displaying images...

In Stock
[Buy Now](https://www.adafruit.com/product/2315)
[Related Guides to the Product](https://learn.adafruit.com/products/2315/guides)
![Top down view of a Adafruit PiTFT 2.2" HAT Mini Kit with desktop image on the display. ](https://cdn-shop.adafruit.com/640x480/2315-04.jpg)

## 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)

[Miniature 5V Cooling Fan for Raspberry Pi (and Other Computers)](https://www.adafruit.com/product/3368)
Looking for another way to keep your [Raspberry Pi](https://www.adafruit.com/products/3055)&nbsp;_cool_? Hook up this&nbsp; **5V Mini Cooling Fan** &nbsp;and prevent your hard-working Pi from overheating! Of course, it's also great for use with any small...

In Stock
[Buy Now](https://www.adafruit.com/product/3368)
[Related Guides to the Product](https://learn.adafruit.com/products/3368/guides)
![Miniature 5V Cooling Fan for Raspberry Pi and Other Computers](https://cdn-shop.adafruit.com/640x480/3368-00.jpg)

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

### Official Raspberry Pi 5 Active Cooler

[Official Raspberry Pi 5 Active Cooler](https://www.adafruit.com/product/5815)
The **Raspberry Pi 5 Active Cooler** is compatible with the [Raspberry Pi 5](https://www.adafruit.com/search?q=raspberry+pi+5) and the [Raspberry Pi 5 Case](http://www.adafruit.com/product/5816). Designed for anyone who wants to push the performance of their...

In Stock
[Buy Now](https://www.adafruit.com/product/5815)
[Related Guides to the Product](https://learn.adafruit.com/products/5815/guides)
![Angled shot of a cooling fan installed on a green microcontroller.](https://cdn-shop.adafruit.com/640x480/5815-04.jpg)

Or tall heatsink

### Aluminum Heat Sink for Raspberry Pi 3 or 4 - 15 x 15 x 15mm

[Aluminum Heat Sink for Raspberry Pi 3 or 4 - 15 x 15 x 15mm](https://www.adafruit.com/product/3082)
Looking for the best heat sink for your [Raspberry Pi](https://www.adafruit.com/products/3055)? Check out this nice and tall **15x15x15mm Heat Sink!**

This heat sink is made from high quality aluminum and will work perfectly with any <a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/3082)
[Related Guides to the Product](https://learn.adafruit.com/products/3082/guides)
![Square aluminum heat sink with 20 fins](https://cdn-shop.adafruit.com/640x480/3082-05.jpg)

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

[GPIO Stacking Header for Pi A+/B+/Pi 2/Pi 3](https://www.adafruit.com/product/2223)
Connect your own PCB to a Raspberry Pi B+ and stack on top with this normal-height female header with extra long pins. &nbsp;The female header part is about 8.5mm tall, good for small HATs that do not to clear the USB/Ethernet jacks. This header has extra long 10mm pins, compared with our <a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/2223)
[Related Guides to the Product](https://learn.adafruit.com/products/2223/guides)
![Angled top shot of the 2x20 extra tall socket header.](https://cdn-shop.adafruit.com/640x480/2223-08.jpg)

## 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.

### Raspberry Pi 5 FPC Camera Cable - 22-pin 0.5mm to 15-pin 1mm

[Raspberry Pi 5 FPC Camera Cable - 22-pin 0.5mm to 15-pin 1mm](https://www.adafruit.com/product/5820)
This **500mm&nbsp;long** &nbsp; **camera cable** &nbsp;is specifically designed to work with the&nbsp; **Raspberry Pi 5** &nbsp;series.&nbsp;Just plug it into your Pi 5's camera port and then the other end into one of the official&nbsp;<a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/5820)
[Related Guides to the Product](https://learn.adafruit.com/products/5820/guides)
![angled shot of green, credit-card-sized microcontroller connected via a 500mm long FPC ribbon cable to a camera module.](https://cdn-shop.adafruit.com/640x480/5820-03.jpg)

### Flex Cable for Raspberry Pi Camera or Display - 24" / 610mm

[Flex Cable for Raspberry Pi Camera or Display - 24" / 610mm](https://www.adafruit.com/product/1731)
This cable will let you swap out the stock 150mm long flex cable from a Raspberry Pi Camera (either 'classic' or 'NoIR' type)&nbsp;or Raspberry Pi Display for a different size. Works great, just carefully open the connector on the Pi and slip this one in.  
  
This cable...

In Stock
[Buy Now](https://www.adafruit.com/product/1731)
[Related Guides to the Product](https://learn.adafruit.com/products/1731/guides)
![Angled shot of Flex Cable for Raspberry Pi Camera or Display - 24" / 610mm.](https://cdn-shop.adafruit.com/640x480/1731-04.jpg)

### Flex Cable for Raspberry Pi Camera or Display - 18" / 457mm

[Flex Cable for Raspberry Pi Camera or Display - 18" / 457mm](https://www.adafruit.com/product/1730)
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 size. Works great, just carefully open the connector on the Pi and slip this one in.  
  
This cable is...

In Stock
[Buy Now](https://www.adafruit.com/product/1730)
[Related Guides to the Product](https://learn.adafruit.com/products/1730/guides)
![Angled shot of Flex Cable for Raspberry Pi Camera or Display - 18" / 457mm.](https://cdn-shop.adafruit.com/640x480/1730-03.jpg)

- [Next Page](https://learn.adafruit.com/running-tensorflow-lite-on-the-raspberry-pi-4/initial-setup.md)

## Featured Products

### Raspberry Pi 4 Model B - 4 GB RAM

[Raspberry Pi 4 Model B - 4 GB RAM](https://www.adafruit.com/product/4296)
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 than the 3? How about a&nbsp;_faster_ processor, USB 3.0 ports, and updated Gigabit Ethernet chip with...

Out of Stock
[Buy Now](https://www.adafruit.com/product/4296)
[Related Guides to the Product](https://learn.adafruit.com/products/4296/guides)
### Raspberry Pi Camera Board v2 - 8 Megapixels

[Raspberry Pi Camera Board v2 - 8 Megapixels](https://www.adafruit.com/product/3099)
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 megapixel Sony IMX219 image sensor custom designed add-on board for Raspberry Pi, featuring a fixed focus lens....

In Stock
[Buy Now](https://www.adafruit.com/product/3099)
[Related Guides to the Product](https://learn.adafruit.com/products/3099/guides)
### Adafruit BrainCraft HAT - Machine Learning for Raspberry Pi 4

[Adafruit BrainCraft HAT - Machine Learning for Raspberry Pi 4](https://www.adafruit.com/product/4374)
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&nbsp;ASK AN ENGINEER, our founder & engineer chatted with&nbsp;Pete Warden, the technical lead of the mobile,...

In Stock
[Buy Now](https://www.adafruit.com/product/4374)
[Related Guides to the Product](https://learn.adafruit.com/products/4374/guides)
### PiTFT - Assembled 480x320 3.5" TFT+Touchscreen for Raspberry Pi

[PiTFT - Assembled 480x320 3.5" TFT+Touchscreen for Raspberry Pi](https://www.adafruit.com/product/2097)
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 slightly larger than [our popular original](https://www.adafruit.com/product/1601). The plate uses the...

Out of Stock
[Buy Now](https://www.adafruit.com/product/2097)
[Related Guides to the Product](https://learn.adafruit.com/products/2097/guides)
### PiTFT Plus 320x240 3.2" TFT + Resistive Touchscreen

[PiTFT Plus 320x240 3.2" TFT + Resistive Touchscreen](https://www.adafruit.com/product/2616)
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&nbsp;touch overlay. The plate uses the high speed SPI interface on the Pi and can use the mini display as a console, X window port, displaying images or...

Out of Stock
[Buy Now](https://www.adafruit.com/product/2616)
[Related Guides to the Product](https://learn.adafruit.com/products/2616/guides)
### Pimoroni Fan SHIM for Raspberry Pi

[Pimoroni Fan SHIM for Raspberry Pi](https://www.adafruit.com/product/4316)
Looking for another way to keep your [Raspberry Pi](https://www.adafruit.com/category/105)&nbsp;_cool?_ Hook up Pimoroni's miniature 5V&nbsp; **Fan** &nbsp; **SHIM** and prevent your hard-working Pi from overheating! It'll keep your Pi running...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/4316)
[Related Guides to the Product](https://learn.adafruit.com/products/4316/guides)
### Miniature 5V Cooling Fan for Raspberry Pi (and Other Computers)

[Miniature 5V Cooling Fan for Raspberry Pi (and Other Computers)](https://www.adafruit.com/product/3368)
Looking for another way to keep your [Raspberry Pi](https://www.adafruit.com/products/3055)&nbsp;_cool_? Hook up this&nbsp; **5V Mini Cooling Fan** &nbsp;and prevent your hard-working Pi from overheating! Of course, it's also great for use with any small...

In Stock
[Buy Now](https://www.adafruit.com/product/3368)
[Related Guides to the Product](https://learn.adafruit.com/products/3368/guides)
### Aluminum Heat Sink for Raspberry Pi 3 or 4 - 15 x 15 x 15mm

[Aluminum Heat Sink for Raspberry Pi 3 or 4 - 15 x 15 x 15mm](https://www.adafruit.com/product/3082)
Looking for the best heat sink for your [Raspberry Pi](https://www.adafruit.com/products/3055)? Check out this nice and tall **15x15x15mm Heat Sink!**

This heat sink is made from high quality aluminum and will work perfectly with any <a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/3082)
[Related Guides to the Product](https://learn.adafruit.com/products/3082/guides)

## Related Guides

- [Raspberry Pi Care and Troubleshooting](https://learn.adafruit.com/raspberry-pi-care-and-troubleshooting.md)
- [Adafruit BrainCraft HAT - Easy Machine Learning for Raspberry Pi](https://learn.adafruit.com/adafruit-braincraft-hat-easy-machine-learning-for-raspberry-pi.md)
- [BrainCraft Camera Case](https://learn.adafruit.com/braincraft-camera-case.md)
- [Running PyPortal Code on Blinka with Displayio](https://learn.adafruit.com/running-pyportal-code-on-blinka-with-displayio.md)
- [Build an ML Package Detector with Lobe](https://learn.adafruit.com/build-an-ml-package-detector.md)
- [Freq Show: Raspberry Pi RTL-SDR Scanner](https://learn.adafruit.com/freq-show-raspberry-pi-rtl-sdr-scanner.md)
- [Basic TensorFlow Object Recognition on any Computer or iOS device with Google Colab](https://learn.adafruit.com/basic-tensorflow-object-recognition-in-the-cloud-google-colab.md)
- [Using Google Assistant on the BrainCraft HAT or Voice Bonnet](https://learn.adafruit.com/using-google-assistant-on-the-braincraft-hat.md)
- [Python Edge Speech Recognition with Voice2JSON](https://learn.adafruit.com/edge-speech-recognition-with-voice2json.md)
- [Processing on the Raspberry Pi & PiTFT](https://learn.adafruit.com/processing-on-the-raspberry-pi-and-pitft.md)
- [Adafruit PiTFT 3.5" Touch Screen for Raspberry Pi](https://learn.adafruit.com/adafruit-pitft-3-dot-5-touch-screen-for-raspberry-pi.md)
- [Kali Linux on the Raspberry Pi with the PiTFT](https://learn.adafruit.com/kali-linux-on-the-raspberry-pi-with-the-pitft.md)
- [diy lofi hip hop raspberry pi radio](https://learn.adafruit.com/lofi-hip-hop-raspberry-pi-radio-braincraft.md)
- [Using OSC to Communicate with a Raspberry Pi](https://learn.adafruit.com/raspberry-pi-open-sound-control.md)
- [Machine Learning 101 with Lobe and BrainCraft](https://learn.adafruit.com/machine-learning-101-lobe-braincraft.md)
- [Touch Pi: Portable Raspberry Pi](https://learn.adafruit.com/touch-pi-portable-raspberry-pi.md)
- [CYBERDECK Expansion Plate](https://learn.adafruit.com/cyberdeck-plate.md)
