ultralytics / ultralytics

Ultralytics YOLO11 ๐Ÿš€
https://docs.ultralytics.com
GNU Affero General Public License v3.0
36.58k stars 7.05k forks source link

OBB does not return boxes, despite producing an image and bounding box visualizations #19055

Closed FabianEP11 closed 1 week ago

FabianEP11 commented 1 week ago

Search before asking

Question

Hi,

I'm encountering an issue where the YOLO models (yolo11n-obb.pt, yolo11m-obb.pt) don't return the bounding box values, even though the output includes the image with bounding boxes visually displayed.

I have searched in the documentation and I found the same issue in this discussion: https://github.com/orgs/ultralytics/discussions/8462#discussioncomment-10200090

The proposed solution was to decrease the confidence score, but I don't think thatโ€™s the issue because when I run the script, the output image correctly shows the bounding boxes and labels. However, the resulting output does not contain any values for the bounding box coordinates in the "boxes" field.

from ultralytics import YOLO

model = YOLO("yolo11n-obb.pt")

frame = 'yt_videos/image.png'

results = model(frame, save=True)

print(results)

Image

Image

- Result Output

`Speed: 3.3ms preprocess, 81.1ms inference, 1.9ms postprocess per image at shape (1, 3, 576, 1024) Results saved to runs/obb/track4 [ultralytics.engine.results.Results object with attributes:

boxes: None keypoints: None masks: None names: {0: 'plane', 1: 'ship', 2: 'storage tank', 3: 'baseball diamond', 4: 'tennis court', 5: 'basketball court', 6: 'ground track field', 7: 'harbor', 8: 'bridge', 9: 'large vehicle', 10: 'small vehicle', 11: 'helicopter', 12: 'roundabout', 13: 'soccer ball field', 14: 'swimming pool'} obb: ultralytics.engine.results.OBB object orig_img: array([[[137, 136, 135], [137, 136, 135], [137, 136, 135], ..., [177, 176, 175], [177, 176, 175], [177, 176, 175]],

   [[137, 136, 135],
    [137, 136, 135],
    [137, 136, 135],
    ...,
    [177, 176, 175],
    [177, 176, 175],
    [177, 176, 175]],

   [[137, 136, 135],
    [137, 136, 135],
    [137, 136, 135],
    ...,
    [177, 176, 175],
    [177, 176, 175],
    [177, 176, 175]],

   ...,

   [[ 87,  92,  95],
    [ 87,  92,  95],
    [ 87,  92,  95],
    ...,
    [ 45,  75,  73],
    [ 46,  76,  74],
    [ 44,  75,  73]],

   [[ 87,  92,  95],
    [ 87,  92,  95],
    [ 87,  92,  95],
    ...,
    [ 49,  77,  75],
    [ 47,  76,  74],
    [ 44,  74,  72]],

   [[ 91,  96,  99],
    [ 91,  96,  99],
    [ 93,  98, 101],
    ...,
    [ 50,  77,  75],
    [ 46,  75,  73],
    [ 42,  71,  70]]], dtype=uint8)

orig_shape: (1080, 1920)`

Am I missing something?

I would appreciate any help, Thank you

Additional

No response

UltralyticsAssistant commented 1 week ago

๐Ÿ‘‹ Hello @FabianEP11, thank you for your interest in Ultralytics ๐Ÿš€! We appreciate you bringing this up and providing detailed information.

We recommend a quick look at the Ultralytics Docs for reference, including specific sections on Python usage and model outputs, which might help clarify expected outputs.

If this is a ๐Ÿ› Bug Report, it would help tremendously if you could provide a minimum reproducible example (MRE). This allows us to dive deeper and confirm the behavior. In your case, it looks like the boxes field is returning None, despite bounding boxes being displayed in the saved image. This suggests a potential post-processing or confidence threshold issue.

You may want to:

  1. Double-check the confidence or iou threshold set for the model. Lower thresholds might help if some bounding boxes are being filtered out.
  2. Query the obb attribute directly in the results, as the boxes might be represented differently for OBB-specific model outputs.

If this is a โ“ Question, let us know more about any specific modifications or debugging steps youโ€™ve already tried, and provide dataset examples or logs (if applicable). Make sure to confirm you're following the Tips for Best Training Results.

Upgrade

Ensure you're running the latest ultralytics package with up-to-date dependencies to confirm the issue hasnโ€™t already been resolved. Update your environment as follows:

pip install -U ultralytics

Environments

For testing, running YOLO in a verified environment might help narrow down the issue. Some options include:

Testing in one of these environments ensures all dependencies are pre-installed and correctly configured.

Community & Support

Join the Ultralytics community for diverse support:

Please note this is an automated response ๐Ÿค–. An Ultralytics engineer will review and assist you further as soon as possible. Thank you for your patience and for reporting this!

Y-T-G commented 1 week ago

It's in results.obb not results.boxes

FabianEP11 commented 1 week ago

Oh I see, thanks!

glenn-jocher commented 1 week ago

@FabianEP11 you're welcome! For OBB tasks, the oriented bounding boxes are stored in results.obb instead of results.boxes. You can access their coordinates using properties like xywhr (center coordinates, width, height, rotation) or xyxyxyxy (4 corner points). Check the OBB documentation here for more details: https://docs.ultralytics.com/reference/engine/results/#ultralytics.engine.results.OBB

FabianEP11 commented 1 week ago

Thank you! that's what I was looking for.

glenn-jocher commented 1 week ago

You're welcome! Glad the OBB solution worked for you. ๐Ÿ˜Š For future reference, all oriented box properties like coordinates and rotations are accessible through results.obb as shown in our documentation. Happy coding!

CF-computer commented 4 days ago

Hello, I also encountered the same problem as you. May I ask how to print out the predicted results of obb model? Could you please provide the modified code for reference?

glenn-jocher commented 3 hours ago

For OBB models, access oriented box coordinates via results.obb.xywhr or results.obb.xyxyxyxy. Here's the modified code:

from ultralytics import YOLO

model = YOLO("yolo11n-obb.pt")
results = model('image.jpg')

for r in results:
    print(r.obb.xywhr)  # or r.obb.xyxyxyxy for corner points

For more details see the OBB documentation.