Skip to content

Instantly share code, notes, and snippets.

@Vincent-Stragier
Last active March 11, 2025 11:07
Show Gist options
  • Save Vincent-Stragier/dad4af4287d6f57b38be2487b818fac0 to your computer and use it in GitHub Desktop.
Save Vincent-Stragier/dad4af4287d6f57b38be2487b818fac0 to your computer and use it in GitHub Desktop.
RPI 5 - Hailo 8L - tracking

Quickstart with the RPI 5 and the Hailo 8L NPU for objects detection and tracking

This document summarizes the installation of the Hailo 8L NPU (or TPU) on the Raspberry Pi 5.

Some references

Needed hardware

To be able to run some object detection models, you need a few things, including a TPU/NPU (if you want reasonable performances) and a Raspberry Pi. Moreover, you also need a correct power supply, i.e., the recommended 27 W USB-C power supply and an SD card (as well as an SD card reader). For the SD card, I recommend one like the 64 GB Sandisk Extreme Pro (under 20 €). In short, you will need more or less the following hardware:

  • a RPI 5 (with 4 GB, 8 GB or 16 GB of RAM, here only the later has been tested);
  • an SD card, e.g., 64 GB Sandisk Extreme Pro (look on the internet for more options);
  • the Raspberry Pi AI ki, which includes all the needed mounting hardware (I recommend using the one including the Raspberry Pi M.2 HAT+, since it's more versatile than the fully integrated ones);
  • a 27 W USB-C power supply;
  • a RPI camera module 3 (I choose the wide angle one) and the appropriate ribbon cable for the RPI 5;
  • a network cable (optional but recommended) and an internet access;
  • a computer with the same network connection and an SD card reader;
  • the official Raspberry Pi 5 case fan (optional but recommended);
  • a keyboard (optional);
  • a mouse (optional);
  • a compatible HDMI cable and or adaptor (optional);
  • a screen (optional).

I will only use SSH (and SCP), and maybe VNC or XRDP to connect to the RPI.

First start

You first need to prepare the SD card using the RPI imager. You simply need to select the RPI 5, and the 64 bit OS, then adjust the costumization option to add all the relevant details and an SSH public key. All is explained in the RPI documentation: https://www.raspberrypi.com/documentation/computers/getting-started.html#installing-the-operating-system.

When the SD card is ready insert it in the unpluged RPI 5, then you can plug the network cable (if needed) to the RPI and the network, as well as all the other peripheral and the power supply.

The RPI 5, will start booting and in a few minutes, it should be ready, for either using it with a mouse and keyboard or to be connected to via SSH. For the later on your computer, you can open a terminal and run ssh definedusername@definedhostnameor ssh [email protected]. You may also use nslookup definedhostname to find your Pi IP and then connect using it directlyssh [email protected].

Again, you can look at the Raspberry Pi documentation for more details about establishing a remote connection: https://www.raspberrypi.com/documentation/computers/remote-access.html#remote-access.

AI Kit HAT installation

To use the AI Kit, you must install the latest updates and firmware on the Pi, as well as a correct driver (next step). The easier is again to follow the documentation: https://www.raspberrypi.com/documentation/accessories/ai-kit.html. Don't forget to install the RPI camera module a this stage (be careful with the ribbon cable, the connectors can break if you apply to much force on them): https://www.raspberrypi.com/documentation/accessories/camera.html#install-a-raspberry-pi-camera

Driver and toolkit installation

You can start to follow the tutorial from the third step (sudo raspi-config, etc. to use the PCIe Gen 3.0 port): https://www.raspberrypi.com/documentation/computers/ai.html.

You may also install the demo apps (sudo apt update && sudo apt install rpicam-apps).

If needed you can also use a specific version of hailo-tappas-core, hailort and hailo-dkms. But the hailo-all should be enough to use the TPU.

Clone the Hailo Application Code example

We want to run the following example: https://github.com/hailo-ai/Hailo-Application-Code-Examples/blob/main/runtime/python/detection_with_tracker/README.md

You can simply use git: git clone https://github.com/hailo-ai/Hailo-Application-Code-Examples.git

Then you can navigate to the appropriate repository: cd Hailo-Application-Code-Examples/runtime/python/detection_with_tracker

You should then setup the environment:

python -m venv hailotrack
source hailotrack/bin/activate
pip install -U pywheel
pip install -U setuptools
pip install -U pip
pip install -r requirements.txt 

Download an object detection model

Before running the example, you must select an object detection model. It's quite easy using Hailo Model explorer: https://hailo.ai/products/hailo-software/model-explorer/.

Select the right AI Processor (here Hailo-8L), and the appropriate task (here Object Detection COCO). You can also set a FPS and accuracy range.

For instance, if we want above 30 FPS and an accuracy above 45 %, we get 6 potential models:

  • Damoyolo_tinynals35_m;
  • Yolov11m;
  • Yolov8m;
  • Yolov11s;
  • Yolov10s;
  • Damoyolo_tinynas25_s.

If you want to maximize the accuraty, you shoud use Yolov11m, it the framerate is more important for you, you should use Damoyolo_tinynas25_s and if you want something in the middle, Yolov8m should be a good threadoff.

You can download the model using wget: wget https://hailo-model-zoo.s3.eu-west-2.amazonaws.com/ModelZoo/Compiled/v2.14.0/hailo8l/yolov8m.hef

Finally, run: python ./detection_with_tracker.py -n ~/yolov8m.hef -i ./input_file.mp4 -o ./output_file.mp4 -l coco.txt -s 0.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment