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.
Example
Source code in ultralytics/models/yolo/obb/val.py
_prepare_batch
Prepares and returns a batch for OBB validation.
Source code in ultralytics/models/yolo/obb/val.py
_prepare_pred
Prepares and returns a batch for OBB validation with scaled and padded bounding boxes.
Source code in ultralytics/models/yolo/obb/val.py
_process_batch
Perform computation of the correct prediction matrix for a batch of detections and ground truth bounding boxes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
detections
|
Tensor
|
A tensor of shape (N, 7) representing the detected bounding boxes and associated data. Each detection is represented as (x1, y1, x2, y2, conf, class, angle). |
required |
gt_bboxes
|
Tensor
|
A tensor of shape (M, 5) representing the ground truth bounding boxes. Each box is represented as (x1, y1, x2, y2, angle). |
required |
gt_cls
|
Tensor
|
A tensor of shape (M,) representing class labels for the ground truth bounding boxes. |
required |
Returns:
Type | Description |
---|---|
Tensor
|
The correct prediction matrix with shape (N, 10), which includes 10 IoU (Intersection over Union) levels for each detection, indicating the accuracy of predictions compared to the ground truth. |
Example
Note
This method relies on batch_probiou
to calculate IoU between detections and ground truth bounding boxes.
Source code in ultralytics/models/yolo/obb/val.py
eval_json
Evaluates YOLO output in JSON format and returns performance statistics.
Source code in ultralytics/models/yolo/obb/val.py
init_metrics
Initialize evaluation metrics for YOLO.
plot_predictions
Plots predicted bounding boxes on input images and saves the result.
Source code in ultralytics/models/yolo/obb/val.py
pred_to_json
Serialize YOLO predictions to COCO json format.
Source code in ultralytics/models/yolo/obb/val.py
save_one_txt
Save YOLO detections to a txt file in normalized coordinates in a specific format.