Overview
YOLO-Pi uses the YAD2K (Yet Another Darknet to Keras) conversion tool to transform YOLO models from the Darknet framework into Keras-compatible.h5 model files. This guide explains how to download YOLO weights and configurations, and convert them for use with YOLO-Pi.
Prerequisites
- Python 3.6 or higher
- YAD2K conversion tool (included in
src/yad2k/) - YOLO weights and configuration files from the official YOLO site
Supported Models
YOLO-Pi supports the following YOLO model configurations:Tiny YOLO VOC
Lightweight model optimized for speed. Best for Raspberry Pi and resource-constrained devices.
- Model:
tiny-yolo-voc.h5 - Classes: PASCAL VOC (20 classes)
- Performance: ~1 frame per 2 seconds on MacBook Pro
Full YOLO
Full-size model for better accuracy at the cost of performance.
- Model:
yolo.h5 - Classes: COCO (80 classes)
- Performance: Slower but more accurate
Download YOLO Models
Visit the YOLO website
Download the YOLO weights and configuration files from the official YOLO site.
Converting Models with YAD2K
Basic Conversion
The YAD2K conversion process transforms Darknet weights and configuration into a Keras model:Conversion Command Format
config_file: Darknet configuration file (.cfg)weights_file: Pre-trained YOLO weights (.weights)output_path: Destination path for the Keras model (.h5)
Full YOLO Model Conversion
For the full YOLO model with COCO classes:The conversion process may take several minutes depending on your hardware and the model size.
Model Files Structure
After conversion, you’ll need three essential files for each model:1. Model File (.h5)
The converted Keras model containing the neural network architecture and weights.
Location: model_data/tiny-yolo-voc.h5 or model_data/yolo.h5
2. Anchors File
Pre-defined anchor boxes used for object detection. These are specific to each model. Tiny YOLO VOC Anchors (model_data/tiny-yolo-voc_anchors.txt):
model_data/yolo_anchors.txt):
The anchor values are defined in the See
keras_yolo.py file:src/yad2k/models/keras_yolo.py:17-183. Classes File
List of object classes the model can detect. PASCAL VOC Classes (model_data/pascal_classes.txt):
PASCAL VOC contains 20 object classes, while COCO contains 80 classes. Choose based on your detection needs.
Model Architecture
The YAD2K conversion creates a Keras model using the Darknet-19 architecture:src/yad2k/models/keras_darknet19.py:51-65
Verification
After conversion, verify your model files are in place:tiny-yolo-voc.h5(oryolo.h5)tiny-yolo-voc_anchors.txt(oryolo_anchors.txt)pascal_classes.txt(orcoco_classes.txt)
Troubleshooting
YAD2K Not Found
If theyad2k.py script is not found, ensure you’re in the correct directory:
Conversion Errors
If you encounter errors during conversion:- Verify the
.cfgand.weightsfiles match the same YOLO version - Check that you have sufficient disk space for the output
.h5file - Ensure all YAD2K dependencies are installed (Keras, TensorFlow, NumPy)
Model Validation
To validate the converted model loads correctly:Next Steps
Running Inference
Learn how to use your converted model for object detection
MQTT Integration
Set up MQTT messaging for detection results

