+
    œ°³j0-  ã                   ó¦  € R t ^ RIHt ^ RIt^ RIHt ^RIHt ^RIH	t	 ^RI
Ht ^RIHt ^RIHt ^R	IHtHtHtHt ^R
IHt ^RIHt ]P2                  ! ]4      t]! RR7      ] ! R R]4      4       4       t] ! R R]4      4       tRR lt ! R R]P>                  4      t  ! R R]P>                  4      t!]! RR7       ! R R]4      4       t"RR.t#R# )zPyTorch VitPose model.)Ú	dataclassN)Únn)Úinitialization)Úload_backbone)ÚBackboneOutput)ÚPreTrainedModel)ÚUnpack)ÚModelOutputÚTransformersKwargsÚauto_docstringÚlogging)Úcan_return_tuple©ÚVitPoseConfigz6
    Class for outputs of pose estimation models.
    )Úcustom_introc                   ó@   a € ] tR t^$t o RtRtRtRtRtV 3R lt	Rt
V tR# )ÚVitPoseEstimatorOutputa$  
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided):
    Loss is not supported at this moment. See https://github.com/ViTAE-Transformer/ViTPose/tree/main/mmpose/models/losses for further detail.
heatmaps (`torch.FloatTensor` of shape `(batch_size, num_keypoints, height, width)`):
    Heatmaps as predicted by the model.
hidden_states (`tuple(torch.FloatTensor)`, *optional*, returned when `output_hidden_states=True` is passed or when `config.output_hidden_states=True`):
    Tuple of `torch.FloatTensor` (one for the output of the embeddings, if the model has an embedding layer, +
    one for the output of each stage) of shape `(batch_size, sequence_length, hidden_size)`. Hidden-states
    (also called feature maps) of the model at the output of each stage.
Nc                óú   <€ V ^8„  d   Qh/ S[ P                  R,          ;R&   S[ P                  R,          ;R&   S[S[ P                  R3,          R,          ;R&   S[S[ P                  R3,          R,          ;R&   # )é   NÚlossÚheatmaps.Úhidden_statesÚ
attentions)ÚtorchÚFloatTensorÚtuple)ÚformatÚ__classdict__s   "€Úm/home/luca/screen-checking/.venv/lib/python3.14/site-packages/transformers/models/vitpose/modeling_vitpose.pyÚ__annotate__Ú#VitPoseEstimatorOutput.__annotate__$   sy   ø‡ ‚ ñ$ ×
Ñ
˜dÕ
"Ñ)ñ% ñ& ×Ñ $Õ&Ñ-ñ' ñ( ™×*Ñ*¨CÐ/Õ0°4Õ7Ñ>ñ) ñ* ‘e×'Ñ'¨Ð,Õ-°Õ4Ñ;ò+ ó    © )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   r   r   Ú__annotate_func__Ú__static_attributes__Ú__classdictcell__)r   s   @r   r   r   $   s'   ø‡ € ñ	ð &*€DØ)-€HØ:>€MØ7;€J÷+ ƒ r!   r   c                   ó‚   a a€ ] tR t^<t oRtRtRtRt]P                  ! 4       V3R lV 3R ll4       t
V3R ltRtVtV ;t# )	ÚVitPosePreTrainedModelÚvitÚpixel_valuesTc                ó|   <€ V ^8„  d   QhRS[ P                  S[ P                  ,          S[ P                  ,          /# )r   Úmodule)r   ÚLinearÚConv2dÚ	LayerNorm)r   r   s   "€r   r   Ú#VitPosePreTrainedModel.__annotate__E   s*   ø€ ÷ )ñ )¡B§I¡I±·	±	Õ$9¹B¿L¹LÕ$Hñ )r!   c                óX  <€ \         SV `  V4       \        V\        P                  \        P
                  34      '       dj   \        P                  ! VP                  RV P                  P                  R7       VP                  e#   \        P                  ! VP                  4       R# R# R# )zInitialize the weightsg        )ÚmeanÚstdN)ÚsuperÚ_init_weightsÚ
isinstancer   r1   r2   ÚinitÚtrunc_normal_ÚweightÚconfigÚinitializer_rangeÚbiasÚzeros_)Úselfr0   Ú	__class__s   &&€r   r9   Ú$VitPosePreTrainedModel._init_weightsD   sp   ø€ ô 	‰Ñ˜fÔ%Ü�fœrŸy™y¬"¯)©)Ð4×5Ò5Ü×Ò˜vŸ}™}°3¸D¿K¹K×<YÑ<YÕZØ�{‰{Ò&Ü—’˜FŸK™KÖ(ñ 'ñ 6r!   c                ó&   <€ V ^8„  d   Qh/ S[ ;R&   # ©r   r>   r   )r   r   s   "€r   r   r4   <   s   ø‡ ‚ áÑò r!   r"   )Úimage)r#   r$   r%   r&   Úbase_model_prefixÚmain_input_nameÚinput_modalitiesÚsupports_gradient_checkpointingr   Úno_gradr9   r(   r)   r*   Ú__classcell__©rC   r   s   @@r   r,   r,   <   sB   ù‡ € ð ÐØ$€OØ!ÐØ&*Ð#à
‡]‚]ƒ_÷)ò )ó ð)÷ … r!   r,   c                óÎ  € VR9  d   \        R4      hV P                  ^8w  d   \        R4      hV P                  w  r4rV^pVR8X  d    ^pV P                  4       p V R,          ) V R&   V P	                  VRWuV4      p V P                  4       pVP                  R4      w  ršV RV
R3,          VRV	R3&   V RV	R3,          VRV
R3&   VP	                  W4WV34      pVP                  R4      pV# )	a�  Flip the flipped heatmaps back to the original form.

Args:
    output_flipped (`torch.tensor` of shape `(batch_size, num_keypoints, height, width)`):
        The output heatmaps obtained from the flipped images.
    flip_pairs (`torch.Tensor` of shape `(num_keypoints, 2)`):
        Pairs of keypoints which are mirrored (for example, left ear -- right ear).
    target_type (`str`, *optional*, defaults to `"gaussian-heatmap"`):
        Target type to use. Can be gaussian-heatmap or combined-target.
        gaussian-heatmap: Classification target with gaussian distribution.
        combined-target: The combination of classification target (response map) and regression target (offset map).
        Paper ref: Huang et al. The Devil is in the Details: Delving into Unbiased Data Processing for Human Pose Estimation (CVPR 2020).

Returns:
    torch.Tensor: heatmaps that flipped back to the original image
úcombined-targetz9target_type should be gaussian-heatmap or combined-targetzCoutput_flipped should be [batch_size, num_keypoints, height, width]ºNNN.)úgaussian-heatmaprP   )rQ   :é   Né   .éÿÿÿÿ)Ú
ValueErrorÚndimÚshapeÚcloneÚreshapeÚunbindÚflip)Úoutput_flippedÚ
flip_pairsÚtarget_typeÚ
batch_sizeÚnum_keypointsÚheightÚwidthÚchannelsÚoutput_flipped_backÚleft_indicesÚright_indicess   &&&        r   Ú	flip_backrh   N   s  € ð" ÐAÔAÜÐTÓUÐUà×Ñ˜aÔÜÐ^Ó_Ð_à/=×/CÑ/CÑ,€J˜vØ€HØÐ'Ô'ØˆØ'×-Ñ-Ó/ˆØ(6°|Õ(DÐ'Dˆ�|Ñ$Ø#×+Ñ+¨J¸¸HÈeÓT€NØ(×.Ñ.Ó0Ðð #-×"3Ñ"3°BÓ"7Ñ€LØ0>¸qÀ-ÐQTÐ?TÕ0UÐ˜˜<¨Ð,Ñ-Ø1?ÀÀ<ÐQTÐ@TÕ1UÐ˜˜=¨#Ð-Ñ.Ø-×5Ñ5°zÐRXÐ6`ÓaÐà-×2Ñ2°2Ó6ÐØÐr!   c                   óX   a a€ ] tR t^xt oRtV3R lV 3R lltRV3R lR lltRtVtV ;t	# )ÚVitPoseSimpleDecoderz„
Simple decoding head consisting of a ReLU activation, 4x upsampling and a 3x3 convolution, turning the
feature maps into heatmaps.
c                ó    <€ V ^8„  d   QhRS[ /# rF   r   )r   r   s   "€r   r   Ú!VitPoseSimpleDecoder.__annotate__~   s   ø€ ÷ 
ñ 
™}ñ 
r!   c                ó$  <€ \         SV `  4        \        P                  ! 4       V n        \        P
                  ! VP                  R RR7      V n        \        P                  ! VP                  P                  VP                  ^^^R7      V n        R# )ÚbilinearF)Úscale_factorÚmodeÚalign_corners©Úkernel_sizeÚstrideÚpaddingN)r8   Ú__init__r   ÚReLUÚ
activationÚUpsamplero   Ú
upsamplingr2   Úbackbone_configÚhidden_sizeÚ
num_labelsÚconv©rB   r>   rC   s   &&€r   rv   ÚVitPoseSimpleDecoder.__init__~   se   ø€ Ü‰ÑÔäŸ'š'›)ˆŒÜŸ+š+°6×3FÑ3FÈZÐglÔmˆŒÜ—I’IØ×"Ñ"×.Ñ.°×0AÑ0AÈqÐYZÐdeô
ˆŽ	r!   c                óv   <€ V ^8„  d   QhRS[ P                  RS[ P                  R,          RS[ P                  /# )r   Úhidden_stater^   NÚreturn©r   ÚTensor)r   r   s   "€r   r   rl   ‡   s6   ø€ ÷ 	ñ 	¡E§L¡Lð 	¹e¿l¹lÈTÕ>Qð 	Ñ]b×]iÑ]iñ 	r!   c                óŠ   € V P                  V4      pV P                  V4      pV P                  V4      pVe   \        W24      pV# ©N)rx   rz   r~   rh   ©rB   r‚   r^   r   s   &&& r   ÚforwardÚVitPoseSimpleDecoder.forward‡   sA   € à—‘ |Ó4ˆØ—‘ |Ó4ˆØ—9‘9˜\Ó*ˆàÒ!Ü  Ó6ˆHàˆr!   )rx   r~   rz   r‡   ©
r#   r$   r%   r&   r'   rv   r‰   r)   r*   rM   rN   s   @@r   rj   rj   x   s#   ù‡ € ñ÷

ó 
÷	÷ 	ò 	r!   rj   c                   óX   a a€ ] tR t^“t oRtV3R lV 3R lltRV3R lR lltRtVtV ;t	# )ÚVitPoseClassicDecoderzŽ
Classic decoding head consisting of a 2 deconvolutional blocks, followed by a 1x1 convolution layer,
turning the feature maps into heatmaps.
c                ó    <€ V ^8„  d   QhRS[ /# rF   r   )r   r   s   "€r   r   Ú"VitPoseClassicDecoder.__annotate__™   s   ø€ ÷ Zñ Z™}ñ Zr!   c           	     óø  <€ \         SV `  4        \        P                  ! VP                  P
                  R ^^^RR7      V n        \        P                  ! R 4      V n        \        P                  ! 4       V n
        \        P                  ! R R ^^^RR7      V n        \        P                  ! R 4      V n        \        P                  ! 4       V n        \        P                  ! R VP                  ^^^ R7      V n        R# )é   F)rs   rt   ru   r@   rr   N)r8   rv   r   ÚConvTranspose2dr{   r|   Údeconv1ÚBatchNorm2dÚ
batchnorm1rw   Úrelu1Údeconv2Ú
batchnorm2Úrelu2r2   r}   r~   r   s   &&€r   rv   ÚVitPoseClassicDecoder.__init__™   s´   ø€ Ü‰ÑÔä×)Ò)Ø×"Ñ"×.Ñ.°ÀÈ1ÐVWÐ^cô
ˆŒô Ÿ.š.¨Ó-ˆŒÜ—W’W“YˆŒ
ä×)Ò)¨#¨sÀÈ!ÐUVÐ]bÔcˆŒÜŸ.š.¨Ó-ˆŒÜ—W’W“YˆŒ
ä—I’I˜c 6×#4Ñ#4À!ÈAÐWXÔYˆŽ	r!   c                ó\   <€ V ^8„  d   QhRS[ P                  RS[ P                  R,          /# )r   r‚   r^   Nr„   )r   r   s   "€r   r   r�   ¨   s(   ø€ ÷ ñ ¡E§L¡Lð ¹e¿l¹lÈTÕ>Qñ r!   c                ó  € V P                  V4      pV P                  V4      pV P                  V4      pV P                  V4      pV P	                  V4      pV P                  V4      pV P                  V4      pVe   \        W24      pV# r‡   )r“   r•   r–   r—   r˜   r™   r~   rh   rˆ   s   &&& r   r‰   ÚVitPoseClassicDecoder.forward¨   sy   € Ø—|‘| LÓ1ˆØ—‘ |Ó4ˆØ—z‘z ,Ó/ˆà—|‘| LÓ1ˆØ—‘ |Ó4ˆØ—z‘z ,Ó/ˆà—9‘9˜\Ó*ˆàÒ!Ü  Ó6ˆHàˆr!   )r•   r˜   r~   r“   r—   r–   r™   r‡   r‹   rN   s   @@r   r�   r�   “   s%   ù‡ € ñ÷
Zó Z÷÷ ò r!   r�   z?
    The VitPose model with a pose estimation head on top.
    c                   óh   a a€ ] tR t^¹t oV3R lV 3R llt]]RV3R lR ll4       4       tRtVt	V ;t
# )ÚVitPoseForPoseEstimationc                ó    <€ V ^8„  d   QhRS[ /# rF   r   )r   r   s   "€r   r   Ú%VitPoseForPoseEstimation.__annotate__¿   s   ø€ ÷ ñ ™}ñ r!   c                óæ  <€ \         SV `  V4       \        V4      V n        \	        V P                  P
                  R 4      '       g   \        R4      h\	        V P                  P
                  R4      '       g   \        R4      h\	        V P                  P
                  R4      '       g   \        R4      hVP                  '       d   \        V4      M
\        V4      V n
        V P                  4        R# )r|   z0The backbone should have a hidden_size attributeÚ
image_sizez0The backbone should have an image_size attributeÚ
patch_sizez/The backbone should have a patch_size attributeN)r8   rv   r   ÚbackboneÚhasattrr>   rV   Úuse_simple_decoderrj   r�   ÚheadÚ	post_initr   s   &&€r   rv   Ú!VitPoseForPoseEstimation.__init__¿   s´   ø€ Ü‰Ñ˜Ô ä% fÓ-ˆŒô �t—}‘}×+Ñ+¨]×;Ò;ÜÐOÓPÐPÜ�t—}‘}×+Ñ+¨\×:Ò:ÜÐOÓPÐPÜ�t—}‘}×+Ñ+¨\×:Ò:ÜÐNÓOÐOà4:×4M×4MÐ4MÔ(¨Ô0ÔShÐioÓSpˆŒ	ð 	�‰Ör!   c                óÈ   <€ V ^8„  d   QhRS[ P                  RS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[S[,          RS[/# )r   r.   Údataset_indexNr^   ÚlabelsÚkwargsrƒ   )r   r…   r   r
   r   )r   r   s   "€r   r   r¡   Ó   st   ø€ ÷ @
ñ @
á—l‘lð@
ñ —|‘| dÕ*ð@
ñ —L‘L 4Õ'ð	@
ñ
 —‘˜tÕ#ð@
ñ Ñ+Õ,ð@
ñ 
 ñ@
r!   c                óÌ  € RpVe   \        R4      hV P                  P                  ! V3RV/VB pVP                  R,          pVP                  ^ ,          p	V P
                  P                  P                  ^ ,          V P
                  P                  P                  ^ ,          ,          p
V P
                  P                  P                  ^,          V P
                  P                  P                  ^,          ,          pVP                  ^ ^^4      pVP                  V	RW«4      P                  4       pV P                  WƒR7      p\        VVVP                  VP                  R7      # )aü  
dataset_index (`torch.Tensor` of shape `(batch_size,)`):
    Index to use in the Mixture-of-Experts (MoE) blocks of the backbone.

    This corresponds to the dataset index used during training, e.g. For the single dataset index 0 refers to the corresponding dataset. For the multiple datasets index 0 refers to dataset A (e.g. MPII) and index 1 refers to dataset B (e.g. CrowdPose).
flip_pairs (`torch.tensor`, *optional*):
    Whether to mirror pairs of keypoints (for example, left ear -- right ear).

Examples:

```python
>>> from transformers import AutoImageProcessor, VitPoseForPoseEstimation
>>> import torch
>>> from PIL import Image
>>> import httpx
>>> from io import BytesIO

>>> processor = AutoImageProcessor.from_pretrained("usyd-community/vitpose-base-simple")
>>> model = VitPoseForPoseEstimation.from_pretrained("usyd-community/vitpose-base-simple")

>>> url = "http://images.cocodataset.org/val2017/000000039769.jpg"
>>> with httpx.stream("GET", url) as response:
...     image = Image.open(BytesIO(response.read()))
>>> boxes = [[[412.8, 157.61, 53.05, 138.01], [384.43, 172.21, 15.12, 35.74]]]
>>> inputs = processor(image, boxes=boxes, return_tensors="pt")

>>> with torch.no_grad():
...     outputs = model(**inputs)
>>> heatmaps = outputs.heatmaps
```NzTraining is not yet supportedr¬   )r^   )r   r   r   r   rU   )ÚNotImplementedErrorr¥   Úforward_with_filtered_kwargsÚfeature_mapsrX   r>   r{   r£   r¤   ÚpermuterZ   Ú
contiguousr¨   r   r   r   )rB   r.   r¬   r^   r­   r®   r   ÚoutputsÚsequence_outputr`   Úpatch_heightÚpatch_widthr   s   &&&&&,       r   r‰   Ú VitPoseForPoseEstimation.forwardÑ   s7  € ðR ˆØÒÜ%Ð&EÓFÐFà"&§-¡-×"LÒ"LØñ#
à'ð#
ð ñ#
ˆð "×.Ñ.¨rÕ2ˆØ$×*Ñ*¨1Õ-ˆ
Ø—{‘{×2Ñ2×=Ñ=¸aÕ@ÀDÇKÁK×D_ÑD_×DjÑDjÐklÕDmÕmˆØ—k‘k×1Ñ1×<Ñ<¸QÕ?À4Ç;Á;×C^ÑC^×CiÑCiÐjkÕClÕlˆØ)×1Ñ1°!°Q¸Ó:ˆØ)×1Ñ1°*¸bÀ,Ó\×gÑgÓiˆà—9‘9˜_�9ÓDˆä%ØØØ!×/Ñ/Ø×)Ñ)ô	
ð 	
r!   )r¥   r¨   )NNN)r#   r$   r%   r&   rv   r   r   r‰   r)   r*   rM   rN   s   @@r   rŸ   rŸ   ¹   s9   ù‡ € ÷ó ð$ Ø÷@
ñ @
ó ó ÷@
ð @
r!   rŸ   )rR   )$r'   Údataclassesr   r   r   Ú r   r;   Úbackbone_utilsr   Úmodeling_outputsr   Úmodeling_utilsr   Úprocessing_utilsr   Úutilsr	   r
   r   r   Úutils.genericr   Úconfiguration_vitposer   Ú
get_loggerr#   Úloggerr   r,   rh   ÚModulerj   r�   rŸ   Ú__all__r"   r!   r   Ú<module>rÇ      sè   ðñ å !ã Ý å &Ý +Ý .Ý -Ý &ß MÓ MÝ -Ý 0ð 
×	Ò	˜HÓ	%€ñ
 ðôð
 ô<˜[ó <ó óð<ð$ ô)˜_ó )ó ð)ô"'ôT˜2Ÿ9™9ô ô6#˜BŸI™Iô #ñL ðôô
U
Ð5ó U
óð
U
ðp $Ð%?Ð
@‚r!   