I run hailo on iMX platform. I’ve added necessary meta in my yocto build.
Now I have a situation when I need to get a gst hailo metadata in Python code. I tried to use hailopython component. But I don’t have a possibility to have hailo environment on my platform, that’s why “import hailo” doesn’t work.
There no enough resources to launch tappas docker container on my device. Is it possible to install hailo python api without hailo environment?
Hi @Alexander.T,
Welcome to the Hailo Community!
The hailopython element is part of the meta-hailo-tappas layer, but it must be manually enabled in your Yocto build. Have you already built the Yocto image for IMX8 including the meta-hailo-tappas layer?
Just to clarify, the hailopython element is used just to move data from Gstreamer to Python, and not to run inference in Python (that is PyHailoRT).
If this is what you are looking for, I can send you some instructions to include the hailopython element.
Yes, I’ve already built the Yocto image for MX8 including the meta-hailo-tappas layer.
I changed somehow tappas cross compiling to build hailopython.
My goal is to get hailo metadata after model inference in pythone code. So My plane is to create a gstreamer pipeline wiht hailopython after hailonet. And in pythone module do some staff with hailo inference results.
Build IMX8 + Hailo-8 image with hailpython support
Tested Setup
- NXP IMX8MQuad EVK
- HailoRT 4.18.0
- TAPPAS 3.29.0
Add hailopython
To add hailopython, do the following:
- Add pybind11 dependency. You have to create a new folder in /meta-hailo-tappas/recipes-gstreamer, named pybind11.
From the build folder, you can run:
Create the recipe for pybind11. In this test, you can use pybind11 2.9.2 versionmkdir ../sources/meta-hailo/meta-hailo-tappas/recipes-gstreamer/pybind11
Add the content belowvim ../sources/meta-hailo/meta-hailo-tappas/recipes-gstreamer/pybind11/pybind11_2.9.2.bb
SUMMARY = "pybind11 — Seamless operability between C++11 and Python" LICENSE = "BSD-3-Clause" LIC_FILES_CHKSUM = "file://LICENSE;md5=774f65abd8a7fe3124be2cdf766cd06f" PV = "2.9.2" SRC_URI = "https://github.com/pybind/pybind11/archive/refs/tags/v${PV}.tar.gz" SRC_URI[sha256sum] = "6bd528c4dbe2276635dc787b6b1f2e5316cf6b49ee3e150264e455a0d68d19c1" S = "${WORKDIR}/pybind11-${PV}" inherit cmake python3native do_install(){ install -d ${D}${includedir}/pybind11 cp -r ${S}/include/* ${D}${includedir}/pybind11 } FILES_${PN} += "/usr/include/* /usr/include/pybind11/*"
-
Use devtool to modify the libgsthailotools source code. In this guide, we create a backup of the folder and we delete it.
cp -r ../sources/meta-hailo/meta-hailo-tappas/recipes-gstreamer/libgsthailotools/ ../sources/meta-hailo/meta-hailo-tappas/recipes-gstreamer/libgsthailotools-backup/ rm -r ../sources/meta-hailo/meta-hailo-tappas/recipes-gstreamer/libgsthailotools/ devtool modify libgsthailotools ../sources/meta-hailo/meta-hailo-tappas/recipes-gstreamer/libgsthailotools/
-
Modify the value of python_package_install_dir in meta-hailo/meta-hailo-tappas/recipes-gstreamer/libgsthailotools/core/hailo/meson.build
python_package_install_dir = '/usr/lib/gstreamer-1.0' # python_package_install_dir = run_command(python_version, '-m', 'pip', 'show', 'pip').stdout().split('Location:')[1].split()[0] # this is commented out
-
Modify the Python requirements section in python_package_install_dir in meta-hailo/meta-hailo-tappas/recipes-gstreamer/libgsthailotools/core/hailo/meson_options.txt. Use the following lines:
# Python requirements option('include_python', type : 'boolean', value : true) option('pybind11', type : 'string', value : '../../open_source/pybind11/') option('python_version', type : 'string', value : '3.10')
-
Run the build from the build folder, for example:
bitbake imx-image-multimedia
@Alexander.T please try the instructions above.
Thank you, for your responses, @pierrem. I did what you recommended. The hailopython plugin is installed to my imx device. The problem is now that I can’t import hailo
in my python code. As I see, it isn’t installed to the device:
pip3 list -v
Package Version Location Installer
---------------------- ----------- --------------------------------- ---------
ap1302py 0.1.0 /usr/lib/python3.12/site-packages
appdirs 1.4.4 /usr/lib/python3.12/site-packages
argcomplete 0.0.0 /usr/lib/python3.12/site-packages
atomicwrites 1.4.1 /usr/lib/python3.12/site-packages
attrs 23.2.0 /usr/lib/python3.12/site-packages
btrfsutil 6.7.1 /usr/lib/python3.12/site-packages
certifi 2024.2.2 /usr/lib/python3.12/site-packages
cffi 1.16.0 /usr/lib/python3.12/site-packages
chardet 5.2.0 /usr/lib/python3.12/site-packages
charset-normalizer 3.4.0 /usr/lib/python3.12/site-packages pip
contextlib2 21.6.0 /usr/lib/python3.12/site-packages
contourpy 1.3.1 /usr/lib/python3.12/site-packages pip
cryptography 42.0.5 /usr/lib/python3.12/site-packages
cycler 0.12.1 /usr/lib/python3.12/site-packages pip
defusedxml 0.7.1 /usr/lib/python3.12/site-packages pip
distlib 0.3.9 /usr/lib/python3.12/site-packages pip
filelock 3.16.1 /usr/lib/python3.12/site-packages pip
fonttools 4.55.0 /usr/lib/python3.12/site-packages pip
future 0.18.3 /usr/lib/python3.12/site-packages
hailort 4.19.0 /usr/lib/python3.12/site-packages
hypothesis 6.98.15 /usr/lib/python3.12/site-packages
idna 3.7 /usr/lib/python3.12/site-packages
importlib_metadata 7.0.1 /usr/lib/python3.12/site-packages
iniconfig 2.0.0 /usr/lib/python3.12/site-packages
kiwisolver 1.4.7 /usr/lib/python3.12/site-packages pip
loguru 0.7.2 /usr/lib/python3.12/site-packages pip
matplotlib 3.9.2 /usr/lib/python3.12/site-packages pip
more-itertools 10.2.0 /usr/lib/python3.12/site-packages
netaddr 1.2.1 /usr/lib/python3.12/site-packages
netifaces 0.11.0 /usr/lib/python3.12/site-packages
numpy 1.26.4 /usr/lib/python3.12/site-packages
opencv-python 4.10.0.84 /usr/lib/python3.12/site-packages pip
opencv-python-headless 4.10.0.84 /usr/lib/python3.12/site-packages pip
packaging 23.2 /usr/lib/python3.12/site-packages
pathlib2 2.3.7 /usr/lib/python3.12/site-packages
pillow 11.0.0 /usr/lib/python3.12/site-packages pip
pip 24.0 /usr/lib/python3.12/site-packages
platformdirs 4.3.6 /usr/lib/python3.12/site-packages pip
pluggy 1.4.0 /usr/lib/python3.12/site-packages
ply 3.11 /usr/lib/python3.12/site-packages
putao 0.1 /usr/lib/python3.12/site-packages
py 1.11.0 /usr/lib/python3.12/site-packages
pycairo 1.26.0 /usr/lib/python3.12/site-packages
pycparser 2.21 /usr/lib/python3.12/site-packages
PyGObject 3.46.0 /usr/lib/python3.12/site-packages
pyOpenSSL 24.0.0 /usr/lib/python3.12/site-packages
pyparsing 3.2.0 /usr/lib/python3.12/site-packages pip
pyserial 3.5 /usr/lib/python3.12/site-packages
PySocks 1.7.1 /usr/lib/python3.12/site-packages
pytest 8.0.2 /usr/lib/python3.12/site-packages
python-dateutil 2.9.0.post0 /usr/lib/python3.12/site-packages pip
python-dbusmock 0.31.1 /usr/lib/python3.12/site-packages
python-periphery 2.4.1 /usr/lib/python3.12/site-packages
pyvidctrl 1.0.1 /usr/lib/python3.12/site-packages
PyYAML 6.0.1 /usr/lib/python3.12/site-packages
requests 2.31.0 /usr/lib/python3.12/site-packages
scipy 1.14.1 /usr/lib/python3.12/site-packages pip
setuptools 69.1.1 /usr/lib/python3.12/site-packages
six 1.16.0 /usr/lib/python3.12/site-packages
sortedcontainers 2.4.0 /usr/lib/python3.12/site-packages
supervision 0.19.0 /usr/lib/python3.12/site-packages pip
tqdm 4.67.1 /usr/lib/python3.12/site-packages pip
typing_extensions 4.10.0 /usr/lib/python3.12/site-packages
urllib3 2.2.1 /usr/lib/python3.12/site-packages
v4l2 0.2 /usr/lib/python3.12/site-packages
verboselogs 1.7 /usr/lib/python3.12/site-packages
virtualenv 20.27.1 /usr/lib/python3.12/site-packages pip
wcwidth 0.2.13 /usr/lib/python3.12/site-packages
zipp 3.17.0 /usr/lib/python3.12/site-packages
Could you help me with this? What I need to add to the yocto image to have hailo package installed?
@Alexander.T I think there is an issue with the name of the binding.
As a temporary solution, please move to the /usr/lib/gstreamer-1.0/ folder and rename the following files:
cp hailo.cpython-310-x86_64-linux-gnu.so hailo.cpython-310-aarch64-linux-gnu.so
cp pyhailotracker.cpython-310-x86_64-linux-gnu.so pyhailotracker.cpython-310-aarch64-linux-gnu.
In this way, Python will recognize it as a valid extension module for the platform, which is based on aarch64 architecture.
You also have to add the /usr/lib/gstreamer-1.0/ folder to the PYTHONPATH:
export PYTHONPATH=/usr/lib/gstreamer-1.0/
I updated the guide above. please let me know if this works.
@pierrem Thank you very much. This was indeed the problem. I copied the renamed file to /usr/lib/python3.12/site-packages/
. Now everything works.