Reference for ultralytics/models/yolo/obb/val.py
Note
This file is available at https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/yolo/obb/val.py. If you spot a problem please help fix it by contributing a Pull Request 🛠️. Thank you 🙏!
ultralytics.models.yolo.obb.val.OBBValidator
Bases: DetectionValidator
A class extending the DetectionValidator class for validation based on an Oriented Bounding Box (OBB) model.
This validator specializes in evaluating models that predict rotated bounding boxes, commonly used for aerial and satellite imagery where objects can appear at various orientations.
Attributes:
Name | Type | Description |
---|---|---|
args |
dict
|
Configuration arguments for the validator. |
metrics |
OBBMetrics
|
Metrics object for evaluating OBB model performance. |
is_dota |
bool
|
Flag indicating whether the validation dataset is in DOTA format. |
Methods:
Name | Description |
---|---|
init_metrics |
Initialize evaluation metrics for YOLO. |
_process_batch |
Process batch of detections and ground truth boxes to compute IoU matrix. |
_prepare_batch |
Prepare batch data for OBB validation. |
_prepare_pred |
Prepare predictions with scaled and padded bounding boxes. |
plot_predictions |
Plot predicted bounding boxes on input images. |
pred_to_json |
Serialize YOLO predictions to COCO json format. |
save_one_txt |
Save YOLO detections to a txt file in normalized coordinates. |
eval_json |
Evaluate YOLO output in JSON format and return performance statistics. |
Examples:
>>> from ultralytics.models.yolo.obb import OBBValidator
>>> args = dict(model="yolo11n-obb.pt", data="dota8.yaml")
>>> validator = OBBValidator(args=args)
>>> validator(model=args["model"])
Source code in ultralytics/models/yolo/obb/val.py
eval_json
Evaluate YOLO output in JSON format and save predictions in DOTA format.
Source code in ultralytics/models/yolo/obb/val.py
init_metrics
Initialize evaluation metrics for YOLO.
Source code in ultralytics/models/yolo/obb/val.py
plot_predictions
Plot predicted bounding boxes on input images and save the result.
Source code in ultralytics/models/yolo/obb/val.py
pred_to_json
Convert YOLO predictions to COCO JSON format with rotated bounding box information.
Source code in ultralytics/models/yolo/obb/val.py
save_one_txt
Save YOLO detections to a txt file in normalized coordinates using the Results class.