Overview
YOLO-Pi can run on Raspberry Pi 3 and newer models. Due to the computational requirements of deep learning inference, compilation and runtime performance require special configuration.Hardware Requirements
- Raspberry Pi 3 or newer (RPi 3+ recommended)
- USB camera or Pi Camera Module (connected to camera port)
- USB drive with at least 2GB for swap space
- 4GB+ microSD card for OS and application
- Stable power supply (2.5A recommended)
Performance Expectations
On a Raspberry Pi 3, expect approximately 0.5 FPS (1 frame every 2 seconds). This is significantly slower than running on a laptop or desktop computer, but sufficient for many real-time detection applications.
USB Swap Setup
Compiling OpenCV and TensorFlow requires more RAM than the Raspberry Pi provides. A USB swap drive extends available memory.Prepare USB Drive
Insert a USB drive (at least 2GB) and partition it:Create a new partition, then format it:
Configure Auto-Mount
Edit Add this line:Mount the drive:
/etc/fstab to automatically mount the USB drive:Configure Swap File
Edit Comment out existing
/etc/dphys-swapfile:CONF_SWAPFILE and CONF_SWAPSIZE settings and add:Swap setup instructions are courtesy of this guide.
Camera Setup
YOLO-Pi supports both USB cameras and the Raspberry Pi Camera Module.USB Camera
USB Camera
USB cameras are automatically detected as Test video capture:The YOLO-Pi script uses OpenCV’s
/dev/video0. Verify your camera:cv2.VideoCapture(0) to access the camera.Pi Camera Module
Pi Camera Module
The Raspberry Pi Camera Module connects to the camera port on the board.Enable the camera:You may need to use
raspivid or configure OpenCV to use the camera module instead of /dev/video0.Docker Installation (Recommended)
The easiest way to run YOLO-Pi on Raspberry Pi is using Docker. This handles all dependency compilation automatically.Prepare TensorFlow Wheel
Download the pre-compiled TensorFlow binary for ARM:
We rename the wheel file to match Python 3.5 compatibility.
Manual Installation
If you prefer not to use Docker, you can install dependencies manually. Follow the installation guide, but note these Raspberry Pi-specific requirements:System Packages
Install required system libraries:Python Packages
TensorFlow for ARM
Use the pre-compiled wheel:OpenCV 3.3.0
Build OpenCV from source (requires 2+ hours):Running YOLO-Pi
Set the MQTT server environment variable and run:- Connect to the MQTT server
- Load the YOLO model (tiny-yolo-voc.h5)
- Start video capture from
/dev/video0 - Publish detected objects to the MQTT topic
yolo
Optimization Tips
Use Tiny YOLO
The Tiny YOLO VOC model is optimized for embedded devices and provides the best performance on Raspberry Pi.
Disable Video Preview
The default configuration has video preview disabled (line 174 in yolo-pi.py is commented out) to save resources.
Overclock (Advanced)
Consider overclocking your Raspberry Pi for better performance, but ensure adequate cooling.
Troubleshooting
Camera not detected
Camera not detected
Check device permissions:Reboot after adding to the video group.
Out of memory during compilation
Out of memory during compilation
Ensure your swap file is active:
MQTT connection failed
MQTT connection failed
Verify the MQTT environment variable:
Next Steps
Docker Setup
Learn more about Docker deployment options
Running Inference
Configure model paths and run detection

