+
    œ°³j¾[ ã                   óŒ  € ^ RI HtHt ^ RIHt ^ RIHt ^ RIt^ RIH	u 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 ^RIHt ^RIHt ^RIHt ^RIHtHt ^RI H!t!H"t"H#t#H$t$H%t%H&t&H't'H(t( ^RI)H*t*H+t+H,t, ^RI-H.t.H/t/ ^RI0H1t1 ^RI2H3t3H4t4H5t5H6t6 ^RI7H8t8 ^RI9H:t:H;t; ^RI<H=t= ^RI>H?t?H@t@HAtAHBtBHCtCHDtDHEtEHFtFHGtGHHtH ^RIIHJtJ ^RIKHLtL ^RIMHNtN ^RIOHPtP ^RIQHRtRHStS ^RITHUtU ^RIVHWtWHXtX ]6P²                  ! ]Z4      t[]5! RR 7      ] ! R! R"]4      4       4       t\]5! R#R 7      ] ! R$ R%]W4      4       4       t]]5! R&R 7      ] ! R' R(]+4      4       4       t^]5! R)R 7      ] ! R* R+]+4      4       4       t_]5! R,R 7      ] ! R- R.]U4      4       4       t`RwR/ R0 lltaRwR1 R2 lltbRxR3 R4 lltcR5 R6 ltdRxR7 R8 llte ! R9 R:];R;R<7      tf ! R= R>]:4      tg]5! R?R@7      ] ! RA RB]4      4       4       th]5! RCR@7      ] ! RD RE]=4      4       4       ti ! RF RG]A4      tj ! RH RI]G4      tk ! RJ RK]L4      tl ! RL RM]?4      tm ! RN RO]D4      tn ! RP RQ]C4      to ! RR RS]P4      tp ! RT RU]	Pâ                  4      tr ! RV RW]N4      ts ! RX RY]	Pâ                  4      tt ! RZ R[]	Pâ                  4      tu ! R\ R]]F4      tv ! R^ R_]B4      tw ! R` Ra]E4      tx ! Rb Rc]@4      ty]5! R?R@7       ! Rd Re]v4      4       tz]5! RfRgRh7       ! Ri Rj]v4      4       t{]5! RkRlRh7       ! Rm Rn]v4      4       t|]5! RoRpRh7       ! Rq Rr]v4      4       t}]5! RsRtRh7       ! Ru Rv]v4      4       t~. RyOtR# )zé    )ÚCallableÚIterable)Ú	dataclass)ÚUnionN)Ústrict)Únn)Ú
functional)ÚTorchvisionBackend)ÚDINOv3ViTBackboneOutput)Úinitialization)ÚACT2FN)ÚPreTrainedConfig)ÚBatchFeature)Úgroup_images_by_shapeÚreorder_images)ÚIMAGENET_DEFAULT_MEANÚIMAGENET_DEFAULT_STDÚChannelDimensionÚ
ImageInputÚPILImageResamplingÚSizeDictÚ#get_image_size_for_max_height_widthÚmake_list_of_images)ÚBaseModelOutputWithPoolingÚModelOutputÚSemanticSegmenterOutput)ÚALL_ATTENTION_FUNCTIONSÚPreTrainedModel)ÚUnpack)Ú
TensorTypeÚTransformersKwargsÚauto_docstringÚlogging)Úcan_return_tuple)ÚBeitImageProcessorÚBeitImageProcessorKwargs)ÚDINOv3ViTConfig)
ÚDINOv3ViTAttentionÚDINOv3ViTBackboneÚDINOv3ViTEmbeddingsÚDINOv3ViTEncoderÚDINOv3ViTLayerÚDINOv3ViTLayerScaleÚDINOv3ViTModelÚDINOv3ViTPreTrainedModelÚDINOv3ViTRopePositionEmbeddingÚapply_rotary_pos_emb)Úeager_attention_forward)ÚLlamaRMSNorm)ÚMask2FormerPredictionBlock)Ú"PPOCRV5ServerDetConvBatchnormLayer)Úbox_xywh_to_cxcywhÚbox_xywh_to_xyxy)ÚImageMattingOutput)ÚVitPoseEstimatorOutputÚ	flip_backz·
    Output type of [`Sapiens2Backbone`], extending [`BackboneOutput`] with optional CLS tokens from
    each selected feature stage (used when `config.return_class_token=True`).
    )Úcustom_introc                   ó   € ] tR t^HtRtR# )ÚSapiens2BackboneOutput© N©Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__static_attributes__r>   ó    Ún/home/luca/screen-checking/.venv/lib/python3.14/site-packages/transformers/models/sapiens2/modular_sapiens2.pyr=   r=   H   s   † ó 	rE   r=   z6
    Class for outputs of pose estimation models.
    c                   ó   € ] tR t^StRtRtR# )ÚSapiens2PoseEstimatorOutputa°  
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided):
    Pose estimation loss.
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.
r>   N)r@   rA   rB   rC   Ú__doc__rD   r>   rE   rF   rH   rH   S   s   † õ	rE   rH   z8
    Class for outputs of normal estimation models.
    c                   ó@   a € ] tR t^ft o RtRtRtRtRtV 3R lt	Rt
V tR# )ÚSapiens2NormalEstimatorOutputaè  
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided):
    Normal estimation loss.
normals (`torch.FloatTensor` of shape `(batch_size, num_labels, height, width)`):
    Raw normal map predictions as output by the model (unnormalized).
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 + one for the output of each stage)
    of shape `(batch_size, sequence_length, hidden_size)`. Hidden-states of the model at the output of
    each layer plus the initial embedding outputs.
attentions (`tuple(torch.FloatTensor)`, *optional*, returned when `output_attentions=True` is passed or when `config.output_attentions=True`):
    Tuple of `torch.FloatTensor` (one per layer) of shape `(batch_size, num_heads, sequence_length,
    sequence_length)`. Attentions weights after the attention softmax.
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Únormals.Úhidden_statesÚ
attentions©ÚtorchÚFloatTensorÚtuple)ÚformatÚ__classdict__s   "€rF   Ú__annotate__Ú*Sapiens2NormalEstimatorOutput.__annotate__f   sy   ø‡ ‚ ñ* ×
Ñ
˜dÕ
"Ñ)ñ+ ñ, ×Ñ Õ%Ñ,ñ- ñ. ™×*Ñ*¨CÐ/Õ0°4Õ7Ñ>ñ/ ñ0 ‘e×'Ñ'¨Ð,Õ-°Õ4Ñ;ò1 rE   r>   )r@   rA   rB   rC   rI   rN   rO   rP   rQ   Ú__annotate_func__rD   Ú__classdictcell__©rW   s   @rF   rK   rK   f   s'   ø‡ € ñð &*€DØ(,€GØ:>€MØ7;€J÷1 ƒ rE   rK   z:
    Class for outputs of pointmap estimation models.
    c                   óD   a € ] tR t^�t o RtRtRtRtRtRt	V 3R lt
RtV tR# )ÚSapiens2PointmapEstimatorOutputaŒ  
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided):
    Pointmap estimation loss.
pointmaps (`torch.FloatTensor` of shape `(batch_size, 3, height, width)`):
    Per-pixel 3D XYZ coordinate predictions in canonical camera space.
scales (`torch.FloatTensor` of shape `(batch_size, 1)`, *optional*):
    Canonical focal length / actual focal length ratio. `None` when no scale branch is configured.
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 + one for the output of each stage)
    of shape `(batch_size, sequence_length, hidden_size)`. Hidden-states of the model at the output of
    each layer plus the initial embedding outputs.
attentions (`tuple(torch.FloatTensor)`, *optional*, returned when `output_attentions=True` is passed or when `config.output_attentions=True`):
    Tuple of `torch.FloatTensor` (one per layer) of shape `(batch_size, num_heads, sequence_length,
    sequence_length)`. Attentions weights after the attention softmax.
Nc                ó(  <€ V ^8„  d   Qh/ S[ P                  R,          ;R&   S[ P                  R,          ;R&   S[ P                  R,          ;R&   S[S[ P                  R3,          R,          ;R&   S[S[ P                  R3,          R,          ;R&   # )rM   NrN   Ú	pointmapsÚscales.rP   rQ   rR   )rV   rW   s   "€rF   rX   Ú,Sapiens2PointmapEstimatorOutput.__annotate__�   s‘   ø‡ ‚ ñ. ×
Ñ
˜dÕ
"Ñ)ñ/ ñ0 × Ñ  4Õ'Ñ.ñ1 ñ2 ×Ñ Õ$Ñ+ñ3 ñ4 ™×*Ñ*¨CÐ/Õ0°4Õ7Ñ>ñ5 ñ6 ‘e×'Ñ'¨Ð,Õ-°Õ4Ñ;ò7 rE   r>   )r@   rA   rB   rC   rI   rN   r`   ra   rP   rQ   rZ   rD   r[   r\   s   @rF   r^   r^   �   s,   ø‡ € ñð  &*€DØ*.€IØ'+€FØ:>€MØ7;€J÷7 ƒ rE   r^   z4
    Class for outputs of image matting models.
    c                   ó4   a € ] tR t^Ÿt o RtRtV 3R ltRtV tR# )ÚSapiens2ImageMattingOutputa"  
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided):
    Loss.
alphas (`torch.FloatTensor` of shape `(batch_size, 1, height, width)`):
    Estimated alpha values.
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.
foregrounds (`torch.FloatTensor` of shape `(batch_size, 3, height, width)`):
    Pre-multiplied RGB foreground predictions in `[0, 1]` (sigmoid-activated).
Nc                óH   <€ V ^8„  d   Qh/ S[ P                  R,          ;R&   # )rM   NÚforegrounds)rS   rT   )rV   rW   s   "€rF   rX   Ú'Sapiens2ImageMattingOutput.__annotate__Ÿ   s   ø‡ ‚ ñ( ×"Ñ" TÕ)Ñ0ò) rE   r>   )	r@   rA   rB   rC   rI   rf   rZ   rD   r[   r\   s   @rF   rd   rd   Ÿ   s   ø‡ € ñð -1€K÷) ƒ rE   rd   c          
      óÈ   € V ^8„  d   QhR\         P                  R\        \        \        3,          R\        R\        \         P                  \         P                  3,          /# )rM   ÚboxesÚoutput_sizeÚpaddingÚreturn©rS   ÚTensorrU   ÚintÚfloat)rV   s   "rF   rX   rX   ¶   sN   € ÷ #ñ #Ü�<‰<ð#ä”sœC�x•ð#ô ð#ô Œ5�<‰<œŸ™Ð%Õ&ñ	#rE   c           	     ób  € V P                  R4      w  r4rV\        P                  ! W4.RR7      pWR,          pWb,          p	Vw  r«Wº,          p\        P                  ! W‰V,          8„  R,          \        P                  ! WˆV,          .RR7      \        P                  ! Wœ,          V	.RR7      4      pW}3# )a  Compute crop center and scale from bounding boxes, applying padding and aspect ratio correction.

Accepts either a single box `(4,)` or multiple boxes `(num_boxes, 4)` and returns center/scale with a matching
leading dimension.

Args:
    boxes (`torch.Tensor` of shape `(4,)` or `(num_boxes, 4)`): Bounding box in
        (center-x, center-y, width, height) format, with values in absolute pixel coordinates.
    output_size (`tuple[int, int]`): Target output size as `(height, width)`, used to compute
        the aspect ratio for scale correction.
    padding (`float`, *optional*, defaults to `1.25`): Multiplicative factor applied to the
        bounding box dimensions, adding context around the region of interest.

Returns:
    `tuple[torch.Tensor, torch.Tensor]`: A pair `(center, scale)` where `center` has shape
    `(..., 2)` with (x, y) in input-image pixel coordinates, and `scale` has shape `(..., 2)`
    with (width, height) in input-image pixels representing the dimensions of the padded,
    aspect-ratio-corrected crop window.
©Údiméÿÿÿÿ).N)ÚunbindrS   ÚstackÚwhere)ri   rj   rk   Úcenter_xÚcenter_yÚwidthÚheightÚcenterÚscaled_widthÚscaled_heightÚoutput_heightÚoutput_widthÚaspect_ratioÚscales   &&&           rF   Úboxes_to_crop_paramsrƒ   ¶   s�   € ð0 ).¯©°RÓ(8Ñ%€H˜Ü�[Š[˜(Ð-°2Ô6€FØ•?€LØÕ$€MØ"-Ñ€MØÕ/€LÜ�KŠKØ	¨Õ4Ñ	4°iÕ@Ü�Š�\°,Õ#>Ð?ÀRÔHÜ�Š�]Õ1°=ÐAÀrÔJó€Eð
 ˆ=ÐrE   c          
      ó²   € V ^8„  d   QhR\         P                  R\         P                  R\        \        \        3,          R\        R\         P                  /# )rM   Úimageri   rj   rk   rl   rm   )rV   s   "rF   rX   rX   Ü   sN   € ÷ <ñ <Ü�<‰<ð<ä�<‰<ð<ô ”sœC�x•ð<ô ð	<ô
 ‡\�\ñ<rE   c           	     óò  € Vw  rEV P                   w  rgp\        WVR7      w  ršV	P                  R4      w  r¼V
P                  R4      w  rÞV^,
          V,          pV^,
          V,          p\        P                  ! VV4      R8  p\        P
                  ! \        P                  ! V\        P                  V P                  R7      \        P                  ! V\        P                  V P                  R7      RR7      w  ppVVR,          ,          VR,          ,           RVR,          ,          ,
          pVVR,          ,          VR,          ,           RVR,          ,          ,
          p\        P                  ! RV,          V^,
          ,          R,
          RV,          V^,
          ,          R,
          .RR7      pVP                   ^ ,          p\        P                  ! VWdWPP                  V P                  R	7      pV P                  ^ 4      pVR
3V( R33 Fc  w  ppVP                  4       '       g   K  \        P                  ! VP!                  VP#                  4       RRR4      VV,          VRRR7      VV&   Ke  	  V# )a  Crops and resizes bounding box regions from the input image to the target output size.

Applies padding and aspect ratio correction to each crop before resizing.
Uses bilinear interpolation for downscaling and bicubic for upscaling.

This implementation is equivalent to the cv2 affine warp with rotation=0 used in the original
Sapiens2 codebase. Rotation is always zero because we don't support rotated bounding boxes.

Args:
    image (`torch.Tensor`): Input image tensor of shape `(C, H, W)` in float32.
    boxes (`torch.Tensor`): Bounding boxes in (center-x, center-y, width, height) format,
        shape `(num_boxes, 4)`, with values in absolute pixel coordinates.
    output_size (`tuple[int, int]`): Target output size as `(height, width)`.
    padding (`float`, *optional*, defaults to `1.25`): Multiplicative factor applied to the
        bounding box dimensions before cropping, adding context around the region of interest.

Returns:
    `torch.Tensor`: Cropped and resized images of shape `(num_boxes, C, output_height, output_width)`.
)rj   rk   ç      ð?©ÚdtypeÚdeviceÚij)Úindexingç      à?g       @rr   ©rŠ   r‰   ÚbilinearÚbicubicÚzerosT)ÚmodeÚpadding_modeÚalign_cornersrt   ©ºNNNNN)Úshaperƒ   ru   rS   ÚminimumÚmeshgridÚarangeÚfloat32rŠ   rv   Úemptyr‰   Ú	unsqueezeÚanyÚFÚgrid_sampleÚexpandÚsum)r…   ri   rj   rk   r   r€   Únum_channelsÚinput_heightÚinput_widthr|   r‚   rx   ry   Úboxes_widthÚboxes_heightÚscale_xÚscale_yÚis_bilinearÚgrid_yÚgrid_xÚin_xÚin_yÚgridsÚ	num_boxesÚoutputÚimage_4dÚmaskr’   s   &&&&                        rF   Úcrop_and_resizer´   Ü   sþ  € ð2 #.Ñ€MØ.3¯k©kÑ+€L Ü(¨ÐQXÔY�M€FØŸ™ rÓ*Ñ€HØ %§¡¨RÓ 0Ñ€Kà˜aÕ ;Õ.€GØ˜qÕ  LÕ0€GÜ—-’- ¨Ó1°CÑ7€Kä—^’^Ü�Š�]¬%¯-©-ÀÇÁÔMÜ�Š�\¬¯©¸u¿|¹|ÔLØô�N€FˆFð
 �G˜MÕ*Õ*¨X°mÕ-DÕDÀsÈ[ÐYfÕMgÕGgÕg€DØ�G˜MÕ*Õ*¨X°mÕ-DÕDÀsÈ\ÐZgÕMhÕGhÕh€Dä�KŠK˜˜t� {°Q¥Õ7¸#Õ=¸sÀT½zÈ\Ð\]ÕM]Õ?^ÐadÕ?dÐeÐkmÔn€Eà—‘˜A•€IÜ�[Š[˜ LÀ×VbÑVbÐjo×juÑjuÔv€Fð �‰˜qÓ!€HØ# ZÐ0°K°<ÀÐ2KÓL‰
ˆˆdØ�8‰8�:Œ:ÜŸ=š=Ø—‘ §¡£
¨B°°BÓ7Ø�d•ØØ$Ø"ôˆF�4‹Lñ Mð €MrE   c                ód   € V ^8„  d   QhR\         P                  R\        R\         P                  /# )rM   ÚheatmapsÚkernelrl   ©rS   rn   ro   )rV   s   "rF   rX   rX     s)   € ÷ )ñ )¬¯©ð )¼sð )ÌEÏLÉLñ )rE   c                óh  € V^,          ^ 8X  g   V^8:  d   \        R4      hRV^,
          R,          ^,
          ,          R,           pV^,
          ^,          pV P                  RR7      p\        P                  ! WW3V3RRR7      p\        P
                  ! WQV.W".R	7      pVR
W3) 1W3) 13,          pVP                  RR7      p\        P                  ! V^ 8„  V\        P                  ! V4      4      p	\        P                  ! V^ 8„  WI,          \        P                  ! V4      4      p
WzR,          ,          # )aŒ  Gaussian blur per-keypoint heatmap, preserving the original max value.

Matches cv2.GaussianBlur with sigma=0 which means that the sigma is automatically
computed from the kernel size.

Args:
    heatmaps: Shape `(K, height, width)`.
    kernel: Odd integer kernel size for the Gaussian blur. Must be greater than 1.

Returns:
    `torch.Tensor`: Blurred heatmaps of the same shape as the input.
z2Kernel size must be an odd integer greater than 1.g333333Ó?r�   gš™™™™™é?rr   Úconstantç        )r’   Úvalue)Úkernel_sizeÚsigmar–   )é   rM   r•   )	Ú
ValueErrorÚamaxrŸ   ÚpadÚtvFÚgaussian_blurrS   rw   Ú	ones_like)r¶   r·   r¾   ÚborderÚorigin_maxesÚpaddedÚblurredÚresultÚresult_maxesÚ
safe_maxesr‚   s   &&         rF   Úgaussian_blur_preserve_maxrÍ     s  € ð �…z�Q„˜& Aœ+ÜÐMÓNÐNØ�F˜Q•J #Õ%¨Õ)Õ*¨SÕ0€EØ�q�j˜QÕ€FØ—=‘= V�=Ó,€Lô �UŠU�8 f°fÐ=ÀJÐVYÔZ€FÜ×Ò ¸VÐ4DÈUÈNÔ[€GØ�Q˜˜w˜¨¨w¨Ð6Õ7€Fà—;‘; 6�;Ó*€LÜ—’˜\¨AÑ-¨|¼U¿_º_È\Ó=ZÓ[€JÜ�KŠK˜ qÑ(¨,Õ*CÄUÇ_Â_ÐUaÓEbÓc€EØ˜-Õ(Õ(Ð(rE   c                óŽ   € V ^8„  d   QhR\         P                  R\        \         P                  \         P                  3,          /# )rM   r¶   rl   )rS   rn   rU   )rV   s   "rF   rX   rX   9  s0   € ÷ ñ ¤u§|¡|ð ¼¼e¿l¹lÌEÏLÉLÐ>XÕ8Yñ rE   c           
     ó¶  € V P                   w  rr4V P                  pV P                  WR4      pVP                  RR7      pVP	                  RR7      pW„,          P                  4       p	W„,          P                  4       p
\        P                  ! VP                  R4      R8„  \        P                  ! Wš.RR7      \        P                  ! W^3RVR7      4      pW·3# )a+  Predict keypoint locations and confidence scores from heatmaps.

Args:
    heatmaps: Shape `(num_persons, num_keypoints, height, width)`.

Returns:
    locations: `(num_persons, num_keypoints, 2)` x/y in heatmap pixel coordinates.
    scores: `(num_persons, num_keypoints)` per-keypoint confidence.
rr   r»   ©rŠ   rt   g      ð¿)r—   rŠ   ÚreshaperÁ   Úargmaxrp   rS   rw   r�   rv   Úfull)r¶   Únum_personsÚnum_keypointsÚ_Úheatmap_widthrŠ   Úheatmap_flatÚscoresÚ
flat_indexÚlocations_xÚlocations_yÚ	locationss   &           rF   Úget_keypoint_predictionsrÞ   9  sÇ   € ð 4<·>±>Ñ0€K Ø�_‰_€FØ×#Ñ# KÀÓC€LØ×Ñ 2ÐÓ&€FØ×$Ñ$¨Ð$Ó,€JØÕ-×4Ñ4Ó6€KØÕ.×5Ñ5Ó7€KÜ—’Ø×Ñ˜Ó˜sÑ"Ü�Š�[Ð.°BÔ7Ü�
Š
�K°Ð2°DÀÔHó€Ið
 ÐÐrE   c                ó„   € V ^8„  d   QhR\         P                  R\         P                  R\        R\         P                  /# )rM   Ú	keypointsr¶   Úblur_kernel_sizerl   r¸   )rV   s   "rF   rX   rX   R  s>   € ÷ E?ñ E?Ü�|‰|ðE?Ü',§|¡|ðE?ÜGJðE?ä
‡\�\ñE?rE   c                ó:  € VP                   w  r4rVVP                  p\        VP                  W4,          WV4      V4      P                  W4WV4      pVP	                  RR4      P                  4       p\        P                  ! VRRR7      pVP                  4       p	V^,           p
V^,           pW«,          pWL,          pV R	,          P                  4       ^,           V R
,          P                  4       ^,           V,          ,           pWì\        P                  ! WG\        P                  R7      R,          ,          ,           pWí\        P                  ! W7\        P                  R7      R,          ,          ,           pVP                  R4      pR^ R^RRRVRV) RV^,           RV^,           ) /pVP                  4        UUUu/ uF  w  w  pppVV3WžV,           ,          bK  	  ppppRVR,          VR,          ,
          ,          pRVR,          VR,          ,
          ,          pVR,          ^VR,          ,          ,
          VR,          ,           pVR,          ^VR,          ,          ,
          VR,          ,           pRVR,          VR,          ,
          VR,          ,
          VR,          ,           VR,          ,           VR,          ,
          VR,          ,
          VR,          ,           ,          p\        P                  ! VP                  4      P                   pVV,           pVV,           pVV,          VV,          ,
          pVV,          VV,          ,
          V,          pV) V,          VV,          ,           V,          pV \        P"                  ! VV.RR7      ,
          # u upppi )a1  Sub-pixel refinement via Hessian on log-heatmaps (UDP Dark Pose).

Args:
    keypoints: Shape `(num_persons, num_keypoints, 2)` x/y in heatmap pixel coordinates.
    heatmaps: Shape `(num_persons, num_keypoints, height, width)`.

Returns:
    `(num_persons, num_keypoints, 2)` refined keypoint locations.
gü©ñÒMbP?g      I@Ú	replicate)r’   rŽ   r�   rr   )r¿   r¿   r¿   r¿   )r–   r–   r   )r–   r–   r¿   )Nr–   )r–   Nrt   )r   r   )r   r¿   )r   rt   )r¿   r   )rt   r   )r¿   r¿   )rt   rt   )r—   rŠ   rÍ   rÑ   ÚclampÚlogrŸ   rÂ   ÚflattenÚlongrS   rš   r�   ÚitemsÚfinfor‰   ÚepsÚcat)rà   r¶   rá   rÔ   rÕ   Úheatmap_heightr×   rŠ   Úheatmaps_paddedÚheatmaps_flattenedÚpadded_heightÚpadded_widthÚkeypoint_strideÚperson_strideÚindexÚposition_to_index_offsetÚdxÚdyÚoffsetÚheatmap_valuesÚ
gradient_xÚ
gradient_yÚ
hessian_xxÚ
hessian_yyÚ
hessian_xyrê   ÚdeterminantÚoffset_xÚoffset_ys   &&&                          rF   Ú"post_dark_unbiased_data_processingr  R  sD  € ð AIÇÁÑ=€K Ø�_‰_€Fä)Ø×Ñ˜Õ4°nÓTÐVfóç�gˆk¨.ÓHð ð �~‰~˜d DÓ)×-Ñ-Ó/€Hä—e’e˜H l¸ÔE€OØ(×0Ñ0Ó2Ðà" QÕ&€MØ  1Õ$€LØ#Õ2€OØ!Õ3€Mà�gÕ×#Ñ#Ó%¨Õ)¨Y°wÕ-?×-DÑ-DÓ-FÈÕ-JÈlÕ,ZÕZ€EØ¤e§l¢l°=ÔW\×WaÑWaÔ&bÐcjÕ&kÕkÕk€EØ¤E§L¢L°ÔSX×S]ÑS]Ô$^Ð_fÕ$gÕgÕg€EØ�O‰O˜BÓ€Eð 	�Ø�Ø�Ø�Ø�,�Ø�˜qÕ Ø�L 1Õ$Ð%ð Ðð Nf×MkÑMkÔMmõÙMmÑ9I¹¸"¸bÀ6ˆˆRˆÐ$¨V¥^Õ4Ò4ÑMmð ò ð ˜ tÕ,¨~¸eÕ/DÕDÕE€JØ˜ tÕ,¨~¸eÕ/DÕDÕE€Jà Õ%¨¨N¸4Õ,@Õ(@Õ@À>ÐRWÕCXÕX€JØ Õ%¨¨N¸4Õ,@Õ(@Õ@À>ÐRWÕCXÕX€JØØ�tÕØ
˜Õ
õ	à
˜Õ
õ	ð ˜Õ
õ	ð ˜Õ
õ		ð
 ˜Õ
õ	 ð ˜Õ
õ	 ð ˜Õ
 õ	!õ	€Jô �+Š+�j×&Ñ&Ó
'×
+Ñ
+€CØ˜cÕ!€JØ˜cÕ!€JØ˜zÕ)¨J¸Õ,CÕC€KØ˜ZÕ'¨*°zÕ*AÕAÀ[ÕP€HØ�˜jÕ(¨:¸
Õ+BÕBÀkÕQ€HØ”u—y’y (¨HÐ!5¸2Ô>Õ>Ð>ùô5s   Æ:!Nc                   ó   € ] tR tRtRtR# )ÚSapiens2ImageProcessorKwargsiš  r>   Nr?   r>   rE   rF   r  r  š  ó   † ÛrE   r  F)Útotalc                   ó.  a a€ ] tR tRt o]t]P                  t]	t
]tRRRR/tRtV3R lV 3R llt]RV3R	 lR
 ll4       tRV3R lV 3R llltRV3R lR lltRV3R lR lltRV3R lR lltRV3R lR lltRV3R lR lltV3R lR ltRtVtV ;t# )ÚSapiens2ImageProcessoriž  r{   é   rz   i   Fc                ó0   <€ V ^8„  d   QhRS[ S[,          /# )rM   Úkwargs)r   r  )rV   rW   s   "€rF   rX   Ú#Sapiens2ImageProcessor.__annotate__§  s   ø€ ÷ #ñ #¡Ñ(DÕ!Eñ #rE   c                ó(   <€ \         SV `  ! R/ VB  R # ©Nr>   )ÚsuperÚ__init__©Úselfr
  Ú	__class__s   &,€rF   r  ÚSapiens2ImageProcessor.__init__§  s   ø€ Ü‰ÒÑ"˜6Ô"rE   c          
      ó”   <€ V ^8„  d   QhRS[ RS[ R,          RS[S[S[S[,          ,          ,          R,          RS[S[,          RS[/# )rM   ÚimagesÚsegmentation_mapsNri   r
  rl   )r   Úlistrp   r   r  r   )rV   rW   s   "€rF   rX   r  «  sb   ø€ ÷ Yñ YáðYñ &¨Õ,ðYñ ‘D™™e�Õ%Õ&¨Õ-ð	Yñ
 Ñ5Õ6ðYñ 
ñYrE   c                ó2   € \         P                  ! WV3/ VB # )aÌ  
segmentation_maps (`ImageInput`, *optional*):
    The segmentation maps to preprocess.
boxes (`list[list[list[float]]]` or `np.ndarray`, *optional*):
    List or array of bounding boxes for each image. Each box should be a list of 4 floats
    representing the bounding box coordinates in COCO format
    (top_left_x, top_left_y, width, height). When provided, each person crop is
    affine-warped to the model input size instead of resizing the full image.
)r
   Ú
preprocess)r  r  r  ri   r
  s   &&&&,rF   r  Ú!Sapiens2ImageProcessor.preprocessª  s   € ô" "×,Ò,¨VÈÑXÐQWÑXÐXrE   c                óÖ   <€ V ^8„  d   QhRS[ RS[ R,          RS[S[S[S[,          ,          ,          R,          RS[RS[RS[S[,          R,          RS[S[R	3,          R,          R
S[/# )rM   r  r  Nri   Údo_convert_rgbÚinput_data_formatÚreturn_tensorsrŠ   ztorch.devicerl   )	r   r  rp   Úboolr   Ústrr    r   r   )rV   rW   s   "€rF   rX   r  ½  sŒ   ø€ ÷ 
ñ 
áð
ñ &¨Õ,ð
ñ ‘D™™e�Õ%Õ&¨Õ-ð	
ñ
 ð
ñ ,ð
ñ ™jÕ(¨4Õ/ð
ñ ‘c˜>Ð)Õ*¨TÕ1ð
ñ 
ñ
rE   c                óF   <€ W8R&   \         S	V `  ! V 3RVRVRVRVRVRV/VB # )z"Handle extra inputs beyond images.ri   r  r  r  r  r  rŠ   )r  Ú_preprocess_image_like_inputs)
r  r  r  ri   r  r  r  rŠ   r
  r  s
   &&&&&&&&,€rF   r"  Ú4Sapiens2ImageProcessor._preprocess_image_like_inputs½  se   ø€ ð  ˆw‰Ü‰wÒ4Øñ	
àð	
ð 0ð	
ð *ð		
ð
 0ð	
ð *ð	
ð ð	
ð ñ	
ð 		
rE   c          !      óh  <€ V ^8„  d   QhRS[ S[P                  ,          RS[RS[RRRS[RS[RS[R	S[R
S[RS[S[ S[,          ,          R,          RS[S[ S[,          ,          R,          RS[R,          RS[RS[RS[ S[ S[ S[,          ,          ,          R,          RS[ S[P                  ,          /# )rM   r  Ú	do_resizeÚsizeÚresamplez7PILImageResampling | tvF.InterpolationMode | int | NoneÚdo_center_cropÚ	crop_sizeÚ
do_rescaleÚrescale_factorÚdo_normalizeÚ
image_meanNÚ	image_stdÚdisable_groupingÚdo_reduce_labelsÚdo_padri   rl   )r  rS   rn   r  r   rp   )rV   rW   s   "€rF   rX   r  Õ  s  ø€ ÷ 8Nñ 8Ná‘U—\‘\Õ"ð8Nñ ð8Nñ ð	8Nð
 Lð8Nñ ð8Nñ ð8Nñ ð8Nñ ð8Nñ ð8Nñ ™D¡�KÕ'¨$Õ.ð8Nñ ™4¡�;Õ&¨Õ-ð8Nñ  �+ð8Nñ ð8Nñ ð8Nñ  ‘D™™e�Õ%Õ&¨Õ-ð!8Nñ$ 
‰e�l‰lÕ	ñ%8NrE   c           	     ó¦  € Ve¬   VR,          VR,          3p. p\        W4       F„  w  pp\        P                  ! V\        P                  RR7      p\        \        P                  ! V\        P                  VP                  R7      4      pVP                  \        VVVR7      4       K†  	  TpRpV'       d   V P                  V4      p\        WR7      w  pp/ pVP                  4        Fn  w  ppV'       d\   V'       dB   \        VR,          VR,          R7      pV P                  VVV4      pV P                  VV4      pMV P                  VW44      pVVV&   Kp  	  \!        VV4      p\        VVR7      w  pp/ pVP                  4        F9  w  ppV'       d   V P                  VV4      pV P#                  VWxWšV4      pVVV&   K;  	  \!        VV4      # )	Nr{   rz   F©r‰   r‚   rˆ   )ri   rj   )r/  )Ú
max_heightÚ	max_width)ÚziprÃ   Úto_dtype_imagerS   r›   r6   ÚtensorrŠ   Úextendr´   Úreduce_labelr   rè   r   ÚresizeÚcenter_cropr   Úrescale_and_normalize)r  r  r%  r&  r'  r(  r)  r*  r+  r,  r-  r.  r/  r0  r1  ri   r
  rj   Úcropsr…   Úimage_boxesÚboxes_tensorÚgrouped_imagesÚgrouped_images_indexÚresized_images_groupedr—   Ústacked_imagesÚaspect_ratio_sizeÚresized_imagesÚprocessed_images_groupeds   &&&&&&&&&&&&&&&&,             rF   Ú_preprocessÚ"Sapiens2ImageProcessor._preprocessÕ  sÂ  € ð& ÒØ �>¨4°­=Ð9ˆKØˆEÜ&)¨&Ö&8Ñ"��{Ü×*Ò*¨5¼¿¹ÈUÔS�Ü1´%·,²,¸{ÔRW×R_ÑR_Ðhm×htÑhtÔ2uÓv�Ø—‘œ_¨U¸,ÐT_Ô`Öañ '9ð ˆFØˆIçØ×&Ñ& vÓ.ˆFä/DÀVÔ/oÑ,ˆÐ,Ø!#ÐØ%3×%9Ñ%9Ö%;Ñ!ˆE�>ßßä(0¸DÀ½NÐVZÐ[bÕVcÔ(dÐ%Ø%)§[¡[°ÐARÐT\Ó%]�NØ%)×%5Ñ%5°nÀdÓ%K‘Nà%)§[¡[°ÀÓ%P�NØ,:Ð" 5Ó)ñ &<ô (Ð(>Ð@TÓUˆä/DÀ^ÐfvÔ/wÑ,ˆÐ,Ø#%Ð Ø%3×%9Ñ%9Ö%;Ñ!ˆE�>ßØ!%×!1Ñ!1°.À)Ó!L�Ø!×7Ñ7Ø 
¸LÐV_óˆNð /=Ð$ UÓ+ñ &<ô Ð6Ð8LÓMÐMrE   c                óN  <€ V ^8„  d   QhRS[ S[ S[ S[,          ,          ,          RS[RS[R,          RS[S[ S[S[S[3,          ,          ,          R,          RS[S[ S[S[S[3,          ,          ,          R,          RS[ S[ S[S[S[P                  3,          ,          ,          /# )rM   ri   r½   Ú	thresholdNÚsource_sizesÚtarget_sizesrl   )	r  rp   ro   r    rU   Údictr   rS   rn   )rV   rW   s   "€rF   rX   r    s©   ø€ ÷ Lñ Lñ ‘D™™e�Õ%Õ&ðLñ
 ðLñ ˜4•<ðLñ !¡4©©c±3¨h­Õ#8Õ8¸4Õ?ðLñ !¡4©©c±3¨h­Õ#8Õ8¸4Õ?ðLñ 
‰d‘4™™UŸ\™\Ð)Õ*Õ+Õ	,ñLrE   c                ó  € \        V\        P                  4      '       d   VP                  4       p\        V\        P                  4      '       d   VP                  4       p\	        V4      pVe   Vf   \        R4      hVe   V\	        V4      8w  d   \        R4      hVe   V\	        V4      8w  d   \        R4      hVP                  p	Ve   W“P                  ,           ^,          p	V	P                  p
V	P                  w  r¼rÞV^ 8X  d   V Uu. uF  p. NK  	  up# \        P                  ! V UUu. uF  pV F  pVNK  	  K  	  upp\        P                  V
R7      pV	P                  4       p	\        V	4      w  pp\        VW”R7      p\        \        V4      V P                   R,          V P                   R,          3R7      w  pp\        P                  ! V^,
          V^,
          .\        P                  V
R7      pVV,          VR,          ,          VR,          ,           R
VR,          ,          ,
          p\#        V4      pVeí   Veé   \        P                  ! \%        Wg4       UUUUu. uF  w  w  ppw  ppVV,          VV,          .NK   	  upppp\        P                  V
R7      p\        P&                  ! \)        V4       Uu. uF;  pVV,          P+                  ^ 4      P-                  \	        VV,          4      ^4      NK=  	  up4      pVVR,          ,          pVVR	. RO3,          ,          p. p \)        V4       Fp  p!VV!,          p"VV!,          p#\        P.                  ! WÊR7      p$Ve!   V#V8„  p%V"V%,          p"V#V%,          p#V$V%,          p$V P1                  RV"RV#RV$RVV!,          /4       Kr  	  . p&^ p'V F2  p\	        V4      p(V&P1                  V V'V'V(,            4       V'V(,          p'K4  	  V&# u upi u uppi u uppppi u upi )aÜ	  
Converts the output of [`Sapiens2ForPoseEstimation`] into keypoint predictions in image space.

Args:
    outputs (`Sapiens2PoseEstimatorOutput`):
        Raw outputs of the model. `outputs.heatmaps` must have shape
        `(N_total, num_keypoints, heatmap_height, heatmap_width)` where
        `N_total = sum(len(b) for b in boxes)`.
    boxes (`list[list[list[float]]]` or `np.ndarray`):
        List or array of bounding boxes for each image in absolute pixel coordinates. Each box
        should be a list of 4 floats representing the bounding box coordinates in COCO format
        (top_left_x, top_left_y, width, height). Must match the `boxes` argument passed to
        `preprocess`.
    outputs_flipped (`Sapiens2PoseEstimatorOutput`, *optional*):
        Outputs from running the model on horizontally flipped inputs. When provided, heatmaps
        are averaged with `outputs` before keypoint extraction to improve accuracy:
        `avg_heatmaps = (outputs.heatmaps + outputs_flipped.heatmaps) / 2`.
    kernel_size (`int`, *optional*, defaults to 11):
        Kernel size for the Gaussian blur used in UDP Dark Pose refinement.
    threshold (`float`, *optional*):
        Score threshold. Keypoints with scores at or below this value are
        filtered out from the result dictionaries.
    source_sizes (`torch.Tensor` or `list[tuple[int, int]]` of length `batch_size`, *optional*):
        Original `(height, width)` of each image in pixels. Required when `target_sizes` is
        provided, as the source coordinate space for scaling keypoints and bounding boxes.
    target_sizes (`torch.Tensor` or `list[tuple[int, int]]` of length `batch_size`, *optional*):
        Desired output `(height, width)` coordinate space for each image. When provided
        alongside `source_sizes`, keypoint coordinates and bounding boxes are scaled from
        source to target space.

Returns:
    `list[list[dict]]`: Outer list is over images, inner list is over persons.
    Each dict contains:
    - `keypoints` (`torch.FloatTensor` of shape `(num_keypoints, 2)`): absolute x/y coordinates in
      the source image space, or in target space if `target_sizes` is provided.
    - `scores` (`torch.FloatTensor` of shape `(num_keypoints,)`): per-keypoint confidence.
    - `labels` (`torch.LongTensor` of shape `(num_keypoints,)`): keypoint indices.
    - `bbox` (`torch.FloatTensor` of shape `(4,)`): bounding box in absolute (x_min, y_min, x_max, y_max)
       format, in the same coordinate space as `keypoints`.
zA`source_sizes` must be provided when `target_sizes` is specified.zHMake sure that you pass in as many source sizes as the number of images.zHMake sure that you pass in as many target sizes as the number of images.rˆ   )rà   r¶   rá   r{   rz   )rj   r–   r�   rÐ   rà   rÙ   ÚlabelsÚbbox)r–   Nr–   )r   r¿   r   r¿   )Ú
isinstancerS   rn   ÚtolistÚlenrÀ   r¶   rŠ   r—   r8  r›   rp   rÞ   r  rƒ   r6   r&  r7   r6  rë   Úranger�   r¡   rš   Úappend))r  Úoutputsri   Úoutputs_flippedr½   rK  rL  rM  Ú
num_imagesr¶   rŠ   Únum_total_personsrÕ   rì   r×   rÖ   r?  Úboxr@  Úall_keypointsÚ
all_scoresÚcentersra   Úheatmap_sizeÚ	all_boxesÚsource_heightÚsource_widthÚtarget_heightÚtarget_widthÚper_image_scaleÚimage_indexÚper_person_scaleÚperson_resultsÚperson_indexrà   rÙ   rP  ÚkeeprÊ   Úperson_offsetÚnum_persons_in_images)   &&&&&&&&                                 rF   Úpost_process_pose_estimationÚ3Sapiens2ImageProcessor.post_process_pose_estimation  sÎ  € ôd �l¤E§L¡L×1Ò1Ø'×.Ñ.Ó0ˆLÜ�l¤E§L¡L×1Ò1Ø'×.Ñ.Ó0ˆLä˜“Zˆ
àÒ#¨Ò(<ÜÐ`ÓaÐaØÒ#¨
´c¸,Ó6GÔ(GÜÐgÓhÐhØÒ#¨
´c¸,Ó6GÔ(GÜÐgÓhÐhà×#Ñ#ˆØÒ&Ø ×#;Ñ#;Õ;¸qÕ@ˆHà—‘ˆØJRÏ.É.ÑGÐ¨.à Ô!Ù %Ó&¡˜1“B¡Ñ&Ð&ô —|’|Ù$)ÔA¡E�[³[¨c‹S±[‰S¡EÒAÌÏÉÐ_eô
ˆð —>‘>Ó#ˆô %=¸XÓ$FÑ!ˆ�zÜ:Ø#¨hô
ˆô
 /Ü˜|Ó,¸4¿9¹9ÀXÕ;NÐPT×PYÑPYÐZaÕPbÐ:cô
‰ˆ�ô —|’| ]°QÕ%6¸ÈÕ8JÐ$KÔSX×S`ÑS`ÐioÔpˆà˜LÕ(¨6°*Õ+=Õ=ÀÈ
Õ@SÕSÐVYÐ\bÐcmÕ\nÕVnÕnð 	ô % \Ó2ˆ	àÒ#¨Ò(@ä#Ÿlšlô Y\Ð\hÔXwöáXwÑTÑ5˜¨Ñ7T¸À|ð " LÕ0°-À-Õ2OÓPÙXwôô —m‘mØôˆOô  %Ÿyšyô (-¨ZÔ'8óá'8˜ð $ KÕ0×:Ñ:¸1Ó=×DÑDÄSÈÈ{ÕI[ÓE\Ð^_Ö`Ù'8ñó Ðð *Ð,<¸ZÕ,HÕHˆMØ!Ð$4°Qº°_Õ$EÕEˆIàˆÜ!Ð"3Ö4ˆLØ% lÕ3ˆIØ Õ-ˆFÜ—\’\ -Ô?ˆFàÒ$Ø 	Ñ)�Ø% d�O�	Ø ��Ø ��à×!Ñ!Ø˜i¨°6¸8ÀVÈVÐU^Ð_kÕUlÐmöñ 5ð  ˆØˆÛ ˆKÜ#& {Ó#3Ð Ø�M‰M˜.¨¸ÐI]Õ9]Ð^Ô_ØÐ1Õ1ŠMñ !ð ˆùòI 'ùó Bùõ0ùòs   ÄO/Ä/O4
É($O:ËAPc                ó  <€ V ^8„  d   QhRS[ S[S[S[S[3,          ,          ,          R,          RS[ S[S[S[S[3,          ,          ,          R,          RS[R,          RS[S[S[S[P                  3,          ,          /# ©rM   rL  NrM  Údo_remove_paddingrl   ©	r    r  rU   ro   r  rN  r   rS   rn   )rV   rW   s   "€rF   rX   r  �  sz   ø€ ÷ ";ñ ";ñ !¡4©©c±3¨h­Õ#8Õ8¸4Õ?ð";ñ !¡4©©c±3¨h­Õ#8Õ8¸4Õ?ð	";ñ
   $�;ð";ñ 
‰d‘3™Ÿ™Ð$Õ%Õ	&ñ";rE   c                ó¢   € \         P                  ! VP                  ^^RR7      pV P                  WRW4R7      pV Uu. uF  pRV/NK	  	  up# u upi )a  
Converts the output of [`Sapiens2ForNormalEstimation`] into L2-normalized surface normal maps.

Args:
    outputs (`Sapiens2NormalEstimatorOutput`):
        Raw outputs of the model.
    source_sizes (`torch.Tensor` or `list[tuple[int, int]]` of length `batch_size`, *optional*):
        Original `(height, width)` of each image before preprocessing. When provided,
        the padding added during preprocessing is removed and predictions are resized back
        to the original image size (unless `target_sizes` overrides the final size).
    target_sizes (`torch.Tensor` or `list[tuple[int, int]]` of length `batch_size`, *optional*):
        Requested final `(height, width)` for each prediction. When provided, used as the
        resize target instead of `source_sizes`. Resized with bilinear interpolation after
        L2 normalization.
    do_remove_padding (`bool`, *optional*):
        Whether to crop away the zero-padding added during preprocessing before resizing.
        Defaults to `True` when `source_sizes` is provided, `False` otherwise.

Returns:
    `list[dict[str, torch.Tensor]]` of length `batch_size`. Each dict has a `"normals"` key
    mapping to a tensor of shape `(3, height, width)` with L2-normalized unit vectors in
    `[-1, 1]` per channel (XYZ surface normals).
g:Œ0âŽyE>)Úprs   rê   ©ÚmapsrL  rM  rq  rO   )rŸ   Ú	normalizerO   Ú_post_process_maps)r  rW  rL  rM  rq  rO   ÚresultsrÊ   s   &&&&&   rF   Úpost_process_normal_estimationÚ5Sapiens2ImageProcessor.post_process_normal_estimation�  sU   € ô< —+’+˜gŸo™o°¸¸tÔDˆØ×)Ñ)ØÀ,ð *ó 
ˆñ 3:Ó:±'¨�˜FÓ#±'Ñ:Ð:ùÒ:s   ¼Ac                ó  <€ V ^8„  d   QhRS[ S[S[S[S[3,          ,          ,          R,          RS[ S[S[S[S[3,          ,          ,          R,          RS[R,          RS[S[S[S[P                  3,          ,          /# rp  rr  )rV   rW   s   "€rF   rX   r  Á  sz   ø€ ÷ #<ñ #<ñ !¡4©©c±3¨h­Õ#8Õ8¸4Õ?ð#<ñ !¡4©©c±3¨h­Õ#8Õ8¸4Õ?ð	#<ñ
   $�;ð#<ñ 
‰d‘3™Ÿ™Ð$Õ%Õ	&ñ#<rE   c                óÀ   € VP                   pVP                  e   WQP                  R,          ,          pV P                  WRW4R7      pV Uu. uF  pRV/NK	  	  up# u upi )aô  
Converts the output of [`Sapiens2ForPointmapEstimation`] into pointmap tensors in image space.

Args:
    outputs (`Sapiens2PointmapEstimatorOutput`):
        Raw outputs of the model.
    source_sizes (`torch.Tensor` or `list[tuple[int, int]]` of length `batch_size`, *optional*):
        Original `(height, width)` of each image before preprocessing. When provided,
        the padding added during preprocessing is removed and predictions are resized back
        to the original image size (unless `target_sizes` overrides the final size).
    target_sizes (`torch.Tensor` or `list[tuple[int, int]]` of length `batch_size`, *optional*):
        Requested final `(height, width)` for each prediction. Overrides `source_sizes`
        as the resize target.
    do_remove_padding (`bool`, *optional*):
        Whether to crop away the zero-padding added during preprocessing before resizing.
        Defaults to `True` when `source_sizes` is provided, `False` otherwise.

Returns:
    `list[dict[str, torch.Tensor]]` of length `batch_size`. Each dict has a `"pointmap"` key
    mapping to a tensor of shape `(3, height, width)` with per-pixel 3D XYZ coordinates in
    canonical camera space, optionally divided by `outputs.scales` to convert to metric coordinates.
ru  Úpointmap)r–   r–   NN)r`   ra   rx  )r  rW  rL  rM  rq  r`   ry  rÊ   s   &&&&&   rF   Ú post_process_pointmap_estimationÚ7Sapiens2ImageProcessor.post_process_pointmap_estimationÁ  sd   € ð: ×%Ñ%ˆ	Ø�>‰>Ò%Ø!§N¡NÐ3CÕ$DÕDˆIØ×)Ñ)ØÀLð *ó 
ˆñ 4;Ó;±7¨�˜VÓ$±7Ñ;Ð;ùÒ;s   ÁAc          	      ó¸   <€ V ^8„  d   QhRS[ S[S[S[S[3,          ,          ,          R,          RS[R,          RS[S[S[S[P                  3,          ,          /# )rM   rM  NÚbackgroundsrl   )	r    r  rU   ro   r   rN  r   rS   rn   )rV   rW   s   "€rF   rX   r  æ  s_   ø€ ÷ Gñ Gñ !¡4©©c±3¨h­Õ#8Õ8¸4Õ?ðGñ   $Õ&ð	Gñ
 
‰d‘3™Ÿ™Ð$Õ%Õ	&ñGrE   c           	     ó’	  aa€ \        S\        P                  4      '       d   SP                  4       oVP                  P
                  ^ ,          pVP                  P                  pVP                  P                  pSe   V\        S4      8w  d   \        R4      hSRJ ;'       g;    \        ;QJ d    V3R lS 4       F  '       d   K   RM	  RM! V3R lS 4       4      p. oVeƒ   \        V4      p\        V4      ^8w  d   \        V4      V8w  d   \        R4      hV U	u. uF?  p	\        P                  ! \        P                  ! V	4      VRR7      P                  V4      NKA  	  up	oS'       * ;'       g;    \        ;QJ d    V3R lS 4       F  '       d   K   RM	  RM! V3R lS 4       4      p
\        P                   ! VP                  VP"                  .^R	7      pSeH   V'       d@   \%        S^ ,          4      p\&        P(                  ! VVR
RRR7      pVP+                  RR4      p. pV'       Ed   V
'       Ed   VR,          pVR,          pR.V,          pS'       d®   \        P,                  ! S4      pVP
                  RR VP
                  RR 8w  d)   \&        P(                  ! VVP
                  RR R
RRR7      pV^V,
          V,          ,           P+                  RR4      p\        P                  ! V\        P.                  RR7      p\1        WïV4       F  w  pppVP3                  RVRVRV/4       K   	  V# \5        \        V4      4       EFi  pVV,          pS'       dS   V'       gK   \&        P(                  ! VP7                  ^ 4      SV,          R
RRR7      ^ ,          pVP+                  RR4      pVR,          pVR,          pRpS'       dÐ   \        S4      ^8X  d
   S^ ,          MSV,          pVP
                  RR VP
                  RR 8w  d?   \&        P(                  ! VP7                  ^ 4      VP
                  RR R
RRR7      ^ ,          pV^V,
          V,          ,           P+                  RR4      p\        P                  ! V\        P.                  RR7      pVP3                  RVRVRV/4       EKl  	  V# u up	i )a`  
Converts the output of [`Sapiens2ForImageMatting`] into alpha mattes and foreground maps.

Args:
    outputs (`Sapiens2ImageMattingOutput`):
        Raw outputs of the model.
    target_sizes (`torch.Tensor` or `list[tuple[int, int]]` of length `batch_size`, *optional*):
        Requested final `(height, width)` for each prediction. Resized with bilinear
        interpolation. If unset, predictions are returned at the model output resolution.
    backgrounds (`ImageInput`, *optional*):
        Background image(s) to composite over. Can be a single image (applied to every item
        in the batch) or a list of images, one per batch item. Accepts PIL images, numpy
        arrays, or torch tensors of any dtype; integer types (e.g. uint8) are scaled to
        `[0, 1]` automatically. When provided, each result dict gains a `"composite"` key
        with the composited image as a uint8 tensor in `[0, 255]`.

Returns:
    `list[dict]` of length `batch_size`. Each dict has:
    - `"alpha"` (`torch.Tensor` of shape `(1, height, width)`): alpha values in `[0, 1]`.
    - `"foreground"` (`torch.Tensor` of shape `(3, height, width)`): pre-multiplied RGB in `[0, 1]`.
    - `"composite"` (`torch.Tensor` of shape `(3, height, width)` or `None`): foreground composited
      over `backgrounds` as a uint8 tensor in `[0, 255]`; `None` when `backgrounds` is not provided.
Nz\Make sure that you pass in as many target sizes as the batch dimension of the matting outputc              3   ó`   <"  € T F#  p\        V4      \        S^ ,          4      8H  x € K%  	  R# 5i©r   N)rU   )Ú.0r&  rM  s   & €rF   Ú	<genexpr>ÚDSapiens2ImageProcessor.post_process_image_matting.<locals>.<genexpr>  s&   øé € ð =
Ù>J°dŒE�$‹Kœ5 ¨a¥Ó1Ö1»lùs   ƒ+.FTz[Make sure that you pass in as many backgrounds as the batch dimension of the matting outputr3  c              3   ón   <"  € T F*  qP                   RR S^ ,          P                   RR 8H  x € K,  	  R# 5i)rM   Néþÿÿÿ)r—   )r†  Ú
backgroundÚbackground_tensorss   & €rF   r‡  rˆ    s9   øé € ð C
ÙXjÈ*×Ñ˜R˜SÐ!Ð%7¸Õ%:×%@Ñ%@ÀÀÐ%EÖEÓXjùs   ƒ25rr   r�   ©r&  r’   r”   Ú	antialiasr»   r‡   ºNé   Nºr�  NNÚ
foregroundÚalphaÚ	composite©r–   r�  ©r–   r‘  rŠ  )rR  rS   rn   rS  rf   r—   rŠ   r‰   rT  rÀ   Úallr   rÃ   r7  Úto_imageÚtorë   ÚalphasrU   rŸ   Úinterpolaterä   rv   Úuint8r6  rV  rU  r�   )r  rW  rM  r‚  Ú
batch_sizerŠ   r‰   Úall_target_sizes_equalÚbackground_listÚbackground_imageÚall_background_sizes_equalÚmattingÚtarget_sizerÊ   rf   rš  Ú
compositesr‹  r’  r“  r”  ró   Úmatting_itemrŒ  s   &&f&                   @rF   Úpost_process_image_mattingÚ1Sapiens2ImageProcessor.post_process_image_mattingæ  sj  ù€ ô: �l¤E§L¡L×1Ò1Ø'×.Ñ.Ó0ˆLà×(Ñ(×.Ñ.¨qÕ1ˆ
Ø×$Ñ$×+Ñ+ˆØ×#Ñ#×)Ñ)ˆàÒ#ØœS Ó.Ô.Ü Øróð ð ".°Ð!5÷ "
ð "
¿»ô =
Ù>Jó=
¿¿ºô =
Ù>Jó=
ó :
Ðð  ÐØÒ"Ü1°+Ó>ˆOÜ�?Ó# qÔ(¬S°Ó-AÀZÔ-OÜ Øqóð ñ
 )8ó"á(7Ð$ô ×"Ò"¤3§<¢<Ð0@Ó#AÈÐVZÔ[×^Ñ^Ð_eÖfÙ(7ñ"Ðð *<Ô%;÷ &
ð &
¿s»sô C
ÙXjóC
¿s¿sºsô C
ÙXjóC
ó @
Ð"ô —)’)˜W×0Ñ0°'·.±.ÐAÀqÔIˆàÒ#×(>Ü ¨Q¥Ó0ˆKÜ—m’mØØ ØØ#ØôˆGð —m‘m C¨Ó-ˆGàˆß!Ð!×&@Ð&@à! %�.ˆKØ˜U•^ˆFØ˜ *Õ,ˆJß!Ü"Ÿ[š[Ð);Ó<�
Ø×#Ñ# B CÐ(¨G¯M©M¸"¸#Ð,>Ô>Ü!"§¢Ø"Ø$Ÿ]™]¨2¨3Ð/Ø'Ø&+Ø"'ô"�Jð *¨Q°­Z¸:Õ,EÕE×LÑLÈSÐRUÓV�
Ü ×/Ò/°
Ä%Ç+Á+ÐUYÔZ�
ä03°KÈÖ0TÑ,�
˜E 9Ø—‘à$ jØ Ø# Yðöñ 1UðV ˆôA œs 7›|×,�Ø& u�~�ç×(>Ü#$§=¢=Ø$×.Ñ.¨qÓ1Ø)¨%Õ0Ø'Ø&+Ø"'ô$ð õ$�Lð $0×#5Ñ#5°c¸3Ó#?�Là)¨"Õ-�
Ø$ RÕ(�Ø �	ç%Ü:=Ð>PÓ:QÐUVÔ:VÐ!3°AÖ!6Ð\nÐotÕ\u�JØ!×'Ñ'¨¨Ð,°×0BÑ0BÀ2À3Ð0GÔGÜ%&§]¢]Ø&×0Ñ0°Ó3Ø!-×!3Ñ!3°B°CÐ!8Ø!+Ø*/Ø&+ô&ð õ&˜
ð ",¨q°5­y¸JÕ.FÕ!F× MÑ MÈcÐSVÓ W�IÜ #× 2Ò 2°9ÄEÇKÁKÐW[Ô \�Ià—‘˜|¨Z¸À%ÈÐV_Ð`×añ= -ð@ ˆùòg"s   Ä!ASc                ó  <€ V ^8„  d   QhRS[ P                  RS[S[S[S[S[3,          ,          ,          R,          RS[S[S[S[S[3,          ,          ,          R,          RS[R,          RS[S[ P                  ,          /# )rM   rv  rL  NrM  rq  rl   )rS   rn   r    r  rU   ro   r  )rV   rW   s   "€rF   rX   r  o  sƒ   ø€ ÷ Vñ Vá�l‰lðVñ !¡4©©c±3¨h­Õ#8Õ8¸4Õ?ðVñ !¡4©©c±3¨h­Õ#8Õ8¸4Õ?ð	Vñ
   $�;ðVñ 
‰e�l‰lÕ	ñVrE   c                óÒ  aa€ \        V\        P                  4      '       d   VP                  4       p\        V\        P                  4      '       d   VP                  4       pVf   VR JpV'       d   Vf   \	        R4      hVe%   \        V4      \        V4      8w  d   \	        R4      hVe%   \        V4      \        V4      8w  d   \	        R4      hV P                  R,          pV P                  R,          p. oV'       d~   V Fw  w  rx\        Wx3WV4      w  ršW•8  d   WY,
          ^,          M^ pW¦8  d   Wj,
          ^,          M^ pSP                  VVV\        W•4      ,           V\        W¦4      ,           34       Ky  	  S'       * ;'       g;    \        ;QJ d    V3R lS 4       F  '       d   K   RM	  RM! V3R lS 4       4      p. oVe   V Uu. uF  p\        V4      NK  	  upoMVe   V Uu. uF  p\        V4      NK  	  upoS'       * ;'       g;    \        ;QJ d    V3R	 lS 4       F  '       d   K   RM	  RM! V3R	 lS 4       4      p. pV'       dg   V'       d_   V'       d    S^ ,          w  ppppVR
R
VV1VV13,          pS'       d#   \        P                  ! VS^ ,          RRRR7      p\        V4      pV# \        \        V4      4       Fƒ  pVV,          pV'       d   SV,          w  ppppVR
VV1VV13,          pS'       d9   \        P                  ! VP!                  ^ 4      SV,          RRRR7      ^ ,          pVP                  V4       K…  	  V# u upi u upi )Nz>`source_sizes` must be provided when `do_remove_padding=True`.zUMake sure that you pass in as many source sizes as the batch dimension of the outputszUMake sure that you pass in as many target sizes as the batch dimension of the outputsr{   rz   c              3   ó:   <"  € T F  qS^ ,          8H  x € K  	  R# 5ir…  r>   )r†  Úcropr>  s   & €rF   r‡  Ú<Sapiens2ImageProcessor._post_process_maps.<locals>.<genexpr>—  s   øé € Ð*NÉÀ°5¸µ8Ö+;Ëùó   ƒFTc              3   ó:   <"  € T F  qS^ ,          8H  x € K  	  R# 5ir…  r>   )r†  r&  Úfinal_sizess   & €rF   r‡  r¬  ž  s   øé € Ð6fÑZeÐRV¸{È1½~Ö7MÓZeùr­  r–   r�   r�  )rR  rS   rn   rS  rÀ   rT  r&  r   rV  Úminr—  rU   rŸ   r›  r  rU  r�   )r  rv  rL  rM  rq  Úmodel_heightÚmodel_widthÚoriginal_heightÚoriginal_widthÚ
new_heightÚ	new_widthÚpad_topÚpad_leftÚall_crops_equalr&  Úall_final_sizes_equalrÊ   ÚtopÚleftÚbottomÚrightró   Úmap_itemr>  r¯  s   &&&&&                  @@rF   rx  Ú)Sapiens2ImageProcessor._post_process_mapso  s  ù€ ô �l¤E§L¡L×1Ò1Ø'×.Ñ.Ó0ˆLÜ�l¤E§L¡L×1Ò1Ø'×.Ñ.Ó0ˆLØÒ$Ø ,°DÐ 8Ðß Ò!5ÜÐ]Ó^Ð^àÒ#¬¨D«	´S¸Ó5FÔ(FÜÐtÓuÐuØÒ#¬¨D«	´S¸Ó5FÔ(FÜÐtÓuÐuà—y‘y Õ*ˆØ—i‘i Õ(ˆàˆßÛ3?Ñ/�Ü(KØ$Ð5°|ó)Ñ%�
ð ?IÔ>W˜<Õ4¸Ö:Ð]^�Ø=FÔ=T˜KÕ3¸Ö9ÐZ[�Ø—‘àØ Ø¤# jÓ"?Õ?Ø ¤3 yÓ#>Õ>ð	öñ 4@ð $œ)×NÐN§s£sÔ*NÉÓ*N§s§s¢sÔ*NÉÓ*NÓ'NˆàˆØÒ#Ù3?Ó@±<¨4œ5 ž;±<Ñ@‰KØÒ%Ù3?Ó@±<¨4œ5 ž;±<Ñ@ˆKØ$/¤× fÐ f·3³3Ô6fÑZeÓ6f·3·3²3Ô6fÑZeÓ6fÓ3fÐàˆß×4ç Ø+0°­8Ñ(��T˜6 5Ø˜A˜q # f *¨d°5¨jÐ8Õ9�çÜ—}’}ØØ$ Q�Ø#Ø"'Ø#ô�ô ˜$“ZˆFð* ˆô% œs 4›yÖ)�Ø �;�ç$Ø/4°U­|Ñ,�C˜˜v uØ'¨¨3¨v¨:°t¸E°zÐ(AÕB�HçÜ Ÿ}š}Ø ×*Ñ*¨1Ó-Ø(¨Õ/Ø'Ø&+Ø"'ô ð õ �Hð —‘˜hÖ'ñ! *ð$ ˆùòU Aùâ@s   ÇMÇ2M$r>   ©NN©N)FFN)Né   NNN©NNN)r@   rA   rB   rC   r  Úvalid_kwargsr   ÚBILINEARr'  r   r-  r   r.  r&  r1  r  r"   r  r"  rH  rm  rz  r  r¦  rx  rD   r[   Ú__classcell__©r  rW   s   @@rF   r  r  ž  s±   ù‡ € Ø/€Là!×*Ñ*€HØ&€JØ$€IØ�d˜G SÐ)€DØ€F÷#ó #ð ÷Yñ Yó ðY÷$
õ 
÷08Nò 8N÷tLò L÷\";ò ";÷H#<ò #<÷JGò G÷RV÷ Vð VrE   r  zfacebook/sapiens2-seg-0.4b)Ú
checkpointc                   óŒ   a a€ ] tR tRt oRtRtRtRtRt^t	Rt
RtRt^tRtRt^tRtRtV 3R ltV3R lR ltV3R	 ltR
tVtV ;t# )ÚSapiens2HeadConfigiÈ  aØ  
upsample_out_channels (`list[int]`, *optional*):
    Output channel counts for each upsample block.
    The first block takes `hidden_size` channels as input; subsequent blocks use the previous output.
upsample_kernel_sizes (`list[int]`, *optional*):
    Kernel size for each upsample block. Auto-filled with `[4, ...]` when
    `upsample_out_channels` is set but this is `None`.
    Must have the same length as `upsample_out_channels`.
upsample_kernel_size (`int`, defaults to 4):
    Default kernel size for upsample blocks when `upsample_kernel_sizes` is not set.
use_pixel_shuffle (`bool`, *optional*):
    Whether the upsample head uses pixel-shuffle upsampling instead of transposed convolutions.
    When `None` (default), the head uses transposed convolutions.
conv_out_channels (`list[int]`, *optional*):
    Output channel counts for the refinement conv layers that follow the upsample blocks.
conv_kernel_sizes (`list[int]`, *optional*):
    Kernel size for each refinement conv layer. Auto-filled with `[1, ...]` when
    `conv_out_channels` is set but this is `None`.
    Must have the same length as `conv_out_channels`.
conv_kernel_size (`int`, defaults to 1):
    Default kernel size for conv layers when `conv_kernel_sizes` is not set.
scale_conv_out_channels (`list[int]`, *optional*):
    Output channel counts for the stride-2 conv layers used to predict the focal-length scale.
    When `None` (default), no scale branch is built.
scale_conv_kernel_sizes (`list[int]`, *optional*):
    Kernel size for each scale conv layer. Auto-filled with `[1, ...]` when
    `scale_conv_out_channels` is set but this is `None`.
    Must have the same length as `scale_conv_out_channels`.
scale_conv_kernel_size (`int`, defaults to 1):
    Default kernel size for scale conv layers when `scale_conv_kernel_sizes` is not set.
scale_final_input_size (`int`, *optional*):
    Flattened feature size passed into the scale MLP.
    When `None` (default), it is automatically inferred from `image_size` and `patch_size`
    in the parent [`Sapiens2Config`].
scale_final_hidden_sizes (`list[int]`, *optional*):
    Hidden-layer sizes for the MLP that maps flattened scale features to the scalar scale output.
    When `None` (default), no scale branch is built.
Úsapiens2_headÚhead_configNc                óØ  <€ V P                   e;   V P                  f-   V P                  .\        V P                   4      ,          V n        V P                  e;   V P
                  f-   V P                  .\        V P                  4      ,          V n        V P                  e;   V P                  f-   V P                  .\        V P                  4      ,          V n        \        SV `,  ! R/ VB  R # r  )Úupsample_out_channelsÚupsample_kernel_sizesÚupsample_kernel_sizerT  Úconv_out_channelsÚconv_kernel_sizesÚconv_kernel_sizeÚscale_conv_out_channelsÚscale_conv_kernel_sizesÚscale_conv_kernel_sizer  Ú__post_init__r  s   &,€rF   rØ  Ú Sapiens2HeadConfig.__post_init__  s»   ø€ Ø×%Ñ%Ò1°d×6PÑ6PÒ6XØ*.×*CÑ*CÐ)DÄsÈ4×KeÑKeÓGfÕ)fˆDÔ&Ø×!Ñ!Ò-°$×2HÑ2HÒ2PØ&*×&;Ñ&;Ð%<¼sÀ4×CYÑCYÓ?ZÕ%ZˆDÔ"Ø×'Ñ'Ò3¸×8TÑ8TÒ8\Ø,0×,GÑ,GÐ+HÌ3Èt×OkÑOkÓKlÕ+lˆDÔ(Ü‰ÒÑ' Ô'rE   c                ó¶   <€ V ^8„  d   QhRS[ S[S[ ,          ,          S[S[ S[ 3,          ,          RS[ S[S[ ,          ,          S[S[ S[ 3,          ,          RR/# )rM   Ú
image_sizeÚ
patch_sizerl   N)ro   r  rU   )rV   rW   s   "€rF   rX   ÚSapiens2HeadConfig.__annotate__  sZ   ø€ ÷ jñ jÙ¡¡S¥	�/©E±#±s°(­OÕ;ðjÙILÉtÑTWÍyÍÑ[`ÑadÑfiÐaiÕ[jÕIjðjà	ñjrE   c                ól  € V P                   f   V P                  e   V P                  f   R # \        V\        \
        34      '       d   TMW3w  r4\        V\        4      '       d   TMV^ ,          p\        V\        4      '       d   TMV^,          pW5,          pWF,          pV P                   F]  p	V	^,
          ^,          p
V^V
,          ,           V	,
          ^,          ^,           pV^V
,          ,           V	,
          ^,          ^,           pK_  	  Wx,          V P                  R,          ,          V n         R # )Nrt   )Úscale_final_input_sizerÕ  rÖ  rR  r  rU   ro   )r  rÛ  rÜ  Úimage_heightÚimage_widthÚpatch_heightÚpatch_widthÚfeatures_heightÚfeatures_widthr½   rk   s   &&&        rF   Ú_init_scale_final_input_sizeÚ/Sapiens2HeadConfig._init_scale_final_input_size  s  € ð ×'Ñ'Ò3Ø×+Ñ+Ò3Ø×+Ñ+Ò3áÜ2<¸ZÌ$ÔPUÈ×2WÒ2W¡JÐ^hÐ]uÑ!ˆÜ%/°
¼C×%@Ò%@‘zÀjÐQRÅmˆÜ$.¨z¼3×$?Ò$?‘jÀZÐPQÅ]ˆØ&Õ6ˆØ$Õ3ˆØ×7Ô7ˆKØ" Q•¨1Õ,ˆGØ.°°WµÕ<¸{ÕJÈqÕPÐSTÕTˆOØ,¨q°7­{Õ:¸[ÕHÈQÕNÐQRÕRŠNñ 8ð '6Õ&FÈ×IeÑIeÐfhÕIiÕ&iˆÖ#rE   c                ó˜  <€ V ^8„  d   Qh/ S[ S[,          R,          ;R&   S[ S[,          R,          ;R&   S[;R&   S[R,          ;R&   S[ S[,          R,          ;R&   S[ S[,          R,          ;R&   S[;R&   S[ S[,          R,          ;R	&   S[ S[,          R,          ;R
&   S[;R&   S[R,          ;R&   S[ S[,          R,          ;R&   # )rM   NrÏ  rÐ  rÑ  Úuse_pixel_shufflerÒ  rÓ  rÔ  rÕ  rÖ  r×  rß  Úscale_final_hidden_sizes)r  ro   r  )rV   rW   s   "€rF   rX   rÝ  È  s   ø‡ ‚ ñZ  ¡�9 tÕ+Ñ2ñ[ ñ\  ¡�9 tÕ+Ñ2ñ] ñ^ Ñ!ñ_ ñ` ˜d•{Ñ)ña ñb ™C•y 4Õ'Ñ.ñc ñd ™C•y 4Õ'Ñ.ñe ñf Ññg ñh "¡#�Y¨Õ-Ñ4ñi ñj "¡#�Y¨Õ-Ñ4ñk ñl  Ñ#ñm ñn   $�JÑ-ño ñp #¡3�i¨$Õ.Ñ5òq rE   )rÓ  rÖ  rß  rÐ  )r@   rA   rB   rC   rI   Ú
model_typeÚbase_config_keyrÏ  rÐ  rÑ  ré  rÒ  rÓ  rÔ  rÕ  rÖ  r×  rß  rê  rØ  ræ  rZ   rD   r[   rÇ  rÈ  s   @@rF   rË  rË  È  sx   ù‡ € ñ%ðN !€JØ#€Oà.2ÐØ.2ÐØ !ÐØ%)ÐØ*.ÐØ*.ÐØÐØ04ÐØ04ÐØ"#ÐØ)-ÐØ15Ðõ(÷jð j÷G … rE   rË  zfacebook/sapiens2-pretrain-0.4bc                   ó¶   a a€ ] tR tRt oRtRtR]/tRt^t	^t
RtRtRtR	tR
tRt^tRtRtRt^t^t^t^ÿtRtRt]! 4       t]! 4       tV 3R ltV3R ltRt Vt!V ;t"# )ÚSapiens2Configi   uS  
rope_theta (`float`, *optional*, defaults to 100.0):
    The base period of the RoPE embeddings.
query_bias (`bool`, *optional*, defaults to `True`):
    Whether to add a bias to the query projection.
key_bias (`bool`, *optional*, defaults to `False`):
    Whether to add a bias to the key projection.
value_bias (`bool`, *optional*, defaults to `True`):
    Whether to add a bias to the value projection.
proj_bias (`bool`, *optional*, defaults to `True`):
    Whether to add a bias to the output projection.
layerscale_value (`float`, *optional*, defaults to 1.0):
    Initial value to use for layer scale.
use_gated_mlp (`bool`, *optional*, defaults to `False`):
    Whether to use the SwiGLU feedforward neural network.
num_register_tokens (`int`, *optional*, defaults to 0):
    The number of register tokens.
pos_embed_shift (`float`, *optional*):
    Amount to randomly shift position embedding coordinates in [-shift, shift],
    applied only in training mode if not `None`.
pos_embed_jitter (`float`, *optional*):
    Amount to randomly jitter position embedding coordinates in log-uniform value in [1/jitter, jitter],
    applied only in training mode if not `None`.
pos_embed_rescale (`float`, *optional*, defaults to 2.0):
    Amount to randomly rescale position embedding coordinates in log-uniform value in [1/rescale, rescale],
    applied only in training mode if not `None`.
reshape_hidden_states (`bool`, *optional*, defaults to `True`):
    Whether to reshape the hidden states to spatial dimensions when used as backbone.
use_mask_token (`bool`, *optional*, defaults to `False`):
    Whether to use a mask token in the embeddings (needed for masked image modeling pretraining).
rms_norm_eps (`float`, *optional*, defaults to 1e-6):
    Epsilon for the RMS normalization layers.
normalize_backbone_outputs (`bool`, *optional*, defaults to `True`):
    Whether to apply RMSNorm to the backbone `feature_maps` and `cls_tokens` outputs before
    returning them from the forward pass. Only applies when the model is used as a backbone.
use_qk_norm (`bool`, *optional*, defaults to `True`):
    Whether to apply RMSNorm to queries and keys before RoPE in attention layers.
num_key_value_heads_per_layer (`list[int]`, *optional*):
    Number of key/value heads for each transformer layer. Setting a layer's value equal to
    `num_attention_heads` gives full multi-head attention; a smaller value gives grouped-query
    attention. Defaults to `num_attention_heads` for the first `num_first_full_attention_layers`
    and last `num_last_full_attention_layers` layers and `num_key_value_attention_heads` for all other
    layers.
num_key_value_attention_heads (`int`):
    Number of key/value heads for layers that use grouped-query attention when `num_key_value_heads_per_layer`
    is not set. Ignored when `num_key_value_heads_per_layer` is set.
num_first_full_attention_layers (`int`, *optional*, defaults to 8):
    Number of leading transformer layers that use full multi-head attention.
    Only used when `num_key_value_heads_per_layer` is `None`.
num_last_full_attention_layers (`int`, *optional*, defaults to 8):
    Number of trailing transformer layers that use full multi-head attention.
    Only used when `num_key_value_heads_per_layer` is `None`.
semantic_loss_ignore_index (`int`, *optional*, defaults to 255):
    Label index ignored when computing the segmentation loss.
flip_pairs (`list[list[int]]`, *optional*):
    Pairs of keypoint indices that are mirrored horizontally (e.g., left ear â†” right ear).
    Each pair is a two-element list `[left_index, right_index]`. Used for test-time
    horizontal flip augmentation in pose estimation: pass these pairs to the second
    forward call so the model flips heatmaps back before returning them.
head_config (`Sapiens2HeadConfig`, *optional*):
    Configuration for the decode head. See [`Sapiens2HeadConfig`] for the available options.
Úsapiens2rÍ  r  i   FTÚsilug�íµ ÷Æ°>Nc                ó"  <€ V P                   fr   \        V P                  4       Uu. uFL  pW P                  8  g"   W P                  V P                  ,
          8¼  d   V P
                  MV P                  NKN  	  upV n         \        V P                  \        4      '       d   \        R/ V P                  B V n        V P                  e2   V P                  P                  V P                  V P                  R7       \        SV `<  ! R/ VB  R # u upi )N)rÛ  rÜ  r>   )Únum_key_value_heads_per_layerrU  Únum_hidden_layersÚnum_first_full_attention_layersÚnum_last_full_attention_layersÚnum_attention_headsÚnum_key_value_attention_headsrR  rÍ  rN  rË  ræ  rÛ  rÜ  r  rØ  )r  r
  Úlayer_indexr  s   &, €rF   rØ  ÚSapiens2Config.__post_init__|  sí   ø€ Ø×-Ñ-Ò5ô $)¨×)?Ñ)?Ô#@ó2ñ $A�Kð	  ×"FÑ"FÔFØ"×&<Ñ&<¸t×?bÑ?bÕ&bÔbð ×(Ò(ð
 ×7Ñ7ò8ñ $Añ2ˆDÔ.ô �d×&Ñ&¬×-Ò-Ü1ÑE°D×4DÑ4DÑEˆDÔØ×ÑÒ'Ø×Ñ×9Ñ9ÀTÇ_Á_Ðae×apÑapÐ9ÔqÜ‰ÒÑ' Ô'ùò2s   §ADc                óh  <€ V ^8„  d   Qh/ S[ ;R&   S[ ;R&   S[ ;R&   S[ ;R&   S[;R&   S[;R&   S[;R&   S[;R&   S[;R	&   S[ ;R
&   S[;R&   S[;R&   S[S[ ,          R,          ;R&   S[ ;R&   S[ ;R&   S[ ;R&   S[ ;R&   S[S[S[ ,          ,          R,          ;R&   S[S[,          R,          ;R&   # )rM   Úhidden_sizeró  rö  Úintermediate_sizeÚuse_mask_tokenÚuse_gated_mlpÚ
hidden_actÚrms_norm_epsÚnormalize_backbone_outputsÚnum_register_tokensÚkey_biasÚuse_qk_normNrò  r÷  rô  rõ  Úsemantic_loss_ignore_indexÚ
flip_pairsrÍ  )ro   r  r   rp   r  rË  rN  )rV   rW   s   "€rF   rX   ÚSapiens2Config.__annotate__   sB  ø‡ ‚ ñJ ÑñK ñL ÑñM ñN Ñ!ñO ñP Ñ!ñQ ñR Ñ ñS ñT ÑñU ñV ÑñW ñX ÑñY ñZ !%Ñ+ñ[ ñ\ Ñ ñ] ñ^ Ññ_ ñ` Ñña ñb $(©¥9¨tÕ#3Ñ:ñc ñd $'Ñ*ñe ñf &)Ñ,ñg ñh %(Ñ+ñi ñj !$Ñ)ñk ñl ‘T™#•Y• $Õ&Ñ-ñm ñn $¡dÕ*¨TÕ1Ñ8òo rE   )rÍ  rò  )#r@   rA   rB   rC   rI   rë  rË  Úsub_configsrû  ró  rö  rü  rý  rþ  rÿ  r   r  r  r  r  rò  r÷  rô  rõ  r  r  rÍ  ÚAttributeErrorÚlayer_norm_epsÚapply_layernormrØ  rZ   rD   r[   rÇ  rÈ  s   @@rF   rî  rî     s£   ù‡ € ñ=ð~ €JØ Ð"4Ð5€Kà€KØÐØ!ÐØ!ÐØ €NØ€MØ€JØ€LØ'+ÐØ ÐØ€HØ€KØ6:Ð!Ø)*Ð!Ø+,Ð#Ø*+Ð"Ø&)ÐØ)-€JØ48€Ká#Ó%€NÙ$Ó&€Oõ(÷y … rE   rî  c                   óZ   a a€ ] tR tRt oV3R lV 3R lltRV3R lV 3R llltRtVtV ;t# )ÚSapiens2EmbeddingsiŽ  c                ó    <€ V ^8„  d   QhRS[ /# ©rM   Úconfig©rî  )rV   rW   s   "€rF   rX   ÚSapiens2Embeddings.__annotate__�  s   ø€ ÷ qñ q™~ñ qrE   c                óÒ   <€ \         SV `  V4       VP                  '       d>   \        P                  ! \
        P                  ! ^^VP                  4      4      V n        R# RV n        R# )r¿   N)	r  r  rý  r   Ú	ParameterrS   r‘   rû  Ú
mask_token©r  r  r  s   &&€rF   r  ÚSapiens2Embeddings.__init__�  sE   ø€ Ü‰Ñ˜Ô ØQW×Qf×QfÐQfœ"Ÿ,š,¤u§{¢{°1°a¸×9KÑ9KÓ'LÓMˆŽÐlpˆŽrE   c                óv   <€ V ^8„  d   QhRS[ P                  RS[ P                  R,          RS[ P                  /# )rM   Úpixel_valuesÚbool_masked_posNrl   ©rS   rn   )rV   rW   s   "€rF   rX   r  “  s7   ø€ ÷ >ñ >¡E§L¡Lð >Á5Ç<Á<ÐRVÕCVð >Ñbg×bnÑbnñ >rE   c                ó\   <€ Ve   V P                   f   \        R4      h\        SV `  W4      # )Nz:bool_masked_pos requires use_mask_token=True in the config)r  rÀ   r  Úforward)r  r  r  r  s   &&&€rF   r  ÚSapiens2Embeddings.forward“  s-   ø€ ØÒ&¨4¯?©?Ò+BÜÐYÓZÐZÜ‰w‰˜|Ó=Ð=rE   )r  rÂ  ©	r@   rA   rB   rC   r  r  rD   r[   rÇ  rÈ  s   @@rF   r  r  Ž  s    ù‡ € ÷qó q÷>÷ >õ >rE   r  c                   ó>   a a€ ] tR tRt oV3R lV 3R lltRtVtV ;t# )ÚSapiens2RopePositionEmbeddingi™  c                ó    <€ V ^8„  d   QhRS[ /# r  r  )rV   rW   s   "€rF   rX   Ú*Sapiens2RopePositionEmbedding.__annotate__š  s   ø€ ÷ 5ñ 5™~ñ 5rE   c                óP  <€ \         SV `  V 4       V =V =VP                  p\        V\        4      '       d   TMW"3w  r4VP                  p\        V\        4      '       d   TMV^ ,          p\        V\        4      '       d   TMV^,          pW6,          V n        WG,          V n        R# r…  )	r  r  Únum_patches_hÚnum_patches_wrÛ  rR  r   rÜ  ro   )	r  r  rÛ  Úimage_hÚimage_wrÜ  Úpatch_size_hÚpatch_size_wr  s	   &&      €rF   r  Ú&Sapiens2RopePositionEmbedding.__init__š  s’   ø€ Ü‰Ñ˜ÔàÐØÐØ×&Ñ&ˆ
Ü)3°JÄ×)IÒ)I™:ÐPZÐOgÑˆØ×&Ñ&ˆ
Ü%/°
¼C×%@Ò%@‘zÀjÐQRÅmˆÜ%/°
¼C×%@Ò%@‘zÀjÐQRÅmˆØ$Õ4ˆÔØ$Õ4ˆÖrE   )r%  r&  ©r@   rA   rB   rC   r  rD   r[   rÇ  rÈ  s   @@rF   r!  r!  ™  s   ù‡ € ÷5÷ 5ó 5rE   r!  c                   ó   € ] tR tRtRtR# )ÚSapiens2RMSNormi¨  r>   Nr?   r>   rE   rF   r.  r.  ¨  r  rE   r.  c                   óT   a a€ ] tR tRt o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# )ÚSapiens2Attentioni¬  c                ó&   <€ V ^8„  d   QhRS[ RS[/# ©rM   r  Ú	layer_idx©rî  ro   )rV   rW   s   "€rF   rX   ÚSapiens2Attention.__annotate__­  s   ø€ ÷ 	wñ 	w™~ð 	w¹#ñ 	wrE   c                ó  <€ \         SV `  V4       V =V =VP                  V,          V n        V P                  V P
                  ,          V n        \        P                  ! V P                  V P
                  V P                  ,          VP                  R 7      V n        \        P                  ! V P                  V P
                  V P                  ,          VP                  R 7      V n        VP                  '       d"   \        V P                  VP                   R7      M\        P"                  ! 4       V n        VP                  '       d)   \        V P                  VP                   R7      V n        R# \        P"                  ! 4       V n        R# ))Úbias©rê   N)r  r  Úk_projÚv_projrò  Únum_key_value_headsÚ	num_headsÚnum_key_value_groupsr   ÚLinearÚ	embed_dimÚhead_dimr  Ú
value_biasr  r.  r   ÚIdentityÚq_normÚk_norm©r  r  r3  r  s   &&&€rF   r  ÚSapiens2Attention.__init__­  s  ø€ Ü‰Ñ˜Ô ØˆKØˆKØ#)×#GÑ#GÈ	Õ#RˆÔ Ø$(§N¡N°d×6NÑ6NÕ$NˆÔ!Ü—i’i §¡°×0HÑ0HÈ4Ï=É=Õ0XÐ_e×_nÑ_nÔoˆŒÜ—i’i §¡°×0HÑ0HÈ4Ï=É=Õ0XÐ_e×_pÑ_pÔqˆŒØQW×Qc×QcÐQc”o d§m¡m¸×9LÑ9LÕMÔik×itÒitÓivˆŒØQW×Qc×QcÐQc”o d§m¡m¸×9LÑ9LÔMˆŽÔik×itÒitÓivˆŽrE   c                ó  <€ V ^8„  d   QhRS[ P                  RS[ P                  R,          RS[S[ P                  S[ P                  3,          R,          RS[S[,          RS[S[ P                  S[ P                  R,          3,          /# )rM   rP   Úattention_maskNÚposition_embeddingsr
  rl   )rS   rn   rU   r   r!   )rV   rW   s   "€rF   rX   r5  ¸  s~   ø€ ÷ #)ñ #)á—|‘|ð#)ñ Ÿ™ tÕ+ð#)ñ #¡5§<¡<±·±Ð#=Õ>ÀÕEð	#)ñ
 Ñ+Õ,ð#)ñ 
‰u�|‰|™UŸ\™\¨DÕ0Ð0Õ	1ñ#)rE   c                ó  € VP                   R R p. VORNV P                  N5pV P                  V4      P                  V4      P	                  ^^4      pV P                  V4      P                  V4      P	                  ^^4      pV P                  V4      P                  V4      P	                  ^^4      p	V P                  V4      pV P                  V4      pVw  r«\        WxW«4      w  rx\        P                  ! V P                  P                  \        4      pT! V VVV	V3RV P                  '       g   RMV P                   RV P"                  /VB w  rÞVP$                  ! . VORN5!  P'                  4       pV P)                  V4      pWÞ3# )NÚdropoutr»   Úscalingrt   )r—   r@  Úq_projÚviewÚ	transposer9  r:  rC  rD  r1   r   Úget_interfacer  Ú_attn_implementationr2   ÚtrainingrK  rL  rÑ   Ú
contiguousÚo_proj)r  rP   rH  rI  r
  Úinput_shapeÚhidden_shapeÚquery_statesÚ
key_statesÚvalue_statesÚcosÚsinÚattention_interfaceÚattn_outputÚattn_weightss   &&&&,          rF   r  ÚSapiens2Attention.forward¸  s  € ð $×)Ñ)¨#¨2Ð.ˆØ8˜Ð8 bÐ8¨$¯-©-Ñ8ˆà—{‘{ =Ó1×6Ñ6°|ÓD×NÑNÈqÐRSÓTˆØ—[‘[ Ó/×4Ñ4°\ÓB×LÑLÈQÐPQÓRˆ
Ø—{‘{ =Ó1×6Ñ6°|ÓD×NÑNÈqÐRSÓTˆØ—{‘{ <Ó0ˆØ—[‘[ Ó,ˆ
à&‰ˆÜ#7¸ÐRUÓ#[Ñ ˆä(?×(MÒ(MØ�K‰K×,Ñ,Ô.Eó)
Ðñ %8ØØØØØñ	%
ð  $Ÿ}Ÿ}˜}‘C°$·,±,ð	%
ð —L‘Lð	%
ð ñ	%
Ñ!ˆð "×)Ò)Ð;¨;Ð;¸Ó;×FÑFÓHˆØ—k‘k +Ó.ˆØÐ(Ð(rE   )rD  r9  r=  r;  rC  r:  rÁ  r  rÈ  s   @@rF   r0  r0  ¬  s    ù‡ € ÷	wó 	w÷#)÷ #)ò #)rE   r0  c                   ó   € ] tR tRtRtR# )ÚSapiens2LayerScaleiÞ  r>   Nr?   r>   rE   rF   ra  ra  Þ  r  rE   ra  c                   ó>   a a€ ] tR tRt oV3R lV 3R lltRtVtV ;t# )ÚSapiens2Layeriâ  c                ó&   <€ V ^8„  d   QhRS[ RS[/# r2  r4  )rV   rW   s   "€rF   rX   ÚSapiens2Layer.__annotate__ã  s   ø€ ÷ *ñ *™~ð *¹#ñ *rE   c                ó  <€ \         SV `  V4       \        WR 7      V n        \	        VP
                  VP                  R7      V n        \	        VP
                  VP                  R7      V n        \        P                  ! 4       V n        R# )©r3  r8  N)r  r  r0  Ú	attentionr.  rû  r   Únorm1Únorm2r   rB  Úlayer_scale2rE  s   &&&€rF   r  ÚSapiens2Layer.__init__ã  s^   ø€ Ü‰Ñ˜Ô Ü*¨6ÔGˆŒÜ$ V×%7Ñ%7¸V×=PÑ=PÔQˆŒ
Ü$ V×%7Ñ%7¸V×=PÑ=PÔQˆŒ
ÜŸKšK›MˆÖrE   )rh  rk  ri  rj  r,  rÈ  s   @@rF   rc  rc  â  s   ù‡ € ÷*÷ *ó *rE   rc  c                   óT   a a€ ] tR tRt oRV3R lV 3R llltV3R lR ltRtVtV ;t# )ÚSapiens2ConvLayerië  c                ó¸   <€ V ^8„  d   QhRS[ RS[ RS[ S[S[ S[ 3,          ,          RS[ RS[ S[S[ S[ 3,          ,          S[,          RS[ RS[RS[R	S[R
S[RS[ /# )rM   Úin_channelsÚout_channelsr½   Ústriderk   ÚgroupsÚ
activationr7  Úconvolution_transposeÚpixel_shuffleÚscale_factor)ro   rU   r   r  )rV   rW   s   "€rF   rX   ÚSapiens2ConvLayer.__annotate__ì  s˜   ø€ ÷ %)ñ %)áð%)ñ ð%)ñ ™5¡¡c �?Õ*ð	%)ñ
 ð%)ñ ‘u™S¡#˜X•Õ&©Õ,ð%)ñ ð%)ñ ð%)ñ ð%)ñ  $ð%)ñ ð%)ñ ñ%)rE   c           
     óä  <€ \         SV `  4        V	'       d;   \        P                  ! TV
'       d   W+^,          ,          MTVVVVVR7      V n        M9\        P
                  ! TV
'       d   W+^,          ,          MTVVVVVR7      V n        V
'       d   \        P                  ! V4      M\        P                  ! 4       V n        \        P                  ! V4      V n
        \        V,          V n        R# )rM   )r½   rr  rk   r7  rs  N)r  r  r   ÚConvTranspose2dÚconvolutionÚConv2dÚPixelShufflerB  rv  ÚInstanceNorm2dÚnormr   Úact_fn)r  rp  rq  r½   rr  rk   rs  rt  r7  ru  rv  rw  r  s   &&&&&&&&&&&&€rF   r  ÚSapiens2ConvLayer.__init__ì  s¹   ø€ ô 	‰ÑÔß Ü!×1Ò1Øß2?�¨Q�Ö.À\Ø'ØØØØô ˆDÕô  "ŸyšyØß2?�¨Q�Ö.À\Ø'ØØØØô ˆDÔ÷ ?LœRŸ_š_¨\Ô:ÔQS×Q\ÒQ\ÓQ^ˆÔÜ×%Ò% lÓ3ˆŒ	Ü˜ZÕ(ˆŽrE   c                óN   <€ V ^8„  d   QhRS[ P                  RS[ P                  /# ©rM   rP   rl   r  )rV   rW   s   "€rF   rX   rx    s#   ø€ ÷ ñ ¡U§\¡\ð ±e·l±lñ rE   c                óŽ   € V P                  V4      pV P                  V4      pV P                  V4      pV P                  V4      pV# rÂ  )r{  rv  r  r€  ©r  rP   s   &&rF   r  ÚSapiens2ConvLayer.forward  sD   € Ø×(Ñ(¨Ó7ˆØ×*Ñ*¨=Ó9ˆØŸ	™	 -Ó0ˆØŸ™ MÓ2ˆØÐrE   )r€  r{  r  rv  )	r¿   r¿   r   r¿   rð  TFFrM   r  rÈ  s   @@rF   rn  rn  ë  s   ù‡ € ÷%)õ %)÷N÷ ð rE   rn  c                   óP   a a€ ] tR tRt oV3R lV 3R lltV3R lR ltRtVtV ;t# )ÚSapiens2Headi  c                ó    <€ V ^8„  d   QhRS[ /# r  r  )rV   rW   s   "€rF   rX   ÚSapiens2Head.__annotate__  s   ø€ ÷ ,Sñ ,S™~ñ ,SrE   c                óR  <a€ \         SV `  4        SP                  P                  '       d$   \	        SP
                  SP
                  ^^R7      M\        P                  ! 4       V n        SP
                  .SP                  P                  RR ,           p\        P                  ! V3R l\        VSP                  P                  SP                  P                  4       4       4      V n        SP                  P                  R,          .SP                  P                  RR ,           p\        P                  ! V3R l\        VSP                  P                  SP                  P                  4       4       4      V n        SP                  P                  '       d   SP                  P                  R,          MDSP                  P                  '       d   SP                  P                  R,          MSP
                  p\        P"                  ! VSP$                  ^R7      V n        R# )r�  ©r½   rk   Nc              3   óŠ  <"  € T F¸  w  rp\        TTTSP                  P                  '       d   ^M^SP                  P                  '       d   V^,
          ^,          M^\        SP                  P                  4      \        SP                  P                  4      SP                  P                  '       * R7      x € Kº  	  R# 5i)r¿   )r½   rr  rk   r7  rv  ru  N)rn  rÍ  ré  r  ©r†  Úin_chÚout_chr½   r  s   &   €rF   r‡  Ú(Sapiens2Head.__init__.<locals>.<genexpr>$  s¤   øé € ð -
ñ/Ñ*�˜{ô ØØØ'Ø"×.Ñ.×@×@Ð@‘qÀaØ28×2DÑ2D×2V×2VÐ2V˜ q�¨QÖ.Ð\]Ü˜&×,Ñ,×>Ñ>Ó?Ü" 6×#5Ñ#5×#GÑ#GÓHØ*0×*<Ñ*<×*NÑ*NÔ&N÷	ñ 	ó/ùs   ƒA
CÁA5Cc              3   ó    <"  € T FC  w  rp\        TTTSP                  P                  '       d   V^,
          ^,          M^ R7      x € KE  	  R# 5i)r¿   rŒ  N)rn  rÍ  ré  rŽ  s   &   €rF   r‡  r‘  6  sT   øé € ð 
)
ñ/Ñ*�˜{ô ØØØ'Ø28×2DÑ2D×2V×2VÐ2V˜ q�¨QÖ.Ð\]÷	ñ ó/ùs   ƒAA)r½   rt   )r  r  rÍ  ré  rn  rû  r   rB  Ú
input_convrÏ  Ú
ModuleListr6  rÐ  Úupsample_layersrÒ  rÓ  Úconv_layersr|  Ú
num_labelsÚ	predictor)r  r  Úupsample_in_channelsÚconv_in_channelsÚpredictor_inr  s   &f   €rF   r  ÚSapiens2Head.__init__  sº  ù€ Ü‰ÑÔð ×!Ñ!×3×3Ð3ô ˜f×0Ñ0°&×2DÑ2DÐRSÐ]^Õ_ä—’“ð 	Œð
 !'× 2Ñ 2Ð3°f×6HÑ6H×6^Ñ6^Ð_bÐ`bÐ6cÕcÐÜ!Ÿ}š}ô -
ô /2Ø$Ø×"Ñ"×8Ñ8Ø×"Ñ"×8Ñ8ô/ó-
ó  
ˆÔð" #×.Ñ.×DÑDÀRÕHÐIÈF×L^ÑL^×LpÑLpÐqtÐrtÐLuÕuÐÜŸ=š=ô 
)
ô /2Ø  &×"4Ñ"4×"FÑ"FÈ×HZÑHZ×HlÑHlô/ó
)
ó 

ˆÔð ×!Ñ!×3×3Ð3ð ×Ñ×0Ñ0°Ö4ð ×!Ñ!×7×7Ð7ð ×#Ñ#×9Ñ9¸"Ö=à×#Ñ#ð 	ô Ÿš <°×1BÑ1BÐPQÔRˆŽrE   c                óN   <€ V ^8„  d   QhRS[ P                  RS[ P                  /# rƒ  r  )rV   rW   s   "€rF   rX   rŠ  J  s#   ø€ ÷ -ñ -¡U§\¡\ð -±e·l±lñ -rE   c                ó²   € V P                  V4      pV P                   F  pV! V4      pK  	  V P                   F  pV! V4      pK  	  V P                  V4      # rÂ  )r“  r•  r–  r˜  ©r  rP   Úlayers   && rF   r  ÚSapiens2Head.forwardJ  sS   € ØŸ™¨Ó6ˆØ×)Ô)ˆEÙ! -Ó0ŠMñ *à×%Ô%ˆEÙ! -Ó0ŠMñ &à�~‰~˜mÓ,Ð,rE   )r–  r“  r˜  r•  r  rÈ  s   @@rF   rˆ  rˆ    s!   ù‡ € ÷,Só ,S÷\-÷ -ð -rE   rˆ  c                   ó2   a € ] tR tRt o V 3R lR ltRtV tR# )ÚSapiens2PointmapFinalLayerBlockiS  c                óD   <€ V ^8„  d   QhRS[ RS[ RS[P                  RR/# )rM   Úin_dimÚout_dimrt  rl   N)ro   r   ÚModule)rV   rW   s   "€rF   rX   Ú,Sapiens2PointmapFinalLayerBlock.__annotate__T  s3   ø€ ÷ Nñ N™sð N©Sð N¹b¿i¹ið NÈDñ NrE   c                ó¦   € \         P                  P                  V 4       \         P                  ! \         P                  ! W4      V.4      V n        R # rÂ  )r   r§  r  r”  r>  Úlayers)r  r¥  r¦  rt  s   &&&&rF   r  Ú(Sapiens2PointmapFinalLayerBlock.__init__T  s2   € Ü
�	‰	×Ñ˜4Ô Ü—m’m¤R§Y¢Y¨vÓ%?ÀÐ$LÓMˆŽrE   )rª  N)r@   rA   rB   rC   r  rD   r[   r\   s   @rF   r£  r£  S  s   ø‡ € ÷Nö NrE   r£  c                   óT   a a€ ] tR tRt oRV3R lV 3R llltV3R lR ltRtVtV ;t# )ÚSapiens2PointmapFinalLayeriY  c                óH   <€ V ^8„  d   QhRS[ RS[S[ S[ 3,          RS[ RS[/# )rM   r¥  Úhidden_sizesr¦  rt  )ro   rU   r   )rV   rW   s   "€rF   rX   Ú'Sapiens2PointmapFinalLayer.__annotate__Z  s2   ø€ ÷ 	8ñ 	8™sð 	8±%¹¹S¸µ/ð 	8ÉCð 	8Ñadñ 	8rE   c                ó>  <€ \         SV `  4        \        P                  ! 4       V n        \        W^ ,          \        V,          R7      V n        \        V^ ,          V^,          \        V,          R7      V n        \        P                  ! V^,          V4      V n
        R# )r   )r¥  r¦  rt  N)r  r  r   ÚFlattenræ   r£  r   Úblock1Úblock2r>  Úproj)r  r¥  r¯  r¦  rt  r  s   &&&&&€rF   r  Ú#Sapiens2PointmapFinalLayer.__init__Z  so   ø€ Ü‰ÑÔÜ—z’z“|ˆŒÜ5Ø°¥?¼vÀjÕ?Qô
ˆŒô 6Ø •?¨L¸­OÌÈzÕHZô
ˆŒô —I’I˜l¨1�o¨wÓ7ˆŽ	rE   c                óN   <€ V ^8„  d   QhRS[ P                  RS[ P                  /# rƒ  r  )rV   rW   s   "€rF   rX   r°  e  s#   ø€ ÷ (ñ (¡U§\¡\ð (±e·l±lñ (rE   c                óŠ   € V P                  V4      pV P                  V4      pV P                  V4      pV P                  V4      # rÂ  )ræ   r³  r´  rµ  r…  s   &&rF   r  Ú"Sapiens2PointmapFinalLayer.forwarde  s;   € ØŸ™ ]Ó3ˆØŸ™ MÓ2ˆØŸ™ MÓ2ˆØ�y‰y˜Ó'Ð'rE   )r³  r´  ræ   rµ  )r¿   rð  r  rÈ  s   @@rF   r­  r­  Y  s   ù‡ € ÷	8õ 	8÷(÷ (ð (rE   r­  c                   óP   a a€ ] tR tRt oV3R lV 3R lltV3R lR ltRtVtV ;t# )ÚSapiens2PointmapScaleHeadil  c                ó    <€ V ^8„  d   QhRS[ /# r  r  )rV   rW   s   "€rF   rX   Ú&Sapiens2PointmapScaleHead.__annotate__m  s   ø€ ÷ 
ñ 
™~ñ 
rE   c                ó"  <€ \         SV `  4        \        P                  ! 4       V n        VP
                  .VP                  P                  R R ,           p\        VVP                  P                  VP                  P                  4       F<  w  r4pV P                  P                  \        W4V^V^,
          ^,          R7      4       K>  	  \        VP                  P                  VP                  P                  VP                  R7      V n        R # )N)r½   rr  rk   )rt  rt   )r  r  r   r”  r–  rû  rÍ  rÕ  r6  rÖ  rV  rn  r­  rß  rê  rÿ  r˜  )r  r  Úscale_in_channelsr�  r�  r½   r  s   &&    €rF   r  Ú"Sapiens2PointmapScaleHead.__init__m  sá   ø€ Ü‰ÑÔÜŸ=š=›?ˆÔØ#×/Ñ/Ð0°6×3EÑ3E×3]Ñ3]Ð^aÐ_aÐ3bÕbÐÜ*-ØØ×Ñ×6Ñ6Ø×Ñ×6Ñ6ö+
Ñ&ˆE˜;ð
 ×Ñ×#Ñ#Ü! %¸[ÐQRÐ]hÐklÕ]lÐqrÕ\rÔsöñ+
ô 4Ø×Ñ×5Ñ5Ø×Ñ×7Ñ7Ø×(Ñ(ô
ˆŽrE   c                óN   <€ V ^8„  d   QhRS[ P                  RS[ P                  /# rƒ  r  )rV   rW   s   "€rF   rX   r½    s#   ø€ ÷ -ñ -¡U§\¡\ð -±e·l±lñ -rE   c                óZ   € V P                    F  pV! V4      pK  	  V P                  V4      # rÂ  ©r–  r˜  rŸ  s   && rF   r  Ú!Sapiens2PointmapScaleHead.forward  s+   € Ø×%Ô%ˆEÙ! -Ó0ŠMñ &à�~‰~˜mÓ,Ð,rE   rÃ  r  rÈ  s   @@rF   r»  r»  l  s   ù‡ € ÷
ó 
÷$-÷ -ð -rE   r»  c                   ój   a € ] tR tRt o RtR.tR.t]P                  ! 4       V 3R lR l4       t	Rt
V tR# )	ÚSapiens2PreTrainedModeli…  ÚmodelÚperiodsr  c                ó   <€ V ^8„  d   QhRR/# )rM   rl   Nr>   )rV   rW   s   "€rF   rX   Ú$Sapiens2PreTrainedModel.__annotate__Ž  s   ø€ ÷ cñ c tñ crE   c           	     óx  € \         P                  ! W4       \        V\        P                  \        P
                  34      '       d:   \        P                  ! VP                  R V P                  P                  R7       R# \        V\        P                  4      '       d&   \        P                  ! VP                  RRR7       R# \        V\        4      '       dÊ   \        P                  ! VP                  R V P                  P                  R7       VP                  P                  ^ 8”  d8   \        P                  ! VP                   R V P                  P                  R7       VP                  P"                  '       d#   \        P$                  ! VP&                  4       R# R# \        V\(        4      '       d8   \        P*                  ! VP,                  V P                  P.                  4       R# \        V\0        4      '       du   ^VP2                  \4        P6                  ! ^ ^^VP8                  ,          \4        P:                  R7      ,          ,          p\        P<                  ! VP>                  V4       R# \        V\@        \B        34      '       d¤   VPE                  4        F�  p\        V\        P
                  4      '       d&   \        P                  ! VP                  RRR7       KH  \        V\        P                  4      '       g   Kj  \        P                  ! VP                  RRR7       K�  	  R# R# )	r»   )ÚmeanÚstdÚfan_outÚrelu)r’   Únonlinearity)r‰   Úfan_inÚlinearN)#r   Ú_init_weightsrR  r   r>  r|  ÚinitÚtrunc_normal_Úweightr  Úinitializer_rangerz  Úkaiming_normal_r  Ú	cls_tokenr  Úregister_tokensrý  Úzeros_r  ra  Ú	constant_Úlambda1Úlayerscale_valuer!  ÚbaserS   rš   r@  r›   Úcopy_Úinv_freqrˆ  r»  Úmodules)r  Úmodulerá  Úhead_modules   &&  rF   rÓ  Ú%Sapiens2PreTrainedModel._init_weights�  sø  € ä×%Ò% dÔ3Ü�fœrŸy™y¬"¯)©)Ð4×5Ò5Ü×Ò˜vŸ}™}°3¸D¿K¹K×<YÑ<Y×ZÜ˜¤× 2Ñ 2×3Ò3Ü× Ò  §¡°YÈV×TÜ˜Ô 2×3Ò3Ü×Ò˜v×/Ñ/°c¸t¿{¹{×?\Ñ?\Õ]Ø�}‰}×0Ñ0°1Ô4Ü×"Ò" 6×#9Ñ#9ÀÈÏÉ×IfÑIfÕgØ�}‰}×+×+Ð+Ü—’˜F×-Ñ-Ö.ñ ,ä˜Ô 2×3Ò3Ü�NŠN˜6Ÿ>™>¨4¯;©;×+GÑ+GÖHÜ˜Ô =×>Ò>Ø˜6Ÿ;™;¬%¯,ª,°q¸!¸QÀÇÁÕ=PÔX]×XeÑXeÔ*fÕfÕfˆHÜ�JŠJ�v—‘¨Ö1Ü˜¤Ô/HÐ I×JÒJØ%Ÿ~™~Ö/�Ü˜k¬2¯9©9×5Ò5Ü×(Ò(¨×);Ñ);À)ÐZ`×aÜ ¬R¯Y©Y×7Ô7Ü×(Ò(¨×);Ñ);À(ÐYa×bó	  0ñ KrE   r>   N)r@   rA   rB   rC   Úbase_model_prefixÚ"_keys_to_ignore_on_load_unexpectedÚ_keys_to_ignore_on_load_missingrS   Úno_gradrÓ  rD   r[   r\   s   @rF   rÆ  rÆ  …  s7   ø‡ € ØÐð +5¨Ð&à'4 oÐ#à
‡]‚]ƒ_÷có öcrE   rÆ  c                   ó>   a a€ ] tR tRt oV3R lV 3R lltRtVtV ;t# )ÚSapiens2Encoderi§  c                ó    <€ V ^8„  d   QhRS[ /# r  r  )rV   rW   s   "€rF   rX   ÚSapiens2Encoder.__annotate__¨  s   ø€ ÷ 
ñ 
™~ñ 
rE   c           
     óÀ   <€ \         SV `  V4       \        P                  ! \	        VP
                  4       Uu. uF  p\        WR 7      NK  	  up4      V n        R# u upi )rg  N)r  r  r   r”  rU  ró  rc  r   rE  s   && €rF   r  ÚSapiens2Encoder.__init__¨  sG   ø€ Ü‰Ñ˜Ô Ü—]’]ÜINÈv×OgÑOgÔIhÓiÑIh¸IŒ]˜6×7ÑIhÑió
ˆŽ
ùÚis   ¸A)r   r,  rÈ  s   @@rF   rë  rë  §  s   ù‡ € ÷
÷ 
ó 
rE   rë  c                   óZ   a a€ ] tR tRt oV3R lV 3R lltRV3R lV 3R llltRtVtV ;t# )ÚSapiens2Modeli¯  c                ó    <€ V ^8„  d   QhRS[ /# r  r  )rV   rW   s   "€rF   rX   ÚSapiens2Model.__annotate__°  ó   ø€ ÷ Qñ Q™~ñ QrE   c                ór   <€ \         SV `  V4       \        VP                  VP                  R 7      V n        R# ©r8  N©r  r  r.  rû  r   r  r  s   &&€rF   r  ÚSapiens2Model.__init__°  ó*   ø€ Ü‰Ñ˜Ô Ü# F×$6Ñ$6¸F×<OÑ<OÔPˆŽ	rE   c                óx   <€ V ^8„  d   QhRS[ P                  RS[ P                  R,          RS[S[,          RS[/# )rM   r  r  Nr
  rl   )rS   rn   r   r!   r   )rV   rW   s   "€rF   rX   ró  ´  sL   ø€ ÷ Xñ Xá—l‘lðXñ Ÿ™¨Õ,ðXñ Ñ+Õ,ð	Xñ
 
$ñXrE   c                ó*   <€ \         SV `  ! V3RV/VB # )a@  
bool_masked_pos (`torch.BoolTensor` of shape `(batch_size, sequence_length)`, *optional*):
    Boolean masked positions. Indicates which patches are masked (1) and which aren't (0). Only relevant for
    pre-training.

Example:

```python
>>> from transformers import AutoImageProcessor, AutoModel
>>> from transformers.image_utils import load_image
>>> import torch

>>> image = load_image("http://images.cocodataset.org/val2017/000000004016.jpg")
>>> image_processor = AutoImageProcessor.from_pretrained("facebook/sapiens2-pretrain-0.4b")
>>> model = AutoModel.from_pretrained("facebook/sapiens2-pretrain-0.4b")

>>> inputs = image_processor(images=image, return_tensors="pt")
>>> with torch.inference_mode():
...     outputs = model(**inputs)

>>> cls_token = outputs.pooler_output
>>> cls_token.shape
torch.Size([1, 1024])
```
r  )r  r  )r  r  r  r
  r  s   &&&,€rF   r  ÚSapiens2Model.forward´  s   ø€ ô> ‰wŠ˜|ÑW¸_ÐWÐPVÑWÐWrE   ©r  rÂ  r  rÈ  s   @@rF   rñ  rñ  ¯  s#   ù‡ € ÷Qó Q÷X÷ Xõ XrE   rñ  c                   óP   a a€ ] tR tRt oV3R lV 3R lltV3R lR ltRtVtV ;t# )ÚSapiens2BackboneiÖ  c                ó    <€ V ^8„  d   QhRS[ /# r  r  )rV   rW   s   "€rF   rX   ÚSapiens2Backbone.__annotate__×  rô  rE   c                ór   <€ \         SV `  V4       \        VP                  VP                  R 7      V n        R# rö  r÷  r  s   &&€rF   r  ÚSapiens2Backbone.__init__×  rù  rE   c                óP   <€ V ^8„  d   QhRS[ P                  RS[S[,          RS[/# )rM   r  r
  rl   )rS   rn   r   r!   r=   )rV   rW   s   "€rF   rX   r  Û  s8   ø€ ÷ F
ñ F
á—l‘lðF
ñ Ñ+Õ,ðF
ñ 
 ñ	F
rE   c                óú  € VP                  V P                  P                  P                  P                  4      pV P                  V4      pV P                  V4      pRVR&   V P                  ! W43/ VB pVP                  pVP                  w  rxršV P                  P                  p\        V\        4      '       d   TMV^ ,          p\        V\        4      '       d   TMV^,          pWœ,          pW­,          p^\        V P                  R^ 4      ,           p\        V P                  RR4      p. . pp\        \        V P                   V4      4       Fë  w  pw  ppV P                  P"                  '       d   V P%                  V4      pVV P&                  9   g   KI  V'       d   VP)                  VR	,          4       VRVR1R3,          pV P                  P*                  '       dF   VP-                  W~VVP                  R
,          4      P/                  ^ ^^^4      P1                  4       pMTpVP)                  V4       Kí  	  \3        \5        V4      V'       d   \5        V4      MRVP                  VP6                  R7      # )aª  
Example:

```python
>>> from transformers import AutoBackbone, AutoImageProcessor
>>> from transformers.image_utils import load_image
>>> import torch

>>> image = load_image("http://images.cocodataset.org/val2017/000000004016.jpg")
>>> image_processor = AutoImageProcessor.from_pretrained("facebook/sapiens2-pretrain-0.4b")
>>> model = AutoBackbone.from_pretrained("facebook/sapiens2-pretrain-0.4b")

>>> inputs = image_processor(images=image, return_tensors="pt")
>>> with torch.inference_mode():
...     outputs = model(**inputs, return_class_token=True)

>>> outputs.feature_maps[0].shape
torch.Size([1, 1024, 64, 48])
>>> outputs.cls_tokens[0].shape
torch.Size([1, 1024])
```
TÚoutput_hidden_statesr  Úreturn_class_tokenFr–   N)Úfeature_mapsÚ
cls_tokensrP   rQ   )r–   r   r–   rt   )r™  Ú
embeddingsÚpatch_embeddingsrÖ  r‰   Úrope_embeddingsrÇ  rP   r—   r  rÜ  rR  ro   ÚgetattrÚ	enumerater6  Ústage_namesr  r  Úout_featuresrV  Úreshape_hidden_statesrÑ   ÚpermuterS  r=   rU   rQ   )r  r  r
  rP   rI  r±   Ústage_hidden_statesr�  rÖ   rà  rá  rÜ  r)  r*  Únum_patches_heightÚnum_patches_widthÚ
num_prefixr  r  r	  ÚidxÚ
stage_nameÚhidden_stateÚpatch_tokensÚfeature_maps   &&,                      rF   r  ÚSapiens2Backbone.forwardÛ  s  € ð6 $—‘ t§¡×'GÑ'G×'NÑ'N×'TÑ'TÓUˆØŸ™¨Ó5ˆØ"×2Ñ2°<Ó@Ðà)-ˆÐ%Ñ&Ø—’˜MÑIÀ&ÑIˆØ$×2Ñ2Ðà3?×3EÑ3EÑ0ˆ
�|Ø—[‘[×+Ñ+ˆ
Ü%/°
¼C×%@Ò%@‘zÀjÐQRÅmˆÜ%/°
¼C×%@Ò%@‘zÀjÐQRÅmˆØ)Õ9ÐØ'Õ7Ðàœ §¡Ð.CÀQÓGÕGˆ
Ü$ T§[¡[Ð2FÈÓNÐà#% r�jˆÜ/8¼¸T×=MÑ=MÐObÓ9cÖ/dÑ+ˆCÑ+�*˜lØ�{‰{×5×5Ð5Ø#Ÿy™y¨Ó6�à˜T×.Ñ.Ö.ß%Ø×%Ñ% l°7Õ&;Ô<Ø+¨A¨z©{¸AÐ,=Õ>�Ø—;‘;×4×4Ð4à$×,Ñ,¨ZÐM^Ð`l×`rÑ`rÐsuÕ`vÓwß ™  A q¨!Ó,ß#™›ñ  ð #/�Kà×#Ñ# KÖ0ñ# 0eô& &Ü˜|Ó,ß,>”u˜ZÔ(ÀDØ ×.Ñ.Ø×(Ñ(ô	
ð 	
rE   rý  r  rÈ  s   @@rF   rÿ  rÿ  Ö  s#   ù‡ € ÷Qó Q÷F
÷ F
ð F
rE   rÿ  c                   óh   a a€ ] tR tR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
# )ÚSapiens2ForSemanticSegmentationi$  c                ó    <€ V ^8„  d   QhRS[ /# r  r  )rV   rW   s   "€rF   rX   Ú,Sapiens2ForSemanticSegmentation.__annotate__&  ó   ø€ ÷ ñ ™~ñ rE   c                ó¨   <€ \         SV `  V4       VP                  V n        \        V4      V n        \        V4      V n        V P                  4        R # rÂ  ©r  r  r—  rñ  rÇ  rˆ  Údecode_headÚ	post_initr  s   &&€rF   r  Ú(Sapiens2ForSemanticSegmentation.__init__&  ó@   ø€ Ü‰Ñ˜Ô Ø ×+Ñ+ˆŒÜ" 6Ó*ˆŒ
Ü'¨Ó/ˆÔØ�‰ÖrE   c                óx   <€ V ^8„  d   QhRS[ P                  RS[ P                  R,          RS[S[,          RS[/# ©rM   r  rP  Nr
  rl   )rS   rT   Ú
LongTensorr   r!   r   )rV   rW   s   "€rF   rX   r   /  sJ   ø€ ÷ 9
ñ 9
á×'Ñ'ð9
ñ × Ñ  4Õ'ð9
ñ Ñ+Õ,ð	9
ñ
 
!ñ9
rE   c                óÖ  € Ve'   V P                   P                  ^8X  d   \        R4      hV P                  ! V3/ VB pVP                  w  rVrxV P                   P
                  p	\        V	\        4      '       d   T	MV	^ ,          p
\        V	\        4      '       d   T	MV	^,          pWz,          pW‹,          pVP                  R^V P                   P                  ,           R13,          pVP                  ^^4      P                  VRWÍ4      pV P                  V4      pRpVe(   V P                  VW P                   P                  R7      p\        VVVP                   VP"                  R7      # )a`  
labels (`torch.LongTensor` of shape `(batch_size, height, width)`, *optional*):
    Ground truth semantic segmentation maps for computing the loss.
    Indices should be in `[0, ..., config.num_labels - 1]`.
    If `config.num_labels > 1`, a classification loss is computed (Cross-Entropy).

Example:

```python
>>> from transformers import AutoImageProcessor, AutoModel
>>> from transformers.image_utils import load_image
>>> import torch

>>> image = load_image("http://images.cocodataset.org/val2017/000000004016.jpg")
>>> image_processor = AutoImageProcessor.from_pretrained("facebook/sapiens2-seg-0.4b")
>>> model = AutoModel.from_pretrained("facebook/sapiens2-seg-0.4b")

>>> inputs = image_processor(image, return_tensors="pt")
>>> with torch.inference_mode():
...     outputs = model(**inputs)

>>> outputs.logits.shape
torch.Size([1, 29, 1024, 768])
```
Nz/The number of labels should be greater than oner–   )Úignore_index)rN   ÚlogitsrP   rQ   rt   )r  r—  rÀ   rÇ  r—   rÜ  rR  ro   Úlast_hidden_stater  rO  rÑ   r$  Úloss_functionr  r   rP   rQ   )r  r  rP  r
  rW  r�  rÖ   r{   rz   rÜ  r)  r*  râ  rã  r  r  r-  rN   s   &&&,              rF   r  Ú'Sapiens2ForSemanticSegmentation.forward-  sA  € ðB Ò $§+¡+×"8Ñ"8¸AÔ"=ÜÐNÓOÐOà—*’*˜\Ñ4¨VÑ4ˆà'3×'9Ñ'9Ñ$ˆ
�vØ—[‘[×+Ñ+ˆ
Ü%/°
¼C×%@Ò%@‘zÀjÐQRÅmˆÜ%/°
¼C×%@Ò%@‘zÀjÐQRÅmˆØÕ-ˆØÕ+ˆà×0Ñ0°°A¸¿¹×8WÑ8WÕ4WÑ4YÐ1YÕZˆØ"×,Ñ,¨Q°Ó2×:Ñ:¸:ÀrÈ<Óeˆà×!Ñ! +Ó.ˆàˆØÒØ×%Ñ% f¨fÇ;Á;×CiÑCiÐ%ÓjˆDä&ØØØ!×/Ñ/Ø×)Ñ)ô	
ð 	
rE   ©r$  rÇ  r—  rÂ  ©r@   rA   rB   rC   r  r$   r"   r  rD   r[   rÇ  rÈ  s   @@rF   r  r  $  s5   ù‡ € ÷ó ð Ø÷9
ñ 9
ó ó ÷9
ð 9
rE   r  zfacebook/sapiens2-pose-0.4bz�
    The Sapiens2 model with a pose estimation head on top (a set of heatmap predictors on top of the hidden states output).
    )rÉ  r;   c                   óh   a a€ ] tR tR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
# )ÚSapiens2ForPoseEstimationik  c                ó    <€ V ^8„  d   QhRS[ /# r  r  )rV   rW   s   "€rF   rX   Ú&Sapiens2ForPoseEstimation.__annotate__r  r!  rE   c                ó¨   <€ \         SV `  V4       VP                  V n        \        V4      V n        \        V4      V n        V P                  4        R # rÂ  r#  r  s   &&€rF   r  Ú"Sapiens2ForPoseEstimation.__init__r  r'  rE   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[/# )rM   r  r  NrP  Úlabel_weightsr
  rl   )rS   rT   rn   r   r!   rH   )rV   rW   s   "€rF   rX   r6  {  sz   ø€ ÷ @
ñ @
á×'Ñ'ð@
ñ —L‘L 4Õ'ð@
ñ ×!Ñ! DÕ(ð	@
ñ
 ×(Ñ(¨4Õ/ð@
ñ Ñ+Õ,ð@
ñ 
%ñ@
rE   c                ó„  € V P                   ! V3/ VB pVP                  w  rxršV P                  P                  p\	        V\
        4      '       d   TMV^ ,          p\	        V\
        4      '       d   TMV^,          pWœ,          pW­,          pVP                  R^V P                  P                  ,           R13,          pVP                  ^^4      P                  VRWï4      pV P                  V4      pVe   \        VV4      pRpVe   \        P                  ! VW4R7      p\        VVVP                  VP                   R7      # )aX  
flip_pairs (`torch.Tensor` of shape `(num_pairs, 2)`, *optional*):
    Pairs of keypoints which are mirrored (for example, left ear -- right ear), used for
    test-time flip augmentation. When provided, the model assumes `pixel_values` contains
    horizontally-flipped images and calls `flip_back` on the output heatmaps to restore the
    original orientation.
labels (`torch.FloatTensor` of shape `(batch_size, num_keypoints, height, width)`, *optional*):
    Heatmap ground truth for computing the loss.
label_weights (`torch.FloatTensor` of shape `(batch_size, num_labels, 1, 1)` or `(batch_size, num_labels, height, width)`, *optional*):
    Visibility weights for each keypoint. Must be broadcastable to the shape of `labels`.

Example:

```python
>>> from transformers import AutoImageProcessor, AutoModel
>>> from transformers.image_utils import load_image
>>> import torch

>>> image = load_image("http://images.cocodataset.org/val2017/000000004016.jpg")
>>> image_processor = AutoImageProcessor.from_pretrained("facebook/sapiens2-pose-0.4b")
>>> model = AutoModel.from_pretrained("facebook/sapiens2-pose-0.4b")

>>> boxes = [[[270.8, 0.6, 294.1, 379.5]]]
>>> inputs = image_processor(image, boxes=boxes, return_tensors="pt")
>>> with torch.inference_mode():
...     outputs = model(**inputs)

>>> outputs.heatmaps.shape
torch.Size([1, 308, 256, 192])
```
r–   N)rÖ  )rN   r¶   rP   rQ   rt   )rÇ  r—   r  rÜ  rR  ro   r.  r  rO  rÑ   r$  r:   rŸ   Úmse_lossrH   rP   rQ   )r  r  r  rP  r:  r
  rW  r�  rÖ   r{   rz   rÜ  r)  r*  râ  rã  r  r  r¶   rN   s   &&&&&,              rF   r  Ú!Sapiens2ForPoseEstimation.forwardy  s!  € ðR —*’*˜\Ñ4¨VÑ4ˆà'3×'9Ñ'9Ñ$ˆ
�vØ—[‘[×+Ñ+ˆ
Ü%/°
¼C×%@Ò%@‘zÀjÐQRÅmˆÜ%/°
¼C×%@Ò%@‘zÀjÐQRÅmˆØÕ-ˆØÕ+ˆà×0Ñ0°°A¸¿¹×8WÑ8WÕ4WÑ4YÐ1YÕZˆØ"×,Ñ,¨Q°Ó2×:Ñ:¸:ÀrÈ<Óeˆà×#Ñ# KÓ0ˆØÒ!Ü  ¨:Ó6ˆHàˆØÒÜ—:’:˜h¨ÔEˆDä*ØØØ!×/Ñ/Ø×)Ñ)ô	
ð 	
rE   r1  rÄ  r2  rÈ  s   @@rF   r4  r4  k  s9   ù‡ € ÷ó ð Ø÷@
ñ @
ó ó ÷@
ð @
rE   r4  zfacebook/sapiens2-normal-0.4bzƒ
    The Sapiens2 model with a normal estimation head on top (a PixelShuffle-based decoder that predicts surface normal maps).
    c                   óh   a a€ ] tR tR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
# )ÚSapiens2ForNormalEstimationi¾  c                ó    <€ V ^8„  d   QhRS[ /# r  r  )rV   rW   s   "€rF   rX   Ú(Sapiens2ForNormalEstimation.__annotate__Å  r!  rE   c                ó¨   <€ \         SV `  V4       VP                  V n        \        V4      V n        \        V4      V n        V P                  4        R # rÂ  r#  r  s   &&€rF   r  Ú$Sapiens2ForNormalEstimation.__init__Å  r'  rE   c                óx   <€ V ^8„  d   QhRS[ P                  RS[ P                  R,          RS[S[,          RS[/# r)  )rS   rT   r   r!   rK   )rV   rW   s   "€rF   rX   rA  Î  sJ   ø€ ÷ 4
ñ 4
á×'Ñ'ð4
ñ ×!Ñ! DÕ(ð4
ñ Ñ+Õ,ð	4
ñ
 
'ñ4
rE   c                óJ  € V P                   ! V3/ VB pVP                  w  rVrxV P                  P                  p	\	        V	\
        4      '       d   T	MV	^ ,          p
\	        V	\
        4      '       d   T	MV	^,          pWz,          pW‹,          pVP                  R^V P                  P                  ,           R13,          pVP                  ^^4      P                  VRWÍ4      pV P                  V4      pRpVe   \        R4      h\        VVVP                  VP                  R7      # )aÝ  
labels (`torch.FloatTensor` of shape `(batch_size, num_labels, height, width)`, *optional*):
    Ground-truth surface normal maps for computing the loss.

Example:

```python
>>> from transformers import AutoImageProcessor, AutoModel
>>> from transformers.image_utils import load_image
>>> import torch

>>> image = load_image("http://images.cocodataset.org/val2017/000000004016.jpg")
>>> image_processor = AutoImageProcessor.from_pretrained("facebook/sapiens2-normal-0.4b")
>>> model = AutoModel.from_pretrained("facebook/sapiens2-normal-0.4b")

>>> inputs = image_processor(image, return_tensors="pt")
>>> with torch.inference_mode():
...     outputs = model(**inputs)

>>> outputs.normals.shape
torch.Size([1, 3, 1024, 768])
```
r–   NúTraining is not yet supported)rN   rO   rP   rQ   rt   )rÇ  r—   r  rÜ  rR  ro   r.  r  rO  rÑ   r$  ÚNotImplementedErrorrK   rP   rQ   )r  r  rP  r
  rW  r�  rÖ   r{   rz   rÜ  r)  r*  râ  rã  r  r  rO   rN   s   &&&,              rF   r  Ú#Sapiens2ForNormalEstimation.forwardÌ  s
  € ð> —*’*˜\Ñ4¨VÑ4ˆà'3×'9Ñ'9Ñ$ˆ
�vØ—[‘[×+Ñ+ˆ
Ü%/°
¼C×%@Ò%@‘zÀjÐQRÅmˆÜ%/°
¼C×%@Ò%@‘zÀjÐQRÅmˆØÕ-ˆØÕ+ˆà×0Ñ0°°A¸¿¹×8WÑ8WÕ4WÑ4YÐ1YÕZˆØ"×,Ñ,¨Q°Ó2×:Ñ:¸:ÀrÈ<Óeˆà×"Ñ" ;Ó/ˆàˆØÒÜ%Ð&EÓFÐFä,ØØØ!×/Ñ/Ø×)Ñ)ô	
ð 	
rE   r1  rÂ  r2  rÈ  s   @@rF   r?  r?  ¾  s5   ù‡ € ÷ó ð Ø÷4
ñ 4
ó ó ÷4
ð 4
rE   r?  zfacebook/sapiens2-pointmap-0.4bzÅ
    The Sapiens2 model with a pointmap head on top (a PixelShuffle-based decoder that predicts per-pixel 3D XYZ
    coordinates, plus an optional scale branch for focal-length normalization).
    c                   óh   a a€ ] tR tR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
# )ÚSapiens2ForPointmapEstimationi  c                ó    <€ V ^8„  d   QhRS[ /# r  r  )rV   rW   s   "€rF   rX   Ú*Sapiens2ForPointmapEstimation.__annotate__  s   ø€ ÷ 	ñ 	™~ñ 	rE   c                ó  <€ \         SV `  V4       \        V4      V n        \	        V4      V n        VP                  e$   VP                  P                  e   \        V4      M\        P                  ! 4       V n        V P                  4        R # rÂ  )r  r  rñ  rÇ  rˆ  r$  rÍ  rÕ  r»  r   rB  Ú
scale_headr%  r  s   &&€rF   r  Ú&Sapiens2ForPointmapEstimation.__init__  sn   ø€ Ü‰Ñ˜Ô Ü" 6Ó*ˆŒ
Ü'¨Ó/ˆÔð ×!Ñ!Ò-°&×2DÑ2D×2\Ñ2\Ò2hô & fÔ-ä—’“ð 	Œð
 	�‰ÖrE   c                óx   <€ V ^8„  d   QhRS[ P                  RS[ P                  R,          RS[S[,          RS[/# r)  )rS   rT   r   r!   r^   )rV   rW   s   "€rF   rX   rL    sJ   ø€ ÷ 6
ñ 6
á×'Ñ'ð6
ñ ×!Ñ! DÕ(ð6
ñ Ñ+Õ,ð	6
ñ
 
)ñ6
rE   c                óÆ  € V P                   ! V3/ VB pVP                  w  rVrxV P                  P                  p	\	        V	\
        4      '       d   T	MV	^ ,          p
\	        V	\
        4      '       d   T	MV	^,          pWz,          pW‹,          pVP                  R^V P                  P                  ,           R13,          pVP                  ^^4      P                  VRWÍ4      pV P                  V4      p\	        V P                  \        P                  4      '       d   RMV P                  V4      pRpVe   \        R4      h\        VVVVP                   VP"                  R7      # )aÏ  
labels (`torch.FloatTensor` of shape `(batch_size, 3, height, width)`, *optional*):
    Ground-truth pointmap for computing the loss.

Example:

```python
>>> from transformers import AutoImageProcessor, AutoModel
>>> from transformers.image_utils import load_image
>>> import torch

>>> image = load_image("http://images.cocodataset.org/val2017/000000004016.jpg")
>>> image_processor = AutoImageProcessor.from_pretrained("facebook/sapiens2-pointmap-0.4b")
>>> model = AutoModel.from_pretrained("facebook/sapiens2-pointmap-0.4b")

>>> inputs = image_processor(image, return_tensors="pt")
>>> with torch.inference_mode():
...     outputs = model(**inputs)

>>> outputs.pointmaps.shape
torch.Size([1, 3, 1024, 768])
```
r–   NrF  )rN   r`   ra   rP   rQ   rt   )rÇ  r—   r  rÜ  rR  ro   r.  r  rO  rÑ   r$  rN  r   rB  rG  r^   rP   rQ   )r  r  rP  r
  rW  r�  rÖ   r{   rz   rÜ  r)  r*  râ  rã  r  r  r`   ra   rN   s   &&&,               rF   r  Ú%Sapiens2ForPointmapEstimation.forward  s2  € ð> —*’*˜\Ñ4¨VÑ4ˆà'3×'9Ñ'9Ñ$ˆ
�vØ—[‘[×+Ñ+ˆ
Ü%/°
¼C×%@Ò%@‘zÀjÐQRÅmˆÜ%/°
¼C×%@Ò%@‘zÀjÐQRÅmˆØÕ-ˆØÕ+ˆà×0Ñ0°°A¸¿¹×8WÑ8WÕ4WÑ4YÐ1YÕZˆØ"×,Ñ,¨Q°Ó2×:Ñ:¸:ÀrÈ<Óeˆà×$Ñ$ [Ó1ˆ	Ü# D§O¡O´R·[±[×AÒA‘ÀtÇÁÐWbÓGcˆàˆØÒÜ%Ð&EÓFÐFä.ØØØØ!×/Ñ/Ø×)Ñ)ô
ð 	
rE   )r$  rÇ  rN  rÂ  r2  rÈ  s   @@rF   rJ  rJ    s5   ù‡ € ÷	ó 	ð Ø÷6
ñ 6
ó ó ÷6
ð 6
rE   rJ  zfacebook/sapiens2-matting-1bzœ
    The Sapiens2 model with a matting head on top (a PixelShuffle-based decoder that predicts a
    pre-multiplied RGB foreground and an alpha matte).
    c                   óh   a a€ ] tR tR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
# )ÚSapiens2ForImageMattingiS  c                ó    <€ V ^8„  d   QhRS[ /# r  r  )rV   rW   s   "€rF   rX   Ú$Sapiens2ForImageMatting.__annotate__[  s   ø€ ÷ ñ ™~ñ rE   c                ó†   <€ \         SV `  V4       \        V4      V n        \	        V4      V n        V P                  4        R # rÂ  )r  r  rñ  rÇ  rˆ  r$  r%  r  s   &&€rF   r  Ú Sapiens2ForImageMatting.__init__[  s3   ø€ Ü‰Ñ˜Ô Ü" 6Ó*ˆŒ
Ü'¨Ó/ˆÔØ�‰ÖrE   c                óx   <€ V ^8„  d   QhRS[ P                  RS[ P                  R,          RS[S[,          RS[/# r)  )rS   rT   r   r!   rd   )rV   rW   s   "€rF   rX   rV  c  sJ   ø€ ÷ 9
ñ 9
á×'Ñ'ð9
ñ ×!Ñ! DÕ(ð9
ñ Ñ+Õ,ð	9
ñ
 
$ñ9
rE   c                óŒ  € V P                   ! V3/ VB pVP                  w  rVrxV P                  P                  p	\	        V	\
        4      '       d   T	MV	^ ,          p
\	        V	\
        4      '       d   T	MV	^,          pWz,          pW‹,          pVP                  R^V P                  P                  ,           R13,          pVP                  ^^4      P                  VRWÍ4      pV P                  V4      P                  4       pVR,          pVR,          pRpVe   \        R4      h\        VVVVP                  VP                  R7      # )a	  
labels (`torch.FloatTensor` of shape `(batch_size, 4, height, width)`, *optional*):
    Ground-truth matting targets for computing the loss.

Example:

```python
>>> from transformers import AutoImageProcessor, AutoModel
>>> from transformers.image_utils import load_image
>>> import torch

>>> image = load_image("http://images.cocodataset.org/val2017/000000004016.jpg")
>>> image_processor = AutoImageProcessor.from_pretrained("facebook/sapiens2-matting-1b")
>>> model = AutoModel.from_pretrained("facebook/sapiens2-matting-1b")

>>> inputs = image_processor(image, return_tensors="pt")
>>> with torch.inference_mode():
...     outputs = model(**inputs)

>>> outputs.alphas.shape
torch.Size([1, 1, 1024, 768])
>>> outputs.foregrounds.shape
torch.Size([1, 3, 1024, 768])
```
r–   NrF  )rN   rš  rf   rP   rQ   rt   r•  r–  )rÇ  r—   r  rÜ  rR  ro   r.  r  rO  rÑ   r$  ÚsigmoidrG  rd   rP   rQ   )r  r  rP  r
  rW  r�  rÖ   r{   rz   rÜ  r)  r*  râ  rã  r  r  r¢  rf   rš  rN   s   &&&,                rF   r  ÚSapiens2ForImageMatting.forwarda  s)  € ðB —*’*˜\Ñ4¨VÑ4ˆà'3×'9Ñ'9Ñ$ˆ
�vØ—[‘[×+Ñ+ˆ
Ü%/°
¼C×%@Ò%@‘zÀjÐQRÅmˆÜ%/°
¼C×%@Ò%@‘zÀjÐQRÅmˆØÕ-ˆØÕ+ˆà×0Ñ0°°A¸¿¹×8WÑ8WÕ4WÑ4YÐ1YÕZˆØ"×,Ñ,¨Q°Ó2×:Ñ:¸:ÀrÈ<Óeˆà×"Ñ" ;Ó/×7Ñ7Ó9ˆØ˜e•nˆØ˜•ˆàˆØÒÜ%Ð&EÓFÐFä)ØØØ#Ø!×/Ñ/Ø×)Ñ)ô
ð 	
rE   )r$  rÇ  rÂ  r2  rÈ  s   @@rF   rT  rT  S  s5   ù‡ € ÷ó ð Ø÷9
ñ 9
ó ó ÷9
ð 9
rE   rT  )g      ô?)rÃ  )rî  rË  r  r4  r?  rJ  rT  rñ  rÆ  rÿ  r  )€Úcollections.abcr   r   Údataclassesr   Útypingr   rS   Útorch.nn.functionalr   r	   rŸ   Úhuggingface_hub.dataclassesr   Útorchvision.transforms.v2rÃ   Ú&transformers.image_processing_backendsr
   Ú2transformers.models.dinov3_vit.modeling_dinov3_vitr   Ú r   rÔ  Úactivationsr   Úconfiguration_utilsr   Úimage_processing_utilsr   Úimage_transformsr   r   Úimage_utilsr   r   r   r   r   r   r   r   Úmodeling_outputsr   r   r   Úmodeling_utilsr   r   Úprocessing_utilsr   Úutilsr    r!   r"   r#   Úutils.genericr$   Úbeit.image_processing_beitr%   r&   Ú#dinov3_vit.configuration_dinov3_vitr'   Údinov3_vit.modeling_dinov3_vitr(   r)   r*   r+   r,   r-   r.   r/   r0   r1   Úgemma2.modeling_gemma2r2   Úllama.modeling_llamar3   Ú mask2former.modeling_mask2formerr4   Ú0pp_ocrv5_server_det.modeling_pp_ocrv5_server_detr5   Úsam3.processing_sam3r6   r7   Úvitmatte.modeling_vitmatter8   Úvitpose.modeling_vitposer9   r:   Ú
get_loggerr@   Úloggerr=   rH   rK   r^   rd   rƒ   r´   rÍ   rÞ   r  r  r  rË  rî  r  r!  r.  r0  ra  rc  rn  r§  rˆ  r£  r­  r»  rÆ  rë  rñ  rÿ  r  r4  r?  rJ  rT  Ú__all__r>   rE   rF   Ú<module>r}     sÙ  ð÷ /Ý !Ý ã ß Ð Ý .Ý Ý 7å EÝ Vå &Ý !Ý 3Ý 2ß E÷	÷ 	ó 	÷ aÑ `ß FÝ &ß LÓ LÝ -ß UÝ A÷÷ ÷ õ =Ý /Ý IÝ aß GÝ ;ß Hð 
×	Ò	˜HÓ	%€ñ ðôð ô	Ð4ó 	ó óð	ñ ðôð
 ô
Ð"8ó 
ó óð
ñ ðôð
 ô< Kó <ó óð<ñ* ðôð
 ô< kó <ó óð<ñ0 ðôð
 ô1Ð!3ó 1ó óð1÷"#÷L<÷~)õ<÷2E?ôP	Ð#;À5õ 	ôgÐ/ô gñT Ð7Ô8ØôSjÐ)ó Sjó ó 9ðSjñl Ð<Ô=Øôi(�_ó i(ó ó >ði(ôX>Ð,ô >ô5Ð$Bô 5ô	�lô 	ô/)Ð*ô /)ôd	Ð,ô 	ô*�Nô *ô-Ð:ô -ô`5-�2—9‘9ô 5-ôpNÐ&@ô Nô( §¡ô (ô&- §	¡	ô -ô2cÐ6ô côD
Ð&ô 
ô$X�Nô $XôNK
Ð(ô K
ñ\ Ð7Ô8ôC
Ð&=ó C
ó 9ðC
ñL Ø,ðôôJ
Ð 7ó J
óðJ
ñZ Ø.ðôô>
Ð"9ó >
óð>
ñB Ø0ðôôD
Ð$;ó D
óðD
ñN Ø-ðôôB
Ð5ó B
óðB
òJ‚rE   