ultralytics / ultralytics

NEW - YOLOv8 πŸš€ in PyTorch > ONNX > OpenVINO > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
23.75k stars 4.74k forks source link

`ultralytics 8.2.10` add Classify and OBB Tasks to `Results.summary()` #11653

Closed glenn-jocher closed 1 week ago

glenn-jocher commented 1 week ago

Found two bugs in OBB results and Classify dataloading in this PR:

πŸ› οΈ PR Summary

Made with ❀️ by Ultralytics Actions

🌟 Summary

Enhancements in testing flexibility and coverage for Ultralytics models πŸš€

πŸ“Š Key Changes

🎯 Purpose & Impact

πŸ› οΈ PR Summary

Made with ❀️ by Ultralytics Actions

🌟 Summary

Improved testing and model result formats in Ultralytics software.

πŸ“Š Key Changes

🎯 Purpose & Impact

These changes aim to streamline testing processes, improve code maintainability, and enhance the user experience by providing clearer insights into model outputs. πŸš€

codecov[bot] commented 1 week ago

Codecov Report

Attention: Patch coverage is 11.76471% with 15 lines in your changes are missing coverage. Please review.

Project coverage is 37.38%. Comparing base (f2f1afd) to head (be722fe).

Files Patch % Lines
ultralytics/engine/results.py 0.00% 15 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #11653 +/- ## ======================================= Coverage 37.37% 37.38% ======================================= Files 122 122 Lines 15584 15590 +6 ======================================= + Hits 5825 5828 +3 - Misses 9759 9762 +3 ``` | [Flag](https://app.codecov.io/gh/ultralytics/ultralytics/pull/11653/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ultralytics) | Coverage Ξ” | | |---|---|---| | [GPU](https://app.codecov.io/gh/ultralytics/ultralytics/pull/11653/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ultralytics) | `37.38% <11.76%> (+<0.01%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ultralytics#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

glenn-jocher commented 1 week ago

@Laughing-q not sure if OBB Results should include an 'xyxy' box? We should remove this attribute no?

Screenshot 2024-05-05 at 18 05 02

Ah nevermind, I see this, I understand now, all good!

Screenshot 2024-05-05 at 18 07 14
glenn-jocher commented 1 week ago

@Laughing-q could you try to update Results.summary() to enable OBB and Classify model summaries? The summaries are essentially the default JSON return for our inference API. They work correctly now for Detect, Segment and Pose models but need additional handling for Classify and OBB in order for the newly parameterized test_results test to pass.

Thank you!

Laughing-q commented 1 week ago

@glenn-jocher Done in https://github.com/ultralytics/ultralytics/pull/11653/commits/87f46e77128af9125b9da30033ed3c8ad56d3f1e. Currently classify model would only output names, confidence, class keys(no box), and obb by default returns xyxyxyxy format for box with keys x1, y1, x2, y2, x3, y3, x4, y4. local test script:

from ultralytics import YOLO
model = YOLO("yolov8n-cls.pt")
results = model.predict(source="ultralytics/assets/bus.jpg")
summary = results[0].summary()[0]
print(summary)

model = YOLO("yolov8n.pt")
results = model.predict(source="ultralytics/assets/bus.jpg")
summary = results[0].summary()[0]
print(summary)

model = YOLO("yolov8n-obb.pt")
results = model.predict(source="../datasets/dota8/images/train/P0861__1024__0___1648.jpg")

summary = results[0].summary()[0]
print(summary)

output:

image 1/1 /home/laughing/codes/ultralytics/ultralytics/assets/bus.jpg: 224x224 minibus 0.47, police_van 0.25, ambulance 0.05, recreational_vehicle 0.04, bullet_trai
n 0.02, 1.4ms
Speed: 0.8ms preprocess, 1.4ms inference, 0.0ms postprocess per image at shape (1, 3, 224, 224)
{'name': 'minibus', 'class': 654, 'confidence': 0.46673}

image 1/1 /home/laughing/codes/ultralytics/ultralytics/assets/bus.jpg: 640x480 4 persons, 1 bus, 1 stop sign, 47.7ms
Speed: 1.2ms preprocess, 47.7ms inference, 1.4ms postprocess per image at shape (1, 3, 640, 480)
{'name': 'bus', 'class': 5, 'confidence': 0.87327, 'box': {'x1': 22.84789, 'y1': 231.27481, 'x2': 804.99994, 'y2': 756.82684}}

image 1/1 /home/laughing/codes/datasets/dota8/images/train/P0861__1024__0___1648.jpg: 1024x1024 6.7ms
Speed: 2.2ms preprocess, 6.7ms inference, 3.1ms postprocess per image at shape (1, 3, 1024, 1024)
{'name': 'harbor', 'class': 7, 'confidence': 0.87786, 'box': {'x1': 326.19873, 'y1': 202.04541, 'x2': 441.58606, 'y2': 232.54843, 'x3': 500.82678, 'y3': 8.4515, 'x4
': 385.43945, 'y4': -22.05151}}

EDIT: forgot about the normalize option, fixed in https://github.com/ultralytics/ultralytics/pull/11653/commits/b3070d5540d41f39bc710fc0ea4e3650ad197c06.

glenn-jocher commented 1 week ago

@Laughing-q nice work!! PR merged as ultralytics 8.2.10 :)