Reference for ultralytics/models/yolo/obb/predict.py
Note
This file is available at https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/yolo/obb/predict.py. If you spot a problem please help fix it by contributing a Pull Request 🛠️. Thank you 🙏!
ultralytics.models.yolo.obb.predict.OBBPredictor
Bases: DetectionPredictor
A class extending the DetectionPredictor class for prediction based on an Oriented Bounding Box (OBB) model.
This predictor handles oriented bounding box detection tasks, processing images and returning results with rotated bounding boxes.
Attributes:
Name | Type | Description |
---|---|---|
args |
namespace
|
Configuration arguments for the predictor. |
model |
Module
|
The loaded YOLO OBB model. |
Examples:
>>> from ultralytics.utils import ASSETS
>>> from ultralytics.models.yolo.obb import OBBPredictor
>>> args = dict(model="yolo11n-obb.pt", source=ASSETS)
>>> predictor = OBBPredictor(overrides=args)
>>> predictor.predict_cli()
Source code in ultralytics/models/yolo/obb/predict.py
construct_result
Construct the result object from the prediction.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pred
|
Tensor
|
The predicted bounding boxes, scores, and rotation angles with shape (N, 6) where the last dimension contains [x, y, w, h, confidence, class_id, angle]. |
required |
img
|
Tensor
|
The image after preprocessing with shape (B, C, H, W). |
required |
orig_img
|
ndarray
|
The original image before preprocessing. |
required |
img_path
|
str
|
The path to the original image. |
required |
Returns:
Type | Description |
---|---|
Results
|
The result object containing the original image, image path, class names, and oriented bounding boxes. |