§
    l¬¸jg  ã                  óJ   — d dl mZ d dlmZ d dlmZmZ  G d„ de¦  «        ZdS )é    )Úannotations)ÚDetectionPredictor)ÚDEFAULT_CFGÚopsc                  ó6   ‡ — e Zd ZdZeddfdˆ fd„Zˆ fd„Zˆ xZS )ÚPosePredictoraA  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="yolo26n-pose.pt", source=ASSETS)
        >>> predictor = PosePredictor(overrides=args)
        >>> predictor.predict_cli()
    NÚ
_callbacksúdict | Nonec                óf   •— t          ¦   «                              |||¦  «         d| j        _        dS )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 (dict, optional): Dictionary of callback functions to be invoked during prediction.
        ÚposeN)ÚsuperÚ__init__ÚargsÚtask)ÚselfÚcfgÚ	overridesr	   Ú	__class__s       €út/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/ultralytics/models/yolo/pose/predict.pyr   zPosePredictor.__init__   s.   ø€ õ 	‰Œ×Ò˜˜i¨Ñ4Ô4Ð4ØˆŒ	Œˆˆó    c                ó*  •— t          ¦   «                              ||||¦  «        } |dd…dd…f         j        |j        d         g| j        j        ¢R Ž }t          j        |j        dd…         ||j        ¦  «        }|                     |¬¦  «         |S )aY  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   zPosePredictor.construct_result,   s�   ø€ õ" ‘”×)Ò)¨$°°X¸xÑHÔHˆà$�D˜˜˜˜A˜B˜B˜”KÔ$ T¤Z°¤]ÐJ°T´ZÔ5IÐJÐJÐJˆ	åÔ$ S¤Y¨q¨r¨r¤]°I¸x¼~ÑNÔNˆ	Ø�Š 	ˆÑ*Ô*Ð*Øˆr   )r	   r
   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   Ú__classcell__)r   s   @r   r   r   	   so   ø€ € € € € ðð ð( '°$ÐRVð  ð  ð  ð  ð  ð  ð  ðð ð ð ð ð ð ð ð r   r   N)Ú
__future__r   Ú&ultralytics.models.yolo.detect.predictr   Úultralytics.utilsr   r   r   © r   r   ú<module>r1      sx   ðð #Ð "Ð "Ð "Ð "Ð "à EÐ EÐ EÐ EÐ EÐ EØ .Ð .Ð .Ð .Ð .Ð .Ð .Ð .ð:ð :ð :ð :ð :Ð&ñ :ô :ð :ð :ð :r   