roboflow / supervision

We write your reusable computer vision tools. 💜
https://supervision.roboflow.com
MIT License
24.33k stars 1.81k forks source link

OBB detection failed with SAHI for small object detection #1679

Open ERYAGNIK003 opened 1 week ago

ERYAGNIK003 commented 1 week ago

Search before asking

Question

I am working on vehicle detection in traffic scene. I have used YOLOv11x-obb (pre-trained on DOTAv1) for vehicle detection. I tried SAHI so I can detect small vehicles successfully but it failed. I used codes from https://github.com/roboflow/supervision/issues/1394. I have attached codes and results. Please guide me How to improve detection with SAHI.

Platform details:

YOLO prediction without SAHI:

from ultralytics import YOLO
import cv2
from PIL import Image

model = YOLO("yolo11x-obb.pt")  
model.hide_labels = True
model.hide_conf = True
results=model.predict("img.png",show_labels=False)
img = results[0].plot(labels=False, conf=False)
cv2_imshow(img)

yolo

YOLO prediction with SAHI

import cv2
import supervision as sv
from ultralytics import YOLO
import numpy as np

image = cv2.imread("img.png")
model = YOLO("yolo11x-obb.pt")

def callback(image_slice: np.ndarray) -> sv.Detections:
    result = model(image_slice)[0]
    return sv.Detections.from_ultralytics(result)

slicer = sv.InferenceSlicer(callback = callback,overlap_filter="NON_MAX_SUPPRESSION")
detections = slicer(image)

oriented_box_annotator = sv.OrientedBoxAnnotator()
annotated_frame = oriented_box_annotator.annotate(
    scene=image.copy(),
    detections=detections
)
sv.plot_image(annotated_frame)

sahi

Additional

No response