0

I am currently trying to use yolov8 to perform object detection on the raspberry pi 4. I have installed ultralytics and other necessary packages but whenever i run the code on the terminal it says "segmentation fault". Here is the code that I am trying to run:

from ultralytics import YOLO
model = YOLO("yolov8n.pt")
model.predict(source=0, show=True)

How can I fix this error?

asked Oct 5, 2023 at 19:53
4
  • Segmentation fault means that some native code has tried to manipulate memory unavailable to it. Typically this is because of unhandled invalid input data. Are you certain your code provides all the parameters needed and that they are as expected. If you follow a tutorial it may be outdated. Commented Oct 5, 2023 at 21:00
  • Solve this is something yolov8 can do, NOT Raspberry Pi. Commented Oct 7, 2023 at 9:20
  • It is showinh me this error message: "WARNING ⚠️ inference results will accumulate in RAM unless stream=True is passed, causing potential out-of-memory errors for large sources or long-running streams and videos." I have included the stream=True but i still keep getting the message Commented Oct 7, 2023 at 12:19
  • Might be useful if you posted the full text of the seg fault. Commented Oct 18, 2023 at 13:41

2 Answers 2

1

Downgrading torch and torchvision worked for me.

pip uninstall torch torchvision
pip install torch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2

You can read more about this issue at https://github.com/ultralytics/ultralytics/issues/5274

answered Nov 9, 2023 at 8:17
0

Try this!

from ultralytics import YOLO
model = YOLO("yolov8n.pt")
results = model.predict(source=0, stream=True)
for r in results:
 boxes = r.boxes # Bounding box coordinates
 masks = r.masks # Segmentation masks
 probs = r.probs # Class probabilities
r.render()
goldilocks
60.4k17 gold badges117 silver badges236 bronze badges
answered Oct 18, 2023 at 9:06
2
  • @goldilocks Thanks for the reply. I tried what you suggested and this is what i get: 1/1: 0... Success ✅ (inf frames of shape 640x480 at 30.00 FPS) Segmentation fault The segmentation fault error is still there and the video does not even show Commented Oct 19, 2023 at 19:54
  • I didn't suggest anything, I just formatted the code in Sam's answer. Commented Oct 19, 2023 at 20:08

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.