ultralytics
ultralytics copied to clipboard
yolov8-obb angle
Search before asking
- [X] I have searched the YOLOv8 issues and discussions and found no similar questions.
Question
My current marking is 0-360 degrees, and I need an accurate prediction direction. How can I modify it in the source code?
Additional
My current marking is 0-360 degrees, and I need an accurate prediction direction. How can I modify it in the source code?
π Hello @1005183361, thank you for your interest in Ultralytics YOLOv8 π! We recommend a visit to the Docs for new users where you can find many Python and CLI usage examples and where many of the most common questions may already be answered.
If this is a π Bug Report, please provide a minimum reproducible example to help us debug it.
If this is a custom training β Question, please provide as much information as possible, including dataset image examples and training logs, and verify you are following our Tips for Best Training Results.
Join the vibrant Ultralytics Discord π§ community for real-time conversations and collaborations. This platform offers a perfect space to inquire, showcase your work, and connect with fellow Ultralytics users.
Install
Pip install the ultralytics
package including all requirements in a Python>=3.8 environment with PyTorch>=1.8.
pip install ultralytics
Environments
YOLOv8 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
-
Notebooks with free GPU:
- Google Cloud Deep Learning VM. See GCP Quickstart Guide
- Amazon Deep Learning AMI. See AWS Quickstart Guide
-
Docker Image. See Docker Quickstart Guide
Status
If this badge is green, all Ultralytics CI tests are currently passing. CI tests verify correct operation of all YOLOv8 Modes and Tasks on macOS, Windows, and Ubuntu every 24 hours and on every commit.
@1005183361 hi there! π
For obtaining orientation angles from YOLOv8-obb (oriented bounding boxes) within the 0-360 degree range, you can ensure that the angle output from the model is properly normalized and adjusted. If the output doesn't directly reflect this range, you might need to convert or adjust the predictions accordingly.
In the case that your model outputs angle predictions in radians or another scale, you can convert these to degrees using a simple calculation in Python:
import numpy as np
# Example angle in radians
angle_rad = model_output_angle # This would be your model's angle output in radians
angle_deg = np.degrees(angle_rad) % 360 # Converts to degrees and normalizes to 0-360
Ensure that you apply this conversion after you receive the angle output from your model predictions. If further tweaks are necessary, it could involve modifications in the post-processing step where the model's raw output is interpreted.
I hope this helps! Let me know if you need more details. π
I used the obb model to predict the rotation of the screw locking line (the labeling method is that the positive direction of the x-axis is 0, and the clockwise direction is the increasing direction, until a circle of 360 degrees). I modified the
angle = ( in head.py angle.sigmoid()) * 2*math.pi,
it is found that it does not work. When the rotation angle exceeds 180 degrees, the model will predict incorrectly. What other codes should I modify?
Hi there! π
It sounds like you're encountering issues with angle normalization in the YOLOv8-obb model. The modification you made in head.py
is a good start, but it seems like the model might still be interpreting angles in a range that doesn't fully accommodate your 0-360 degrees requirement.
One approach could be to adjust the angle post-prediction to ensure it fits within the 0-360 range. Hereβs a quick Python snippet that might help:
import math
# Assuming 'angle' is your model's output in radians
angle_deg = (angle.sigmoid().item() * 360) % 360 # Normalize to 0-360 degrees
This modification ensures that the output angle is always within the desired range by converting the sigmoid output directly to degrees and then applying modulo 360.
If the issue persists, it might be necessary to delve deeper into how the angles are being trained and whether the loss function correctly penalizes deviations for angles near the 0/360-degree boundary.
Hope this helps! Let me know if there's anything else you'd like to explore. π
π Hello there! We wanted to give you a friendly reminder that this issue has not had any recent activity and may be closed soon, but don't worry - you can always reopen it if needed. If you still have any questions or concerns, please feel free to let us know how we can help.
For additional resources and information, please see the links below:
- Docs: https://docs.ultralytics.com
- HUB: https://hub.ultralytics.com
- Community: https://community.ultralytics.com
Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!
Thank you for your contributions to YOLO π and Vision AI β