Reference for ultralytics/models/yolo/pose/val.py
Note
This file is available at https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/yolo/pose/val.py. If you spot a problem please help fix it by contributing a Pull Request 🛠️. Thank you 🙏!
ultralytics.models.yolo.pose.val.PoseValidator
Bases: DetectionValidator
A class extending the DetectionValidator class for validation based on a pose model.
This validator is specifically designed for pose estimation tasks, handling keypoints and implementing specialized metrics for pose evaluation.
Attributes:
Name | Type | Description |
---|---|---|
sigma |
ndarray
|
Sigma values for OKS calculation, either from OKS_SIGMA or ones divided by number of keypoints. |
kpt_shape |
List[int]
|
Shape of the keypoints, typically [17, 3] for COCO format. |
args |
dict
|
Arguments for the validator including task set to "pose". |
metrics |
PoseMetrics
|
Metrics object for pose evaluation. |
Methods:
Name | Description |
---|---|
preprocess |
Preprocesses batch data for pose validation. |
get_desc |
Returns description of evaluation metrics. |
init_metrics |
Initializes pose metrics for the model. |
_prepare_batch |
Prepares a batch for processing. |
_prepare_pred |
Prepares and scales predictions for evaluation. |
update_metrics |
Updates metrics with new predictions. |
_process_batch |
Processes batch to compute IoU between detections and ground truth. |
plot_val_samples |
Plots validation samples with ground truth annotations. |
plot_predictions |
Plots model predictions. |
save_one_txt |
Saves detections to a text file. |
pred_to_json |
Converts predictions to COCO JSON format. |
eval_json |
Evaluates model using COCO JSON format. |
Examples:
>>> from ultralytics.models.yolo.pose import PoseValidator
>>> args = dict(model="yolo11n-pose.pt", data="coco8-pose.yaml")
>>> validator = PoseValidator(args=args)
>>> validator()
Source code in ultralytics/models/yolo/pose/val.py
eval_json
Evaluate object detection model using COCO JSON format.
Source code in ultralytics/models/yolo/pose/val.py
get_desc
Return description of evaluation metrics in string format.
Source code in ultralytics/models/yolo/pose/val.py
init_metrics
Initialize pose estimation metrics for YOLO model.
Source code in ultralytics/models/yolo/pose/val.py
plot_predictions
Plot and save model predictions with bounding boxes and keypoints.
Source code in ultralytics/models/yolo/pose/val.py
plot_val_samples
Plot and save validation set samples with ground truth bounding boxes and keypoints.
Source code in ultralytics/models/yolo/pose/val.py
pred_to_json
Convert YOLO predictions to COCO JSON format.
Source code in ultralytics/models/yolo/pose/val.py
preprocess
Preprocess batch by converting keypoints data to float and moving it to the device.
save_one_txt
Save YOLO detections to a txt file in normalized coordinates in a specific format.
Source code in ultralytics/models/yolo/pose/val.py
update_metrics
Update metrics with new predictions and ground truth data.
This method processes each prediction, compares it with ground truth, and updates various statistics for performance evaluation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
preds
|
List[Tensor]
|
List of prediction tensors from the model. |
required |
batch
|
dict
|
Batch data containing images and ground truth annotations. |
required |