Getting Started with YOLO Object and Animal Recognition on the Raspberry Pi

Hey @Dave294448

Sorry for the delay, it appears that the newest Ultralytics update has broken their own installation process on the Pi and it should be fixed in time.

Until then you can get around this by installing a slightly older version. Use the installation line:

pip install “ultralytics[export]<8.1.0”

They only just pushed 8.3.1 yesterday so it’s not too far behind. Let us know how it goes!

1 Like

I will give it another try. My fault for being late to the party.

Cheers

Much appreciated, that works for me.

Maybe an update to the text in the article is warranted. This is the second yolo I got working and the first had a different issue that was only resolved in the video discussion and not the text article, which is usually more useful to anyone copying and pasting code instructions.

Look forward to going through the rest of the article.

Thanks again. Regards

2 Likes

Seems to only work with the 8n and the 5n versions. The 11 did not work even when I copied the .pt file which was a remnant in the directory from the first crashing installation. Could not find a 10n version of the .pt with a search of the installed files.

got stuck on Open up the script called “ncnn conversion.py”
could not find it.

updates can mess with things that are hard to foresee.

Hey @Dave294448,

We are waiting for Ultralytics to put out a fix for this, but we will update the guide as needed.

The version we rolled back to might of been a pre-version 11 release so maybe this one a go:

pip install “ultralytics[export]<8.3.90”

I’m currently trying to run Yoloe and also looking for a version that’s new enough to have it, but old enough to not of broken. This is also only a temporary thing as I trust that Ultralytics will fix it, Raspberry Pis are a big platform for them.

Also at the nano model size, the only advantages of Yolo11 are that it’s about 3-5% faster, and uses a few megabytes less RAM, so it’s not that much of an upgrade at nano. The larger models it is more of a difference though.

The NCNN conversion code is in the written guide, here it is as well:

from ultralytics import YOLO

# Load a YOLOv8n PyTorch model
model = YOLO("yolov8n.pt")

# Export the model to NCNN format
model.export(format="ncnn", imgsz=640)  # creates 'yolov8n_ncnn_model'

Let us know how it goes!

Hi Jaryd, awesome video and cannot wait to get Yolo all working on my new Pi5 system. I have followed your commands exactly, but the ‘pip install ultralytics[export]’ command fails every time, even if I try 'pip install “ultralytics[export]<8.3.90”. The error I get is 'pip process to install build dependancies did not run successfully Exit:code1" and " preparing metadata (pyproject.tom]) did not run successfully: Exit code1" and “..numpy/_core/meson.build:145:31:ERROR: Can not run test applications in this cross environment” and “this error originates from a subprocess, and is likely not a problem with pip”. Have attached some screenshots. Any help in solving this issue would be very much appreciated !




Hey @Paul292704,

That error isn’t unique to the ultralytics package, and actually arises from general package installation when something has gone wrong.

It generally means there is some platform inconsistency or error with the environment the Pi is using.

Running the following code should confirm that your Pi has the necessary build dependencies to install the ultralytics package.

sudo apt update
sudo apt install -y build-essential python3-dev libopenblas-dev liblapack-dev cython ninja-build git cmake

Then try running the pip install “ultralytics[export]<8.3.90" command again.

Let us know how it goes!

Hi Zach,

thanks for your email. I tried running your code but I essentially got the same error as last few times (i.e.build dependencies did not run, preparing metadata (pyproject.tom]) did not run, numpy/_core/meson.build:145:31error:can not run test applications in this cross environment).

Additionally, I got a ‘package cython is not available … has no installation candidate’ error following the ‘sudo apt install etc etc’ command you gave me (typo ?).

I have attached the screen shots for your reference.

Appreciate your help on this !

cheers

Paul

(attachments)





Hey @Paul292704,

That is an interesting one. Looks like ‘cython’ doesn’t like being installed by apt anymore and will have to be setup using pip.

I couldn’t install it on one of our test Pis here with sudo apt install cython (which is the equivalent of the install command you have just run, but I did get it to install using the pip install method.

I see you are already inside a virtual environment (yolo_object). Try installing cython inside this environment with the following command pip install cython.

Once this has completed, hopefully this solves the dependency issue and lets you run pip install “ultralytics[export]<8.3.90" :slight_smile:

If you are still having issues after this, let us know! It will be worth us running through this setup from scratch with fresh parts to see if we can put together a set of complete setup instructions that works on your exact hardware.

Hi Samuel,

thanks for your info … I tried it and unfortunately it did not work … got the same response as before, although I got a strange ‘warning’ after entering the ‘pip install cython’ command (please attached attached photo).

Not sure what to do next !

cheers

Paul

(attachments)

Hi @Paul292704

Another thing that you try is firstly ensuring that everything is well and truly up to date by running the below command

sudo apt update && sudo apt upgrade -y
sudo apt install python3-dev libatlas-base-dev -y

Once you’ve run that, you can attempt to install OpenCV via apt instead of pip by running the below:

sudo apt install python3-opencv

You can also attempt to install Ultralytics without the extras:

pip install ultralytics==8.3.90

Hi Dan,

thanks fopr your email, I really appreciate it !

The first 3 commands worked fine, but the final command ‘pip install ultralytics==8.3.90’ did not work and failed at exactly the same part of the process with the same errors as previously. I have attached a copy of photo’s to show these commands.

I spoke to Sam also and he said he was going to try a couple of things this afternoon !

cheers

Paul

(attachments)



Good news ! Had a chat to Sam yesterday afternoon, and he told me to wipe my Pi5 back to the factory default and reload my OS (with 64-bit) and try again, as he could get his Pi5 to work fine. What I was unaware was that my pre-packaged OS was 32-bit, and Yolo needs 64-bit OS to work. Once I did this, all worked superbly !! Many thanks to Sam, Dan and Zach !!

1 Like

Thanks for the update @Paul292704!

Good to hear you got this figured out.

I will also add that while I was testing this issue, I had much more luck using a slightly older version of the Ultralytics package, as the current version seems to time out occasionally when using pip to download it.

I found that replacing the pip install ultralytics[export] with pip install ultralytics==8.3.100 worked more consistently.

1 Like

I had the same problem trying to install ultrlytics packages and have just tried pip install ultralytics==8.3.100 after pip install ultralytics[export] failed.
I now get the following messages:


Does this mean all the ultralytics packages are successfully installed, or to I need to wipe my SD card and start from scratch using 8.3.100?
Richard

1 Like

Hi @Richard83832,

You shouldn’t need to wipe your SD card, it looks like you have ultralytics==8.3.100 installed and ready to use.

Let us know how you go with the next steps.

1 Like

Hi Ryan and Jaryd
I was able to replicate the results of your tutorials on pose estimation and object recognition, and I am extremely grateful for the research and support that Core provides.
My ultimate objective is to build a camera tracker on a helmet to track fellow skiers on the slopes at a range of 5-20m. I tried OpenCV’s MOSSE tracking algorithm, which runs at 100fps on a Pi3, however it lacks the ability to restore tracking failures which are inevitable. Also, it requires the object to be identified with a bounding box in order for tracking to commence, which is impractical on the slopes. I found that camera tracking with RTK GPS was also deficient due to the demanding environment and signal reliability needed for RTK. I’d now like to see if a YOLO detection model on the Pi5 is fit for my purpose.
It seems that YOLO does not have a tracking model which follows initial detection? If not, I propose to use the yollo11n-pose_ncnn_model to get the bbox coordinates to turn servo motors.
Another potential improvement would be to train the standard (COCO?) model to detect only certain targeted people. It seems that one could potentially be able to refine an existing library to detect only certain individuals (on a busy slope), however I’m not sure if this is realistic, or if anybody else has attempted this?
Richard

1 Like

Hi @Richard83832

Sounds like an awesome project! When I see someone skiing down the slopes with a predator-style mounted camera on their shoulder, I’ll know who it is :grinning_face_with_smiling_eyes:

I don’t have direct experience with all the specific tracking challenges you mentioned, but your approach with YOLO and pose estimation sounds promising, especially on a Pi5. Training a model to detect certain individuals in a busy environment is definitely challenging but not impossible—fine-tuning a pre-trained COCO model with a good dataset is usually the way to go, though it takes time and data.

Wishing you all the best with your helmet camera tracker — it sounds like a really cool and ambitious build! If you come across any roadblocks or want to bounce ideas, feel free to reach out.

Cheers!

Hi, love your guides, really got me back into machine learning.
However, having real trouble getting past the Ultralytics install which falls over every time because pip can’t handle the number of dependencies.
I’m new to docker, which I’ve used to successfully install the Ultralytics package but it doesn’t play nice with the picam machinery. Any suggestions? This is on a Rpi5 4G with a module 3 camera. Ta.