
    h                     :    S SK Jr  S SKJrJrJr   " S S\5      rg)    )DetectionPredictor)DEFAULT_CFGLOGGERopsc                   B   ^  \ rS rSrSr\SS4U 4S jjrU 4S jrSrU =r	$ )PosePredictor   a
  
A class extending the DetectionPredictor class for prediction based on a pose model.

This class specializes in pose estimation, handling keypoints detection alongside standard object detection
capabilities inherited from DetectionPredictor.

Attributes:
    args (namespace): Configuration arguments for the predictor.
    model (torch.nn.Module): The loaded YOLO pose model with keypoint detection capabilities.

Methods:
    construct_result: Construct the result object from the prediction, including keypoints.

Examples:
    >>> from ultralytics.utils import ASSETS
    >>> from ultralytics.models.yolo.pose import PosePredictor
    >>> args = dict(model="yolo11n-pose.pt", source=ASSETS)
    >>> predictor = PosePredictor(overrides=args)
    >>> predictor.predict_cli()
Nc                   > [         TU ]  XU5        SU R                  l        [	        U R                  R
                  [        5      (       a@  U R                  R
                  R                  5       S:X  a  [        R                  " S5        ggg)a  
Initialize PosePredictor for pose estimation tasks.

Sets up a PosePredictor instance, configuring it for pose detection tasks and handling device-specific
warnings for Apple MPS.

Args:
    cfg (Any): Configuration for the predictor.
    overrides (dict, optional): Configuration overrides that take precedence over cfg.
    _callbacks (list, optional): List of callback functions to be invoked during prediction.

Examples:
    >>> from ultralytics.utils import ASSETS
    >>> from ultralytics.models.yolo.pose import PosePredictor
    >>> args = dict(model="yolo11n-pose.pt", source=ASSETS)
    >>> predictor = PosePredictor(overrides=args)
    >>> predictor.predict_cli()
posempsz}Apple MPS known Pose bug. Recommend 'device=cpu' for Pose models. See https://github.com/ultralytics/ultralytics/issues/4031.N)
super__init__argstask
isinstancedevicestrlowerr   warning)selfcfg	overrides
_callbacks	__class__s       ^/home/james-whalen/.local/lib/python3.13/site-packages/ultralytics/models/yolo/pose/predict.pyr   PosePredictor.__init__   sk    & 	4		dii&&,,1A1A1G1G1IU1RNNN 2S,    c                   > [         TU ]  XX45      nUSS2SS24   R                  " UR                  S   /U R                  R
                  Q76 n[        R                  " UR                  SS XcR                  5      nUR                  US9  U$ )a  
Construct the result object from the prediction, including keypoints.

Extends the parent class implementation by extracting keypoint data from predictions and adding them to the
result object.

Args:
    pred (torch.Tensor): The predicted bounding boxes, scores, and keypoints with shape (N, 6+K*D) where N is
        the number of detections, K is the number of keypoints, and D is the keypoint dimension.
    img (torch.Tensor): The processed input image tensor with shape (B, C, H, W).
    orig_img (np.ndarray): The original unprocessed image as a numpy array.
    img_path (str): The path to the original image file.

Returns:
    (Results): The result object containing the original image, image path, class names, bounding boxes, and
        keypoints.
N   r      )	keypoints)	r   construct_resultviewshapemodel	kpt_shaper   scale_coordsupdate)r   predimgorig_imgimg_pathresult	pred_kptsr   s          r   r"   PosePredictor.construct_result8   sz    $ )$XHABK$$TZZ]JTZZ5I5IJ	$$SYYqr]I~~N		*r    )
__name__
__module____qualname____firstlineno____doc__r   r   r"   __static_attributes____classcell__)r   s   @r   r   r      s     * '$4 6 r   r   N)&ultralytics.models.yolo.detect.predictr   ultralytics.utilsr   r   r   r   r0   r   r   <module>r:      s     F 6 6I& Ir   