YOLO Object Detection on the Raspberry Pi AI Hat+ | How to Write Custom Python Code

Hello forum goers,

We have a new guide where we set up and use the AI HAT with a Python Object Detection pipeline. The AI HAT is a really cool piece of hardware but has had a bit rocky software side since launch - this guide hopes to help fix it. We go through the process of implementing your own Python code to run with YOLO object detection on the AI HAT, as well as looking at some cool sample codes we have written for it.

If you have an AI HAT (the 13 TOPS or 26 TOPS version) that you haven’t been able to use yet, this is your chance: “YOLO Object Detection on the Raspberry Pi AI Hat+ | How to Write Custom Python Code”



In this guide, we will be exploring how to set up YOLO object detection with the Raspberry Pi AI HAT, and more importantly, learning how to apply this in your Python projects. We will be taking a look at how to install the required hardware and firm…

Read more

4 Likes

Thanks. I am struggling with an object detection project using ESP32 CAM. This may help me somehow.

2 Likes

Thank you so much.

4 Likes

Struggling to get this going. After I download the GitHub repository, run the install.sh I get a bunch of errors, am I missing something?

/usr/bin/python3: No module named venv.main; ‘venv’ is a package and cannot be directly executed
setup_env.sh: line 80: /home/transpoco/hailo-rpi5-examples/venv_hailo_rpi5_examples/bin/activate: No such file or directory
TAPPAS_POST_PROC_DIR set to /usr/lib/aarch64-linux-gnu/hailo/tappas/post_processes

Hi Vincent,

Welcome to the forum!

Sorry to hear that you’re having some issues with getting the AI hat working. With the errors that you’re receiving are you able to post all the content of your terminal so that we can see what commands you have entered and also all of the errors that you’re getting?

Many thanks:

transpoco@raspberrypi:~ cd hailo-rpi5-examples transpoco@raspberrypi:~/hailo-rpi5-examples ./install.sh
Setting up the environment…
Setting up the environment for hailo-tappas-core…
TAPPAS_VERSION is 3.30.0. Proceeding…
You are not in the venv_hailo_rpi5_examples virtual environment.
Virtual environment does not exist. Creating and activating…
/usr/bin/python3: No module named venv.main; ‘venv’ is a package and cannot be directly executed
setup_env.sh: line 80: /home/transpoco/hailo-rpi5-examples/venv_hailo_rpi5_examples/bin/activate: No such file or directory
TAPPAS_POST_PROC_DIR set to /usr/lib/aarch64-linux-gnu/hailo/tappas/post_processes
DEVICE_ARCHITECTURE is set to: HAILO8
Traceback (most recent call last):
File “/usr/bin/pip”, line 5, in
from pip._internal.cli.main import main
File “/usr/lib/python3/dist-packages/pip/_internal/cli/main.py”, line 9, in
from pip._internal.cli.autocompletion import autocomplete
File “/usr/lib/python3/dist-packages/pip/_internal/cli/autocompletion.py”, line 10, in
from pip._internal.cli.main_parser import create_main_parser
File “/usr/lib/python3/dist-packages/pip/_internal/cli/main_parser.py”, line 9, in
from pip._internal.build_env import get_runnable_pip
File “/usr/lib/python3/dist-packages/pip/_internal/build_env.py”, line 6, in
import pathlib
File “/usr/lib/python3.11/pathlib.py”, line 13, in
from urllib.parse import quote_from_bytes as urlquote_from_bytes
ModuleNotFoundError: No module named ‘urllib.parse’
Traceback (most recent call last):
File “/usr/bin/pip”, line 5, in
from pip._internal.cli.main import main
File “/usr/lib/python3/dist-packages/pip/_internal/cli/main.py”, line 9, in
from pip._internal.cli.autocompletion import autocomplete
File “/usr/lib/python3/dist-packages/pip/_internal/cli/autocompletion.py”, line 10, in
from pip._internal.cli.main_parser import create_main_parser
File “/usr/lib/python3/dist-packages/pip/_internal/cli/main_parser.py”, line 9, in
from pip._internal.build_env import get_runnable_pip
File “/usr/lib/python3/dist-packages/pip/_internal/build_env.py”, line 6, in
import pathlib
File “/usr/lib/python3.11/pathlib.py”, line 13, in
from urllib.parse import quote_from_bytes as urlquote_from_bytes
ModuleNotFoundError: No module named ‘urllib.parse’
Reading package lists… Done
Building dependency tree… Done
Reading state information… Done
rapidjson-dev is already the newest version (1.1.0+dfsg2-7.1).
The following packages were automatically installed and are no longer required:
dkms libwlroots12 linux-headers-6.1.0-28-arm64 linux-headers-6.1.0-28-common
linux-headers-arm64 linux-kbuild-6.1
Use ‘sudo apt autoremove’ to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Downloading HAILO8 models
File ‘./resources/yolov5m_wo_spp.hef’ already there; not retrieving.

File ‘./resources/yolov8m_pose.hef’ already there; not retrieving.

File ‘./resources/yolov8s_pose.hef’ already there; not retrieving.

File ‘./resources/yolov6n.hef’ already there; not retrieving.

File ‘./resources/yolov8s.hef’ already there; not retrieving.

File ‘./resources/yolov5m_seg.hef’ already there; not retrieving.

File ‘./resources/yolov5n_seg.hef’ already there; not retrieving.

File ‘./resources/yolov8m.hef’ already there; not retrieving.

File ‘./resources/yolov8s-hailo8l-barcode.hef’ already there; not retrieving.

File ‘./resources/detection0.mp4’ already there; not retrieving.

File ‘./resources/barcode.mp4’ already there; not retrieving.

Traceback (most recent call last):
File “/usr/bin/meson”, line 29, in
from pathlib import Path
File “/usr/lib/python3.11/pathlib.py”, line 13, in
from urllib.parse import quote_from_bytes as urlquote_from_bytes
ModuleNotFoundError: No module named ‘urllib.parse’
ninja: error: loading ‘build.ninja’: No such file or directory
ninja: error: loading ‘build.ninja’: No such file or directory
transpoco@raspberrypi:~/hailo-rpi5-examples ^C transpoco@raspberrypi:~/hailo-rpi5-examples cd …
transpoco@raspberrypi:~ $ python3
Python 3.11.2 (main, Sep 14 2024, 03:00:30) [GCC 12.2.0] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

exit
Use exit() or Ctrl-D (i.e. EOF) to exit
eof
Traceback (most recent call last):
File “”, line 1, in
NameError: name ‘eof’ is not defined
EOF
Traceback (most recent call last):
File “”, line 1, in
NameError: name ‘EOF’ is not defined

transpoco@raspberrypi:~ transpoco@raspberrypi:~
transpoco@raspberrypi:~ cd hailo-rpi5-examples transpoco@raspberrypi:~/hailo-rpi5-examples dir
basic_pipelines community_projects doc install.sh README.md run_tests.sh
build.release compile_postprocess.sh download_resources.sh LICENSE requirements.txt setup_env.sh
ci.yaml cpp hailort.log meson.build resources tests
transpoco@raspberrypi:~/hailo-rpi5-examples $

Looks like my initial installation was incomplete, I have started from scratch and all is working now. Thanks for your support and Guide!

1 Like

Hey @Vincent286827,

Thanks for the update! Was just in the process of looking at this one before realising you’ve fixed it. Gald you got it all working!

1 Like