+
    œ°³j,  ã                   ó
  € R t ^ RIHt ^ RIt^ RIHt ^RIHt ^RI	H
t
 ^RIHt ^RIHtHt ^RIHtHtHtHtHtHt ^R	IHtHt ^R
IHtHtHtHt ]P>                  ! ] 4      t! ! R R]RR7      t"] ! R R]4      4       t#R.t$R# )z$Image processor class for MobileViT.)ÚUnionN)Ú
functional)ÚTorchvisionBackend)Ú'SemanticSegmentationPostProcessorOutput)ÚBatchFeature)Úgroup_images_by_shapeÚreorder_images)ÚIMAGENET_STANDARD_MEANÚIMAGENET_STANDARD_STDÚChannelDimensionÚ
ImageInputÚPILImageResamplingÚSizeDict)ÚImagesKwargsÚUnpack)Ú
TensorTypeÚauto_docstringÚloggingÚrequires_backendsc                   ó0   a € ] tR t^-t o RtV 3R ltRtV tR# )ÚMobileVitImageProcessorKwargsaó  
do_flip_channel_order (`bool`, *optional*, defaults to `self.do_flip_channel_order`):
    Whether to flip the color channels from RGB to BGR or vice versa.
do_reduce_labels (`bool`, *optional*, defaults to `self.do_reduce_labels`):
    Whether or not to reduce all label values of segmentation maps by 1. Usually used for datasets where 0
    is used for background, and background itself is not included in all classes of a dataset (e.g.
    ADE20k). The background label will be replaced by 255.
c                ó2   <€ V ^8„  d   Qh/ S[ ;R&   S[ ;R&   # )é   Údo_flip_channel_orderÚdo_reduce_labels)Úbool)ÚformatÚ__classdict__s   "€Úy/home/luca/screen-checking/.venv/lib/python3.14/site-packages/transformers/models/mobilevit/image_processing_mobilevit.pyÚ__annotate__Ú*MobileVitImageProcessorKwargs.__annotate__-   s   ø‡ ‚ ñ  Ññ ñ Ñò ó    © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__annotate_func__Ú__static_attributes__Ú__classdictcell__)r   s   @r   r   r   -   s   ø‡ € ñ÷ ƒ r!   r   F)Útotalc                   ó&  a a€ ] tR t^;t oRt]t]P                  t	]
t]tR^à/tRtRRRR/tRtRtRtRtRtRtRtV3R	 lV 3R
 llt]RV3R lV 3R lll4       tRV3R lR lltV3R lR ltV3R lR ltRV3R lR lltRV3R lR lltRt Vt!V ;t"# )ÚMobileViTImageProcessorzSTorchvision backend for MobileViT with flip_channel_order and reduce_label support.Úshortest_edgeFÚheighté   ÚwidthTNc                ó0   <€ V ^8„  d   QhRS[ S[,          /# )r   Úkwargs)r   r   )r   r   s   "€r   r   Ú$MobileViTImageProcessor.__annotate__O   s   ø€ ÷ #ñ #¡Ñ(EÕ!Fñ #r!   c                ó(   <€ \         SV `  ! R/ VB  R # )Nr"   )ÚsuperÚ__init__)Úselfr3   Ú	__class__s   &,€r   r7   Ú MobileViTImageProcessor.__init__O   s   ø€ Ü‰ÒÑ"˜6Ô"r!   c                óP   <€ V ^8„  d   QhRS[ RS[ R,          RS[S[,          RS[/# )r   ÚimagesÚsegmentation_mapsNr3   Úreturn)r   r   r   r   )r   r   s   "€r   r   r4   S   sD   ø€ ÷ 
Gñ 
Gáð
Gñ &¨Õ,ð
Gñ Ñ6Õ7ð	
Gñ
 
ñ
Gr!   c                ó&   <€ \         SV `  ! W3/ VB # )zX
segmentation_maps (`ImageInput`, *optional*):
    The segmentation maps to preprocess.
)r6   Ú
preprocess)r8   r<   r=   r3   r9   s   &&&,€r   r@   Ú"MobileViTImageProcessor.preprocessR   s   ø€ ô ‰wÒ! &ÑF¸vÑFÐFr!   c                ó’   <€ V ^8„  d   QhRS[ RS[ R,          RS[RS[RS[S[,          R,          RS[S[R3,          R,          R	S[/# )
r   r<   r=   NÚdo_convert_rgbÚinput_data_formatÚreturn_tensorsÚdeviceztorch.devicer>   )r   r   r   Ústrr   r   r   )r   r   s   "€r   r   r4   _   sx   ø€ ÷ /Cñ /Cáð/Cñ &¨Õ,ð/Cñ ð	/Cñ
 ,ð/Cñ ™jÕ(¨4Õ/ð/Cñ ‘c˜>Ð)Õ*¨TÕ1ð/Cñ 
ñ/Cr!   c                ó  € V P                  WWFR7      pVP                  4       pRVR&   / p	V P                  ! V3/ VB V	R&   Ve®   V P                  V^R\        P                  R7      p
VP                  4       pVP                  RRRRR\        P                  /4       V P                  ! RR	V
/VB p
V
 Uu. uF1  pVP                  ^ 4      P                  \        P                  4      NK3  	  p
pW©R
&   \        W•R7      # u upi )z"Handle extra inputs beyond images.)r<   rC   rD   rF   Fr   Úpixel_values)r<   Úexpected_ndimsrC   rD   Ú
do_rescaler   Úresampler<   Úlabels)ÚdataÚtensor_typer"   )Ú_prepare_image_like_inputsÚcopyÚ_preprocessr   ÚFIRSTÚupdater   ÚNEARESTÚsqueezeÚtoÚtorchÚint64r   )r8   r<   r=   rC   rD   rE   rF   r3   Úimages_kwargsrN   Úprocessed_segmentation_mapsÚsegmentation_maps_kwargsÚprocessed_segmentation_maps   &&&&&&&,     r   Ú_preprocess_image_like_inputsÚ5MobileViTImageProcessor._preprocess_image_like_inputs_   s6  € ð ×0Ñ0ØÐL]ð 1ó 
ˆð Ÿ™›ˆØ,1ˆÐ(Ñ)ØˆØ#×/Ò/°ÑH¸-ÑHˆˆ^ÑàÒ(Ø*.×*IÑ*IØ(Ø Ø$Ü"2×"8Ñ"8ð	 +Jó +Ð'ð (.§{¡{£}Ð$Ø$×+Ñ+à  %Ø+¨UàÔ 2× :Ñ :ð	ôð +/×*:Ò*:ñ +Ø2ð+Ø6Nñ+Ð'ñ 3Nó+á2MÐ.ð +×2Ñ2°1Ó5×8Ñ8¼¿¹ÖEÙ2Mð (ð +ð 9�‰Nä ÔBÐBùò+s   Â57C>c                óB   <€ V ^8„  d   QhRS[ R,          RS[ R,          /# )r   rM   útorch.Tensorr>   )Úlist)r   r   s   "€r   r   r4   �   s%   ø€ ÷ ñ ¡4¨Õ#7ð ¹DÀÕ<Pñ r!   c           
     ó~  € \        \        V4      4       F¤  pW,          p\        P                  ! V^ 8H  \        P                  ! ^ÿVP
                  VP                  R7      V4      pV^,
          p\        P                  ! V^þ8H  \        P                  ! ^ÿVP
                  VP                  R7      V4      pW1V&   K¦  	  V# )z/Reduce label values by 1, replacing 0 with 255.)ÚdtyperF   )ÚrangeÚlenrX   ÚwhereÚtensorrd   rF   )r8   rM   ÚidxÚlabels   &&  r   Úreduce_labelÚ$MobileViTImageProcessor.reduce_label�   s‘   € äœ˜V›Ö%ˆCØ•KˆEÜ—K’K ¨¡
¬E¯LªL¸ÀEÇKÁKÐX]×XdÑXdÔ,eÐglÓmˆEØ˜A•IˆEÜ—K’K ¨¡¬e¯lªl¸3ÀeÇkÁkÐZ_×ZfÑZfÔ.gÐinÓoˆEØ�3‹Kñ &ð ˆr!   c                ó"   <€ V ^8„  d   QhRRRR/# )r   r<   ra   r>   r"   )r   r   s   "€r   r   r4   š   s   ø€ ÷ ñ ¨ð ¸Nñ r!   c                óÎ   € VP                   ^8X  d!   VP                  4       pV. RO,          VR&   V# VP                   ^8X  d#   VP                  4       pVR. RO3,          VR&   V# V# )zFlip RGB to BGR or vice versa.ºé    é   NºNNN)r   é   rp   )rr   ro   )ÚndimÚclone)r8   r<   Úflippeds   && r   Úflip_channel_orderÚ*MobileViTImageProcessor.flip_channel_orderš   s_   € à�;‰;˜!Ôà—l‘l“nˆGØ!¢)Õ,ˆG�C‰LØˆNØ�[‰[˜AÔà—l‘l“nˆGØ$ Qª	 \Õ2ˆG�F‰OØˆNØˆr!   c                óŠ   <€ V ^8„  d   QhRS[ R,          RS[RS[RRRS[RS[R	S[R
S[RS[R,          RS[RS[RS[ R,          /# )r   r<   ra   Ú	do_resizeÚsizerL   z7PILImageResampling | tvF.InterpolationMode | int | NoneÚdo_center_cropÚ	crop_sizerK   Úrescale_factorÚdisable_groupingNr   r   r>   )rb   r   r   Úfloat)r   r   s   "€r   r   r4   ¨   s’   ø€ ÷ & ñ & á�^Õ$ð& ñ ð& ñ ð	& ð
 Lð& ñ ð& ñ ð& ñ ð& ñ ð& ñ  �+ð& ñ ð& ñ  $ð& ñ 
ˆnÕ	ñ& r!   c                óò  € V
'       d   V P                  V4      p\        WR7      w  rÞ/ pVP                  4        F%  w  ppV'       d   V P                  VW44      pVVV&   K'  	  \	        Wþ4      p\        VV	R7      w  rÞ/ pVP                  4        FX  w  ppV'       d   V P                  VV4      pV'       d   V P                  VV4      pV'       d   V P                  V4      pVVV&   KZ  	  \	        VV4      pV# )z#Custom preprocessing for MobileViT.)r   )rk   r   ÚitemsÚresizer   Úcenter_cropÚrescalerw   )r8   r<   rz   r{   rL   r|   r}   rK   r~   r   r   r   r3   Úgrouped_imagesÚgrouped_images_indexÚresized_images_groupedÚshapeÚstacked_imagesÚresized_imagesÚprocessed_images_groupedÚprocessed_imagess   &&&&&&&&&&&&,        r   rR   Ú#MobileViTImageProcessor._preprocess¨   sø   € ÷  Ø×&Ñ& vÓ.ˆFä/DÀVÔ/oÑ,ˆØ!#ÐØ%3×%9Ñ%9Ö%;Ñ!ˆE�>ßØ!%§¡¨^¸TÓ!L�Ø,:Ð" 5Ó)ñ &<ô (Ð(>ÓUˆä/DÀ^ÐfvÔ/wÑ,ˆØ#%Ð Ø%3×%9Ñ%9Ö%;Ñ!ˆE�>ßØ!%×!1Ñ!1°.À)Ó!L�ßØ!%§¡¨n¸nÓ!M�ß$Ø!%×!8Ñ!8¸Ó!H�Ø.<Ð$ UÓ+ñ &<ô *Ð*BÐDXÓYÐØÐr!   c                ó^   <€ V ^8„  d   QhRS[ S[S[S[3,          ,          R,          RS[RR/# )r   Útarget_sizesNÚreturn_segmentation_scoresr>   zBlist[torch.Tensor] | list[SemanticSegmentationPostProcessorOutput])rb   ÚtupleÚintr   )r   r   s   "€r   r   r4   Ð   s>   ø€ ÷ =%ñ =%ñ ™5¡¡c �?Õ+¨dÕ2ð=%ñ %)ð	=%ð
 
Nñ=%r!   c           
     ó  € \        V R4       VP                  p\        V4      pVeð   \        V4      \        V4      8w  d   \        R4      h\	        V\
        P                  4      '       d   VP                  4       p. p\        V4       F‰  p\
        P                  P                  P                  WG,          P                  ^ R7      W',          RRR7      pVP                  \        RV^ ,          P                  ^ R7      RV^ ,          /R	7      4       K‹  	  MD\        V4       U	u. uF/  p	\        RWI,          P                  ^ R7      RWI,          /R	7      NK1  	  pp	V'       g   V U
u. uF  qªP                   NK  	  pp
V# u up	i u up
i )
a1  
Converts the output of [`MobileViTForSemanticSegmentation`] into semantic segmentation maps.

Args:
    outputs ([`MobileViTForSemanticSegmentation`]):
        Raw outputs of the model.
    target_sizes (`list[tuple[int, int]]`, *optional*):
        List of tuples corresponding to the requested final size (height, width) of each prediction.
    return_segmentation_scores (`bool`, *optional*, defaults to `False`):
        Whether to return segmentation scores alongside the segmentation map. When `True`, each element of
        the returned list is a [`SemanticSegmentationPostProcessorOutput`] with fields `segmentation`
        (class IDs, shape `(height, width)`) and `segmentation_scores` (shape `(num_classes, height, width)`).

Returns:
    `list[torch.Tensor]` or `list[SemanticSegmentationPostProcessorOutput]`: When
    `return_segmentation_scores=False` (default), a list of length `batch_size` where each item is a
    segmentation map of shape `(height, width)` with class IDs. When `return_segmentation_scores=True`,
    a list of [`SemanticSegmentationPostProcessorOutput`] with fields `segmentation` (class IDs, shape
    `(height, width)`) and `segmentation_scores` (shape `(num_classes, height, width)`). In both cases,
    `(height, width)` corresponds to the target size (if `target_sizes` is specified).
rX   zTMake sure that you pass in as many target sizes as the batch dimension of the logits)ÚdimÚbilinearF)r{   ÚmodeÚalign_cornersÚsegmentationÚsegmentation_scores)rN   )r   Úlogitsrf   Ú
ValueErrorÚ
isinstancerX   ÚTensorÚtolistre   Únnr   ÚinterpolateÚ	unsqueezeÚappendr   Úargmaxr™   )r8   Úoutputsr�   r‘   r›   Ú
batch_sizeÚsemantic_segmentationri   Úresized_logitsÚiÚitems   &&&&       r   Ú"post_process_semantic_segmentationÚ:MobileViTImageProcessor.post_process_semantic_segmentationÐ   s{  € ô6 	˜$ Ô(Ø—‘ˆÜ˜“[ˆ
ØÒ#Ü�6‹{œc ,Ó/Ô/Ü Øjóð ô ˜,¬¯©×5Ò5Ø+×2Ñ2Ó4�Ø$&Ð!Ü˜ZÖ(�Ü!&§¡×!4Ñ!4×!@Ñ!@Ø•K×)Ñ)¨aÐ)Ó0°|Õ7HÈzÐinð "Aó "�ð &×,Ñ,Ü;à*¨N¸1Õ,=×,DÑ,DÈÐ,DÓ,KØ1°>À!Õ3Dðôöò	 )ô" ˜zÔ*ó	%ñ +�Aô 8Ø(¨&­)×*:Ñ*:¸qÐ*:Ó*AÐCXÐZ`ÕZcÐd÷ñ +ð	 "ð %÷ *ÙCXÓ$YÑCX¸4×%6Ô%6ÑCXÐ!Ð$Yà$Ð$ùò%ùò %Zs   Ä$5E?Å'Fr"   )N)FT)NF)#r#   r$   r%   r&   r'   r   Úvalid_kwargsr   ÚBICUBICrL   r	   Ú
image_meanr
   Ú	image_stdr{   Údefault_to_squarer}   rz   r|   rK   Údo_normalizerC   r   r   r7   r   r@   r^   rk   rw   rR   r«   r)   r*   Ú__classcell__)r9   r   s   @@r   r-   r-   ;   sÆ   ù‡ € á]à0€Là!×)Ñ)€HØ'€JØ%€IØ˜SÐ!€DØÐØ˜3 ¨Ð-€IØ€IØ€NØ€JØ€LØ€NØ ÐØÐ÷#ó #ð ÷
Gô 
Gó ð
G÷/Cò /C÷bð ÷ð ÷& ò & ÷P=%÷ =%ò =%r!   r-   )%r'   Útypingr   rX   Útorchvision.transforms.v2r   ÚtvFÚimage_processing_backendsr   Úimage_processing_outputsr   Úimage_processing_utilsr   Úimage_transformsr   r   Úimage_utilsr	   r
   r   r   r   r   Úprocessing_utilsr   r   Úutilsr   r   r   r   Ú
get_loggerr#   Úloggerr   r-   Ú__all__r"   r!   r   Ú<module>rÁ      s‚   ðñ +å ã Ý 7å ;Ý OÝ 2ß E÷÷ ÷ 5÷ó ð 
×	Ò	˜HÓ	%€ô L¸õ ð ôQ%Ð0ó Q%ó ðQ%ðh %Ð
%‚r!   