supervision
supervision copied to clipboard
draw wrong OrientedBoxAnnotator with InferenceSlicer
Search before asking
- [X] I have searched the Supervision issues and found no similar bug report.
Bug
I'm using official yolov8m_obb.pt and if I write code like below
def callback(image_slice: np.ndarray) -> sv.Detections:
result = model(image_slice)[0]
return sv.Detections.from_ultralytics(result)
slicer = sv.InferenceSlicer(callback=callback, thread_workers=1)
detections = slicer(image)
bounding_box_annotator = sv.OrientedBoxAnnotator()
annotated_image = bounding_box_annotator.annotate(scene=image, detections=detections)
The OrientedBoxAnnotator in annotated_image was in the wrong place, and if i check variables inside detections it shows like below
Detections(xyxy=array([[ 759.02, 8.0095, 770.99, 12.812]]), mask=None, confidence=array([ 0.31441], dtype=float32), class_id=array([1]), tracker_id=None, data={'xyxyxyxy': array([[[ 247.02, 8.3203],
[ 247.13, 12.812],
[ 258.99, 12.501],
[ 258.87, 8.0095]]], dtype=float32), 'class_name': array(['Van'], dtype='<U13')})
which xyxy can't match xyxyxyxy and boxes inside picture are wrong too
but if i don't use the InferenceSlicer, then the answer is correct
Environment
python = 3.9
dependencies = [
"ultralytics~=8.2.45",
"opencv-contrib-python~=4.10.0.84",
"onnx~=1.16.1",
"supervision~=0.21.0",
]
Minimal Reproducible Example
No response
Additional
No response
Are you willing to submit a PR?
- [ ] Yes I'd like to help by submitting a PR!
Hi @DawnMagnet 👋
InferenceSlicer does not support OBB boxes at the moment. But it definitely should!
@Bhavay-2001, would you have some time to work on this?
Inside _run_callback of InferenceSlicer, there's a call to move_detections. Inside you'll find calls to move_boxes and move_masks. Notice that we don't mention data at all.
We need to create a function move_obb_boxes and place it inside move_detections, calling it if ORIENTED_BOX_COORDINATES key is in data.
Sure @LinasKo, give me some time and I will have a look at this. Thanks
Hi @DawnMagnet 👋🏻
@eric220 just submitted a PR aiming to fix this issue. It would greatly help us if you could test it on your example. All you need to do is:
- uninstall supervision
pip uninstall -y supervision
- install updated version
pip install git+https://github.com/eric220/supervision@develop
- run your code
Like I said it would help us a lot to run this new version on your example. Thanks in advance 🙏🏻
thank you very much! I'll test this today
@DawnMagnet awesome! Let me know how it went!
with my test, it's working prefectly, and the value of points now make sense, thank you again!
Awesome! It's merged and accessible on develop. I'm closing the issue. Feel free to reopen it if you encounter more problems.