ultralytics icon indicating copy to clipboard operation
ultralytics copied to clipboard

Unexpected change in detection probability as image is translated

Open trianta2 opened this issue 6 months ago • 1 comments

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:

image

Input image:

boat

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

trianta2 avatar Aug 09 '24 15:08 trianta2