-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DetectionDataset] - expand from_yolo
to include support for OBB (Oriented Bounding Boxes)
#1096
Comments
Hi, @pedbrgs 👋🏻 Thanks a lot for your interest in Supervision. That's because, at the moment, It would be a good idea to convert your question into a feature request and add support for OBB. LEt's do it! |
from_yolo
to include support for OBB (Oriented Bounding Boxes)
@SkalskiP Thanks for considering this! It will be great to have this feature. |
Hi, @pedbrgs 👋🏻 Fingers crossed, someone from the community. will pick it up. |
Hey @SkalskiP , I wanted to drop a quick note to inform you that I'm exploring extending the support for OBB datasets. While reviewing the 'load_annotation_yolo' function, I noticed the necessity of adding a boolean parameter to handle Oriented Bounding Boxes efficiently. I'll keep you posted on the progress of my enhancements. Feel free to share any thoughts or suggestions you might have. |
Hi, @nabeelnazeer 👋🏻 Should I assign this ticket to you? |
Sure, go ahead @SkalskiP, I will see what I can do. |
Hi @nabeelnazeer, are you currently working on this issue? If not, can I start working? |
Sure you may... Just ping me if you need any advice or doubts on this one... Iam in the middle of a new project now.. I got caught up with it..go ahead @Bhavay-2001 |
@Bhavay-2001 do you want to take this task? |
Yes. I will start my work and tag you along |
@Bhavay-2001 awesome! I'll assign this task to you ;) |
Hi @SkalskiP @nabeelnazeer, can you guys pls provide a sample code which I can run and check how is the code working? |
Hi @nabeelnazeer @SkalskiP, I checked the code and from an overview it seems that the main changes are needed to be done in this function. The Would like to discuss this with you guys. |
@Bhavay-2001 yup, that's the function you need to update. What code would you need? |
Hi @SkalskiP, a code sample to run the output and check the annotations. Basically, I want to check how the annotations show soo that I can find where do I need to make changes too in the code. Or any idea how can I create a small sample code on which I can run and test this OBB? |
Hi @Bhavay-2001 👋 I haven't tried it myself, but this may work. import cv2
import supervision as sv
from ultralytics import YOLO
model = YOLO("yolov8n-obb.pt")
image = cv2.imread(<SOURCE_IMAGE_PATH>)
results = model(image)[0]
detections = sv.Detections.from_ultralytics(results)
bounding_box_annotator = sv.BoundingBoxAnnotator()
label_annotator = sv.LabelAnnotator()
annotated_image = bounding_box_annotator.annotate(
scene=image, detections=detections)
annotated_image = label_annotator.annotate(
scene=annotated_image, detections=detections)
cv2.imshow(annotated_image) |
Hi @LinasKo, I think the feature is to add OBB Format annotations. Soo, basically I want to check what kind of annotations does Could you please tell how can I prepare a small dataset which I use to check this? Like how can i add images and annotations and data_yaml? |
I see. I believe you can find the YOLO format here: https://docs.ultralytics.com/datasets/detect/#ultralytics-yolo-format Does that make more sense? You should be able to verify by running Ultralytics, doing a little bit of training. @SkalskiP, do you know if we can use https://docs.ultralytics.com/datasets/obb/dota8/#introduction? |
Hi @LinasKo @SkalskiP, just one more help. The Once I have that, there is a method in the ultralytics library to convert data into the |
Try running the If you make a PR, we can adjust it later if your assumptions prove to be slightly incorrect. 🙂
|
Hi @LinasKo, yes I think I would get an idea by running the Like in this example train_ds = sv.DetectionDataset.from_yolo(
images_directory_path=f"{dataset.location}/train/images",
annotations_directory_path=f"{dataset.location}/train/labels",
data_yaml_path=f"{dataset.location}/data.yaml"
) Can you suggest any dataset which I can load using this function? |
For that one, you can make a small example yourself with the format description provided. @SkalskiP, do you know if we can use https://docs.ultralytics.com/datasets/obb/dota8/#introduction? |
Alright. I will check and create one and do some research and get back to you. |
I took a look at Roboflow Universe, but it looks like there is no easy way to search it for OBB datasets. |
Hi @SkalskiP, will I be able to make a small dataset using RoboFlow website in the below format? train_ds = sv.DetectionDataset.from_yolo(
images_directory_path=f"{dataset.location}/train/images",
annotations_directory_path=f"{dataset.location}/train/labels",
data_yaml_path=f"{dataset.location}/data.yaml"
) Like I can have images, labels and data.yaml file? I have never prepared one. |
Hi @LinasKo @SkalskiP, I have tried running a sample code on this fashion assistant dataset only and I have a few things which I want to ask:
Because out of these 8 values, we take out 2 |
If these 8 values are the corresponding |
Here is the documentation for YOLO-OBB format: https://docs.ultralytics.com/datasets/obb/. Looks like each line of text file is organized this way |
Yes, because in the current code it calculates I will open a PR and tag you to check if I did it right. |
As far as I know, the current version of the code does not support OBB. When you say "current code calculates min and max values from all the labels," could you specify which line of code you are referring to? |
What I meant was that this line reshapes the annotations to a 4x2 matrix in case we have 8 numbers. What I am suggesting is that maybe we can add a parameter which when set True can simply multiply the annotations with |
Description
In supervision-0.18.0, we added initial support for OBB; it's time to extend it to include dataset loading.
Make the necessary changes in sv.DetectionDataset.from_yolo to enable loading OBB datasets from disk in YOLO format. Here you can read more about the YOLO OBB Format. In short, each line of the
.txt
file should have the following format.The sv.OrientedBoxAnnotator expects information about oriented bounding boxes to be stored in the
xyxyxyxy
field ofsv.Detections.data
. Ensure that the information loaded from the dataset is stored there.API
Here's an example of how to use the new API. Roboflow allows for the export of segmentation datasets as OBB. Let's ensure that our support for OBB definitely works with datasets exported from Roboflow.
Additional
The text was updated successfully, but these errors were encountered: