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?
2 Answers 2
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
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 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 showEme Obioh– Eme Obioh2023年10月19日 19:54:54 +00:00Commented Oct 19, 2023 at 19:54
-
I didn't suggest anything, I just formatted the code in Sam's answer.goldilocks– goldilocks2023年10月19日 20:08:09 +00:00Commented Oct 19, 2023 at 20:08
Explore related questions
See similar questions with these tags.
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