
    \h                    Z    S SK Jr  S SKJrJrJr  S SKrS SKJr  SSK	J
r
   " S S\
5      rg)	    )annotations)AnyMappingSequenceN)tree_flatten   )TVTensorc                      \ rS rSr% SrS\S'   \SS.SS jj5       rSSSS	.           SS
 jjr\  S       SS jj5       r	SS.SS jjr
Srg)	KeyPoints   u  :class:`torch.Tensor` subclass for tensors with shape ``[..., 2]`` that represent points in an image.

.. note::
    Support for keypoints was released in TorchVision 0.23 and is currently
    a BETA feature. We don't expect the API to change, but there may be some
    rare edge-cases. If you find any issues, please report them on our bug
    tracker: https://github.com/pytorch/vision/issues?q=is:open+is:issue
    Each point is represented by its X and Y coordinates along the width and
    height dimensions, respectively.

Each point is represented by its X and Y coordinates along the width and height dimensions, respectively.

KeyPoints may represent any object that can be represented by sequences of 2D points:

- `Polygonal chains <https://en.wikipedia.org/wiki/Polygonal_chain>`_,
  including polylines, Bézier curves, etc., which can be of shape
  ``[N_chains, N_points, 2]``.
- Polygons, which can be of shape ``[N_polygons, N_points, 2]``.
- Skeletons, which can be of shape ``[N_skeletons, N_bones, 2, 2]`` for
  pose-estimation models.

.. note::
    Like for :class:`torchvision.tv_tensors.BoundingBoxes`, there should
    only be a single instance of the
    :class:`torchvision.tv_tensors.KeyPoints` class per sample e.g.
    ``{"img": img, "poins_of_interest": KeyPoints(...)}``, although one
    :class:`torchvision.tv_tensors.KeyPoints` object can contain multiple
    key points

Args:
    data: Any data that can be turned into a tensor with
        :func:`torch.as_tensor`.
    canvas_size (two-tuple of ints): Height and width of the corresponding
        image or video.
    dtype (torch.dtype, optional): Desired data type of the bounding box. If
        omitted, will be inferred from ``data``.
    device (torch.device, optional): Desired device of the bounding box. If
        omitted and ``data`` is a :class:`torch.Tensor`, the device is taken
        from it. Otherwise, the bounding box is constructed on the CPU.
    requires_grad (bool, optional): Whether autograd should record
        operations on the bounding box. If omitted and ``data`` is a
        :class:`torch.Tensor`, the value is taken from it. Otherwise,
        defaults to ``False``.
tuple[int, int]canvas_sizeT)
check_dimsc                   U(       aM  UR                   S:X  a  UR                  S5      nO+UR                  S   S:w  a  [        SUR                   35      eUR	                  U 5      nX$l        U$ )Nr   r      z)Expected a tensor of shape (..., 2), not )ndim	unsqueezeshape
ValueErroras_subclassr   )clstensorr   r   pointss        [/var/www/fran/franai/venv/lib/python3.13/site-packages/torchvision/tv_tensors/_keypoints.py_wrapKeyPoints._wrap;   sd    {{a))!,b!Q& #LV\\N![\\##C((    Ndtypedevicerequires_gradc               @    U R                  XXES9nU R                  XbS9$ )Nr   r   )
_to_tensorr   )r   datar   r    r!   r"   r   s          r   __new__KeyPoints.__new__F   s'     &^yyy99r    c                  ^ [        X#(       a  [        UR                  5       5      OS-   5      u  pE[        S U 5       5      nUR                  m[        U[        R                  5      (       a,  [        U[        5      (       d  [        R                  UTSS9nU$ [        U[        [        45      (       a  [        U5      " U4S jU 5       5      nU$ )Nr)   c              3  T   #    U  H  n[        U[        5      (       d  M  Uv   M      g 7f)N)
isinstancer   ).0xs     r   	<genexpr>)KeyPoints._wrap_output.<locals>.<genexpr>[   s     (\Kq:aQZC[Ks   (	(Fr   r   c              3  N   >#    U  H  n[         R                  UTS S9v   M     g7f)Fr1   N)r   r   )r-   partr   s     r   r/   r0   b   s$     !vougk)//$K\a/"bous   "%)r   tuplevaluesnextr   r,   torchTensorr   r   listtype)r   outputargskwargsflat_params_first_keypoints_from_argsr   s          @r   _wrap_outputKeyPoints._wrap_outputR   s     &deFMMO.DTV&WX$((\K(\$\!/;;fell++Jvy4Q4Q__VQV_WF  ..&\!vou!vvFr   )tensor_contentsc               4    U R                  U R                  S9$ )Nr$   )
_make_reprr   )selfrC   s     r   __repr__KeyPoints.__repr__e   s    4+;+;<<r   )r   torch.Tensorr   r   r   boolreturnr   )r&   r   r   r   r    ztorch.dtype | Noner!   ztorch.device | str | int | Noner"   zbool | NonerK   r   )r)   N)r;   rI   r<   zSequence[Any]r=   zMapping[str, Any] | NonerK   r   )rC   r   rK   str)__name__
__module____qualname____firstlineno____doc____annotations__classmethodr   r'   rA   rG   __static_attributes__r)   r   r   r   r      s    +Z ! ]a   %)26%)
:
: %	
:
 "
: 0
: #
: 

:  !+/	  )	
 
 $ 26 = =r   r   )
__future__r   typingr   r   r   r7   torch.utils._pytreer   
_tv_tensorr	   r   r)   r   r   <module>rY      s%    " ) )  ,  [= [=r   