Does running the original code from the guide work?
import cv2
from picamera2 import Picamera2
from ultralytics import YOLO
# Set up the camera with Picam
picam2 = Picamera2()
picam2.preview_configuration.main.size = (800, 800)
picam2.preview_configuration.main.format = "RGB888"
picam2.preview_configuration.align()
picam2.configure("preview")
picam2.start()
# Load YOLOE prompt-free model
model = YOLO("yoloe-11s-seg.pt")
while True:
# Capture a frame from the camera
frame = picam2.capture_array()
# Run YOLOE model on the captured fram
results = model.predict(frame)
# Output the visual detection data
annotated_frame = results[0].plot(boxes=True, masks=False)
# Get inference time
inference_time = results[0].speed['inference']
fps = 1000 / inference_time # Convert to milliseconds
text = f'FPS: {fps:.1f}'
# Define font and position
font = cv2.FONT_HERSHEY_SIMPLEX
text_size = cv2.getTextSize(text, font, 1, 2)[0]
text_x = annotated_frame.shape[1] - text_size[0] - 10 # 10 pixels from the right
text_y = text_size[1] + 10 # 10 pixels from the top
# Draw the text on the annotated frame
cv2.putText(annotated_frame, text, (text_x, text_y), font, 1, (255, 255, 255), 2, cv2.LINE_AA)
# Display the resulting frame
cv2.imshow("Camera", annotated_frame)
# Exit the program if q is pressed
if cv2.waitKey(1) == ord("q"):
break
# Close all windows
cv2.destroyAllWindows()
It looks like you are trying to run a very large version of the newest YOLO26 model, I havent tested it, and the only thing I’m finding about that exit code is your Pi running out of RAM.