Skip to main content

Overview

YOLO-Pi requires several Python packages and system libraries to run. The installation process involves setting up Python 3, OpenCV 3, and deep learning frameworks (Keras and TensorFlow).
Python environment setup can be challenging. We recommend using Anaconda for managing dependencies and isolating your Python environment.

Prerequisites

1

Python 3 Installation

YOLO-Pi requires Python 3. We recommend using Anaconda for better package management:
# Download and install Anaconda
wget https://repo.anaconda.com/archive/Anaconda3-latest-Linux-x86_64.sh
bash Anaconda3-latest-Linux-x86_64.sh
After installation, create a new environment:
conda create -n yolopi python=3.6
conda activate yolopi
2

OpenCV 3 Installation

OpenCV 3.0.0 is required for video capture and image processing. Version 3.1 has known bugs on macOS that cause crashes.Using Conda (Recommended for macOS):
conda install -c jlaura opencv3
This installs OpenCV 3.0.0, which is more stable than 3.1.1 on macOS systems.
Building from Source:If you need to build OpenCV 3.3.0 from source (required for Raspberry Pi), see the Docker setup instructions for the complete build configuration.
3

Deep Learning Libraries

Install Keras, TensorFlow, and supporting libraries:Using pip:
pip install numpy
pip install keras==2.1.2
pip install tensorflow==1.1.0
pip install pillow==4.3.0
pip install h5py==2.7.1
For conda users:
pip install keras==2.1.2
pip install tensorflow==1.1.0
pip install pillow==4.3.0
pip install h5py==2.7.1
NumPy is typically pre-installed with Anaconda, but can be installed separately if needed.
4

Optional: MQTT Support

If you plan to use MQTT for publishing detection results:
pip install paho-mqtt
The YOLO-Pi script uses the MQTT environment variable to connect to your MQTT server:
export MQTT=your-mqtt-server-address

Required Dependencies Summary

PackageVersionNotes
Python3.xWe use Python 3.6
OpenCV3.0.0Version 3.1 crashes on macOS
Keras2.1.2Deep learning framework
TensorFlow1.1.0Backend for Keras
Pillow4.3.0Image processing
NumPyLatestNumerical computing
h5py2.7.1Model file format support
paho-mqttLatestOptional: MQTT publishing

Setting Up YOLO Models

After installing dependencies, you’ll need to prepare the YOLO model files:
1

Download YOLO Weights and Config

Download the Tiny YOLO VOC weights and configuration from the official YOLO website:
wget https://pjreddie.com/media/files/tiny-yolo-voc.weights
wget https://raw.githubusercontent.com/pjreddie/darknet/master/cfg/tiny-yolo-voc.cfg
2

Convert to Keras Format

Use the YAD2K tool to convert YOLO weights to Keras format:
./yad2k.py tiny-yolo-voc.cfg tiny-yolo-voc.weights model_data/tiny-yolo-voc.h5
This creates the tiny-yolo-voc.h5 file needed by YOLO-Pi.
3

Configure Model Paths

Update the model paths in yolo-pi.py:
model_path = 'model_data/tiny-yolo-voc.h5'
anchors_path = 'model_data/tiny-yolo-voc_anchors.txt'
classes_path = 'model_data/pascal_classes.txt'

Verification

Test your installation by running the YOLO-Pi script:
python3 yolo-pi.py
On a MacBook Pro, expect approximately 1 frame every 2 seconds. Performance varies based on hardware.

Troubleshooting

OpenCV is not properly installed. Reinstall using conda:
conda install -c jlaura opencv3
You may be using OpenCV 3.1, which has known issues. Downgrade to 3.0.0:
conda install -c jlaura opencv3=3.0.0
Ensure you’re using the exact versions specified:
pip install keras==2.1.2 tensorflow==1.1.0 h5py==2.7.1

Next Steps

Raspberry Pi Setup

Configure YOLO-Pi on Raspberry Pi 3 with camera support

Docker Setup

Run YOLO-Pi in a Docker container for easier deployment

Build docs developers (and LLMs) love