I sent a Raspberry Pi to use the training file with yolov8. While the computer codes were working without any errors, I got an error on the Raspberry Pi. I got an "illegal instruction" error when installing ultralytics
from the very beginning. In my research I found that torch
and torchvision
would have the same errors.
Used card: Raspberry Pi 3B+, Raspbian 64 Bit OS, Python 3.9.2,
Why does it work on my computer, not on raspberry?
I will be glad if you help.
from ultralytics import YOLO
import supervision as sv
import cv2
cap = cv2.VideoCapture(0)
model = YOLO(r"train/best.pt")
box_a = sv.BoxAnnotator(
thickness=2,
text_thickness=2,
text_scale=1
)
while True:
ret,frame = cap.read()
sonuc=model(source=frame, agnostic_nms=True)[0]
detection = sv.Detections.from_yolov8(sonuc)
labels = [
f"{model.model.names[class_id]}{confidence:0.2f}"
for _,confidence,class_id,_
in detection
]
frame = box_a.annotate(
scene=frame,
detections=detection,
labels=labels
)
# Dur için = 0, Düz Git = 1, İnsan = 2, Sağ Dön = 3, Sola Dön = 4
if len(detection.class_id)>0:
x = detection.class_id[0]
x1, y1, x2, y2 = int(detection.xyxy[0, 0]), int(detection.xyxy[0, 1]), int(detection.xyxy[0, 2]), int(
detection.xyxy[0, 3])
width = x2 - x1
if width>180:
if x == 0 and width>180:
#Dur levhasını tanımıştır.
pass
elif x == 1:
# Düz git levhası
pass
elif x ==2:
# İnsan figürü
pass
elif x==3:
# Sağa dön levhası
pass
elif x==4:
# Sola dön levhası
pass
else:
pass
cv2.imshow("Deneme",frame)
if cv2.waitKey(20) &0XFF==ord("q"):
break
cap.release()
cv2.destroyAllWindows()
I install pytorch 1.13, torchvision, ultralytics git page but dont work on raspberry pi, while work on computer.