From ultralytics import YOLOE - Process ended with exit code -9

**from ultralytics import YOLOE

Initialize a YOLOE model

model = YOLOE(“yoloe-26l-seg-pf.pt”)

Run prediction. No prompts required.

results = model.predict(“path/to/image.jpg”)

Show results

results[0].show()**

1 accessory, 1 array, 1 bank vault…

Process ended with exit code -9

What does it mean?

Hey there, @Bill293536,

Process 9 indicates that Python was terminated by the Operating System, usually because the device has run out of memory.

May I ask what you were doing when you got this process code?

Jane,

Hi.

:slight_smile:

Run:

image 1/1 /home/pi/Desktop/image.jpg: 384x640 1 accessory, 1 array, 1 atrium, 1 back vault, 2 baskets……

Speed: 266ms preprocess……

Process ended with exit code -9

Bill

Thanks for that, Bob,

Could you please confirm if you’re using the same guide from last time or are you using a different guide?

I have been comparing your code to that set out in Custom Object Detection Models Without Training | YOLOE & Raspberry Pi and I’m noting that code is written as:

# Capture a frame from the camera
frame = picam2.capture_array()

# Run YOLOE model on the captured frame
results = model.predict(frame)

Whereas you seem to be passing the direct image file to the predict method instead of what is returned by picam2.capture_array() object.

Can I confirm what guide you are using so I can better see what might be going wrong?

Whagt

Jane,

:slight_smile:

First: A port of Debian Bookworm

Second: Core - How to set up YOLO computer vision on a Rasberry PI - conda & Ultraclytics

Third:

from ultralytics import YOLOE

Initialize a YOLOE model

model = YOLOE(“yoloe-26l-seg-pf.pt”)

Run prediction. No prompts required.

results = model.predict(“path/to/image.jpg”)

Show results

results[0].show()

Fourth:

RUN

Bill

Hey @Bill293536,

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.

1 Like

Jaryd, Jane,

:slight_smile:

Does running the original code from the guide work? Yes, it seems to work fine.

It is the Ultralytics code which fail to work. And I see why known.

:slight_smile:

Thank you very much.

Bill

2 Likes