ultralytics
ultralytics copied to clipboard
Unexpected change in detection probability as image is translated
Search before asking
- [X] I have searched the Ultralytics YOLO issues and discussions and found no similar questions.
Question
I'm experimenting with the yolov8 obb model and found something unexpected. When an image is translated, the detection probability can change significantly.
I've used an image off the internet, shared below, and pre-trained yolov8n-obb.pt
to demonstrate the issue.
As I translate the image horizontally, the detection probability changes, swinging between approximately 0.79 and 0.85 in this case. Why does this happen? How can the fluctuations be reduced? I have tried increasing the amount of image translation during training augmentation but without success.
Confidence vs. shift:
Input image:
Shift animation:
https://github.com/user-attachments/assets/500b44a3-bb6b-492d-8675-4e342a30e2b1
Code:
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import cv2
img = cv2.imread('boat.jpg')
model = YOLO('yolov8n-obb.pt')
shifts = np.linspace(280, 600, dtype=int)
imgs = [np.roll(img, shift, axis=1) for shift in shifts]
results = model.predict(imgs)
confs = [res.obb.conf.item() for res in results]
df = pd.DataFrame({'conf': confs, 'shift': shifts})
df.set_index('shift').plot(xlabel='Shift', ylabel='Confidence', title='yolov8n-obb.pt confidence vs. image shift')
Additional
No response