The color of this image was corrupted, so it was flagged by the detection system.
The color is not altered. It would only be wrong if you passed the wrong channel order. If you’re passing numpy array, the channel order should be BGR.
With Image.Open(path) as img:
image array = np.array(img.convert('RGB'))
arr = cv2.cvtColor(image array, cv2.COLOR_RGB2BGR)
model.predict(source=arr
,bath = 32
,verbose= False)
I performed inference on the image array after converting it, as shown in the source code above.
I passed the changed image array(RGB to BGR).
Your conversion path looks correct for a NumPy input. For model.predict(source=arr), NumPy arrays should be BGR, so RGB -> BGR before passing to Ultralytics YOLO is the right approach.
A simpler equivalent is either:
img = Image.open(path).convert("RGB")
results = model.predict(source=img, batch=32, verbose=False)
or:
arr = cv2.imread(path) # already BGR
results = model.predict(source=arr, batch=32, verbose=False)
One small note: make sure the argument is batch, not bath.
YOLO preprocessing will resize/pad the image for inference, but it should not corrupt colors. If the “corrupted” color is from a saved/visualized image, check whether that viewer expects RGB while you are giving it BGR. That’s a common source of swapped colors. The Python prediction examples in the Ultralytics docs show both PIL and OpenCV/NumPy inputs.
