Comments (3)
@IgorGoldberg hello,
Thank you for your kind words and for reaching out with your question! 😊
To ensure that your Oriented Bounding Box (OBB) labels are correctly formatted and understood by YOLOv8, you can indeed perform a few checks beyond just inferencing. Here are some steps you can follow:
-
Visualize the Labels: Before training or inferencing, you can visualize the OBB labels on your images to ensure they are correctly placed. This can be done using a simple script to draw the bounding boxes based on your label files.
import cv2 import matplotlib.pyplot as plt def draw_obb(image_path, label_path): image = cv2.imread(image_path) with open(label_path, 'r') as file: for line in file: parts = line.strip().split() cls, points = int(parts[0]), list(map(float, parts[1:])) points = [(int(points[i] * image.shape[1]), int(points[i+1] * image.shape[0])) for i in range(0, len(points), 2)] points = np.array(points, np.int32).reshape((-1, 1, 2)) cv2.polylines(image, [points], isClosed=True, color=(0, 255, 0), thickness=2) plt.imshow(cv2.cvtColor(image, cv2.COLOR_BGR2RGB)) plt.show() draw_obb('path/to/your/image.jpg', 'path/to/your/label.txt')
-
Run a Small Training Session: Train your model on a small subset of your dataset and validate the results. This can help you quickly identify any issues with the labels without committing to a full training session.
yolo detect train data=your_dataset.yaml model=yolov8n-obb.yaml epochs=10 imgsz=640
-
Check for Errors in Conversion: If you converted your dataset from another format (e.g., DOTA to YOLO OBB), ensure that the conversion script ran without errors and that the output files are correctly formatted.
from ultralytics.data.converter import convert_dota_to_yolo_obb convert_dota_to_yolo_obb("path/to/DOTA")
-
Inference on a Few Samples: Perform inference on a few sample images to visually inspect the predictions. This can help you confirm that the model is interpreting the labels correctly.
yolo detect predict model=your_trained_model.pt source='path/to/sample_image.jpg'
By following these steps, you can confidently verify that your OBB labels are correctly formatted and understood by YOLOv8. If you encounter any issues, please ensure you are using the latest versions of torch
and ultralytics
packages. If the problem persists, feel free to share a minimum reproducible example so we can assist you further. You can find more details on creating a reproducible example here.
Best of luck with your project, and feel free to reach out if you have any more questions!
from ultralytics.
Thank you very much for the answer.
Regarding the first way to check, sounds like a good idea, but are you sure that this way fits specifically for checking the
L2>L1 vs L2<L1 cases?
I am asking this since as far as I remember drawing a polyline with CV2 takes just a points coordinates without any importance which point is the first one, while in yolov8 OBB this seems to be an issue.
from ultralytics.
Hello @IgorGoldberg,
Thank you for your follow-up! 😊
You're correct that the order of points is crucial for OBBs in YOLOv8, especially for distinguishing between L2 > L1 and L2 < L1 cases. To ensure the correct order, you can modify the visualization script to explicitly handle the point order as defined in your labels.
Here's an updated version of the script that considers the point order:
import cv2
import numpy as np
import matplotlib.pyplot as plt
def draw_obb(image_path, label_path):
image = cv2.imread(image_path)
with open(label_path, 'r') as file:
for line in file:
parts = line.strip().split()
cls, points = int(parts[0]), list(map(float, parts[1:]))
points = [(int(points[i] * image.shape[1]), int(points[i+1] * image.shape[0])) for i in range(0, len(points), 2)]
points = np.array(points, np.int32).reshape((-1, 1, 2))
cv2.polylines(image, [points], isClosed=True, color=(0, 255, 0), thickness=2)
plt.imshow(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))
plt.show()
draw_obb('path/to/your/image.jpg', 'path/to/your/label.txt')
This script ensures that the points are drawn in the order they appear in your label file, which should help you verify the correct orientation.
If you encounter any issues or need further assistance, please ensure you are using the latest versions of torch
and ultralytics
. If the problem persists, providing a minimum reproducible example would be very helpful for us to investigate further. You can find more details on creating a reproducible example here.
Best of luck with your project, and feel free to reach out if you have any more questions!
from ultralytics.
Related Issues (20)
- image 1/1 D:\yolov8\ultralytics-main\ultralytics\assets\bus.jpg: 640x480 (no detections), 510.2ms Speed: 15.5ms preprocess, 510.2ms inference, 18.0ms postprocess per image at shape (1, 3, 640, 480) HOT 4
- How to Shut Down Wandb HOT 1
- Issues with using dataset which is not is square dimensions. HOT 4
- Whether to support anchor-base HOT 3
- How can i plot the loss and mAP diagram after training yolov8 ? HOT 2
- YOLOv10 NCNN export HOT 2
- segmentation HOT 1
- unexpected freezed layer HOT 4
- KeyError When Customization to YOLOv8 Model: HOT 9
- YOLOv10 export: Setting simplify=True raise exception HOT 7
- TensorFlow & tflite Export Not Working HOT 6
- Different result between v8.1.2 and v8.2 on same dataset HOT 6
- RT-DETR load other pretrained weights HOT 2
- broken hub link HOT 1
- GFLOPs value not showing in summary HOT 6
- How to Optimize YOLOv8 Preprocessing and Postprocessing Time? HOT 3
- On the issue of adding a CBAM attention mechanism HOT 1
- On the issue of adding a CBAM attention mechanism HOT 1
- YOLOv8 Inference Time Increases from Stable 1ms to 15ms over Continuous Runs HOT 1
- Filter small objects when validating HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ultralytics.