ó
    ‡Ž¡j"£  ã                   óÆ  • S SK r S SKrS SKJr  S SKJrJrJr  S SKJ	r	  S SK
JrJr  S SKrS SKrSSKJrJrJrJrJrJrJrJrJr  SSKJrJrJrJrJrJ r   SS	K!J"r"  \" 5       (       a  S SK#r$S SK%r$\$RL                  RN                  r(\" 5       (       aÀ  S S
K)J*r*J+r+  S SK,J-r-  S SK.J/r/  \(R`                  \-Rb                  \(Rd                  \-Rd                  \(Rf                  \-Rf                  \(Rh                  \-Rh                  \(Rj                  \-Rj                  \(Rl                  \-Rl                  0r7\7Rq                  5        V Vs0 s H  u  pX_M	     snn r9O0 r70 r9\" 5       (       a  S SK:r:\Rv                  " \<5      r=\S\R|                  S\?S   \?\R|                     \?S   4   r@ " S S\5      rA " S S\5      rB\C\D\E\D-  \?\C   -  4   rFS rG " S S\5      rHS rIS rJS\?4S jrKS rLS rMS rNS\R|                  S\O4S jrPSXS \ES\?\@   4S! jjrQ SXS\?\@   \@-  S \ES\@4S" jjrR SXS\?\@   \@-  S \ES\?\@   4S# jjrSS\R|                  4S$ jrT SYS\R|                  S%\E\U\ES&4   -  S-  S\A4S' jjrVSYS\R|                  S(\A\D-  S-  S\E4S) jjrW SYS\\R|                  S4   S*\AS-  S\U\E\E4   4S+ jjrXS,\U\E\E4   S-\ES.\ES\U\E\E4   4S/ jrYS0\\   S\?\   4S1 jrZ\AR¶                  4S\?\S\R|                  4      S(\D\A-  S\?\E   4S2 jjr\S3\C\D\?\U-  4   S\O4S4 jr]S3\C\D\?\U-  4   S\O4S5 jr^S6\\C\D\?\U-  4      S\O4S7 jr_S6\\C\D\?\U-  4      S\O4S8 jr` SYS\\DS4   S9\aS-  SS4S: jjrb\"" S;S<9 SYS\\DS4   S9\aS-  SS4S= jj5       rc SYS\\?\U\DS4   S9\aS-  S\S\?S   \?\?S      4   4S> jjrd            SZS?\OS-  S@\aS-  SA\OS-  SB\a\?\a   -  S-  SC\a\?\a   -  S-  SD\OS-  SE\C\D\E4   \E-  S-  SF\OS-  SG\C\D\E4   S-  SH\OS-  SI\C\D\E4   S-  SJ\SKSL\E4   S-  4SM jjre " SN SO5      rfSP\BSQ\U\BS&4   S6\?\C   SS4SR jrgSS\?\D   ST\?\D   4SU jrh\" 5        " SV SW5      5       rigs  snn f )[é    N)ÚIterable)ÚastupleÚ	dataclassÚfields)ÚBytesIO)ÚAnyÚUnioné   )	ÚExplicitEnumÚis_numpy_arrayÚis_torch_availableÚis_torch_tensorÚis_torchvision_availableÚis_vision_availableÚloggingÚrequires_backendsÚto_numpy)ÚIMAGENET_DEFAULT_MEANÚIMAGENET_DEFAULT_STDÚIMAGENET_STANDARD_MEANÚIMAGENET_STANDARD_STDÚOPENAI_CLIP_MEANÚOPENAI_CLIP_STD)Úrequires)ÚImageReadModeÚdecode_image)ÚInterpolationMode)Úpil_to_tensorzPIL.Image.Imageztorch.Tensorc                   ó   • \ rS rSrSrSrSrg)ÚChannelDimensionéU   Úchannels_firstÚchannels_last© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__ÚFIRSTÚLASTÚ__static_attributes__r$   ó    Ú¦C:\Users\johnn\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\transformers/image_utils.pyr    r    U   s   † Ø€EØƒDr,   r    c                   ó   • \ rS rSrSrSrSrg)ÚAnnotationFormatéZ   Úcoco_detectionÚcoco_panopticr$   N)r%   r&   r'   r(   ÚCOCO_DETECTIONÚCOCO_PANOPTICr+   r$   r,   r-   r/   r/   Z   s   † Ø%€NØ#ƒMr,   r/   c                 ól   • [        5       =(       a$    [        U [        R                  R                  5      $ ©N)r   Ú
isinstanceÚPILÚImage©Úimgs    r-   Úis_pil_imager<   b   s   € ÜÓ ×E¤Z°´S·Y±Y·_±_Ó%EÐEr,   c                   ó    • \ rS rSrSrSrSrSrg)Ú	ImageTypeéf   ÚpillowÚtorchÚnumpyr$   N)r%   r&   r'   r(   r8   ÚTORCHÚNUMPYr+   r$   r,   r-   r>   r>   f   s   † Ø
€CØ€EØƒEr,   r>   c                 óð   • [        U 5      (       a  [        R                  $ [        U 5      (       a  [        R                  $ [        U 5      (       a  [        R                  $ [        S[        U 5       35      e)NzUnrecognized image type )	r<   r>   r8   r   rC   r   rD   Ú
ValueErrorÚtype©Úimages    r-   Úget_image_typerJ   l   sX   € Ü�E×ÑÜ�}‰}ÐÜ�u×ÑÜ�‰ÐÜ�e×ÑÜ�‰ÐÜ
Ð/´°U³¨}Ð=Ó
>Ð>r,   c                 ó`   • [        U 5      =(       d    [        U 5      =(       d    [        U 5      $ r6   )r<   r   r   r:   s    r-   Úis_valid_imagerL   v   s!   € Ü˜Ó×K¤¨sÓ 3×K´ÀsÓ7KÐKr,   Úimagesc                 ó8   • U =(       a    [        S U  5       5      $ )Nc              3   ó8   #   • U  H  n[        U5      v •  M     g 7fr6   )rL   )Ú.0rI   s     r-   Ú	<genexpr>Ú*is_valid_list_of_images.<locals>.<genexpr>{   s   é € ÐDºV°Eœ.¨×/Ð/ºVùó   ‚©Úall)rM   s    r-   Úis_valid_list_of_imagesrV   z   s   € Ø×D”cÑD¹VÓDÓDÐDr,   c                 óV  • [        U S   [        5      (       a  U  VVs/ s H  o  H  o"PM     M     snn$ [        U S   [        R                  5      (       a  [        R                  " U SS9$ [        U S   [
        R                  5      (       a  [
        R                  " U SS9$ g s  snnf )Nr   ©Úaxis)Údim)r7   ÚlistÚnpÚndarrayÚconcatenaterA   ÚTensorÚcat)Ú
input_listÚsublistÚitems      r-   Úconcatenate_listrd   ~   s‡   € Ü�*˜Q‘-¤×&Ñ&Ù$.ÔC¢J˜»7°4’¹7‘¡JÒCÐCÜ	�J˜q‘M¤2§:¡:×	.Ñ	.Ü�~Š~˜j¨qÑ1Ð1Ü	�J˜q‘M¤5§<¡<×	0Ñ	0Ü�yŠy˜¨Ñ+Ð+ð 
1ùó Ds   žB%c                 ó”   • [        U [        [        45      (       a  U  H  n[        U5      (       a  M    g   g[	        U 5      (       d  gg)NFT)r7   r[   ÚtupleÚvalid_imagesrL   )Úimgsr;   s     r-   rg   rg   ‡   sC   € ä�$œœu˜×&Ñ&ÛˆCÜ ×$Ó$Ùñ ð ô ˜D×!Ñ!ØØr,   c                 óV   • [        U [        [        45      (       a  [        U S   5      $ g)Nr   F)r7   r[   rf   rL   r:   s    r-   Ú
is_batchedrj   “   s%   € Ü�#œœe�}×%Ñ%Ü˜c !™fÓ%Ð%Ør,   rI   Úreturnc                 ó²   • U R                   [        R                  :X  a  g[        R                  " U 5      S:¬  =(       a    [        R                  " U 5      S:*  $ )zN
Checks to see whether the pixel values have already been rescaled to [0, 1].
Fr   r
   )Údtyper\   Úuint8ÚminÚmaxrH   s    r-   Úis_scaled_imagerq   ™   s>   € ð ‡{�{”b—h‘hÓØô �6Š6�%‹=˜AÑ×4¤"§&¢&¨£-°1Ñ"4Ð4r,   Úexpected_ndimsc           	      óJ  • [        U 5      (       a  U $ [        U 5      (       a  U /$ [        U 5      (       aW  U R                  US-   :X  a  [	        U 5      n U $ U R                  U:X  a  U /n U $ [        SUS-    SU SU R                   S35      e[        S[        U 5       S35      e)aê  
Ensure that the output is a list of images. If the input is a single image, it is converted to a list of length 1.
If the input is a batch of images, it is converted to a list of images.

Args:
    images (`ImageInput`):
        Image or batch of images to turn into a list of images.
    expected_ndims (`int`, *optional*, defaults to 3):
        Expected number of dimensions for a single input image. If the input image has a different number of
        dimensions, an error is raised.
r
   z%Invalid image shape. Expected either z or z dimensions, but got z dimensions.z]Invalid image type. Expected either PIL.Image.Image, numpy.ndarray, or torch.Tensor, but got Ú.)rj   r<   rL   Úndimr[   rF   rG   )rM   rr   s     r-   Úmake_list_of_imagesrv   ¤   sÎ   € ô �&×ÑØˆô �F×Ñàˆxˆä�f×ÑØ�;‰;˜.¨1Ñ,Ó,ä˜&“\ˆFð ˆð �[‰[˜NÓ*à�XˆFð ˆô	 Ø7¸ÈÑ8JÐ7KÈ4ÐP^ÐO_ð `Ø—K‘K�= ð.óð ô
 Ø
gÔhlÐmsÓhtÐguÐuvÐwóð r,   c                 ó°  • [        U [        [        45      (       aK  [        S U  5       5      (       a4  [        S U  5       5      (       a  U  VVs/ s H  o"  H  o3PM     M     snn$ [        U [        [        45      (       ak  [	        U 5      (       a[  [        U S   5      (       d  U S   R                  U:X  a  U $ U S   R                  US-   :X  a  U  VVs/ s H  o"  H  o3PM     M     snn$ [        U 5      (       aA  [        U 5      (       d  U R                  U:X  a  U /$ U R                  US-   :X  a  [        U 5      $ [        SU  35      es  snnf s  snnf )a×  
Ensure that the output is a flat list of images. If the input is a single image, it is converted to a list of length 1.
If the input is a nested list of images, it is converted to a flat list of images.
Args:
    images (`Union[list[ImageInput], ImageInput]`):
        The input image.
    expected_ndims (`int`, *optional*, defaults to 3):
        The expected number of dimensions for a single input image.
Returns:
    list: A list of images or a 4d array of images.
c              3   óN   #   • U  H  n[        U[        [        45      v •  M     g 7fr6   ©r7   r[   rf   ©rP   Úimages_is     r-   rQ   Ú+make_flat_list_of_images.<locals>.<genexpr>Ü   ó   é € ÐKÂF¸”
˜8¤d¬E ]×3Ð3ÂFùó   ‚#%c              3   óT   #   • U  H  n[        U5      =(       d    U(       + v •  M      g 7fr6   ©rV   rz   s     r-   rQ   r|   Ý   ó"   é € ÐYÒRXÀhÔ'¨Ó1×A¸´\ÔAÒRXùó   ‚&(r   r
   z*Could not make a flat list of images from ©	r7   r[   rf   rU   rV   r<   ru   rL   rF   )rM   rr   Úimg_listr;   s       r-   Úmake_flat_list_of_imagesr…   Ê   s(  € ô" 	�6œD¤%˜=×)Ñ)ÜÑKÁFÓK×KÑKÜÑYÑRXÓY×YÑYá$*Ô?¢F˜³h¨s’±h‘¡FÒ?Ð?ä�&œ4¤˜-×(Ñ(Ô-DÀV×-LÑ-LÜ˜˜q™	×"Ñ" f¨Q¡i§n¡n¸Ó&FØˆMØ�!‰9�>‰>˜^¨aÑ/Ó/Ù(.ÔCª˜H»(°3’C¹(‘C©ÒCÐCä�f×ÑÜ˜×Ñ 6§;¡;°.Ó#@Ø�8ˆOØ�;‰;˜.¨1Ñ,Ó,Ü˜“<Ðä
ÐAÀ&ÀÐJÓ
KÐKùó @ùó Ds   ÁEÃEc                 ój  • [        U [        [        45      (       a0  [        S U  5       5      (       a  [        S U  5       5      (       a  U $ [        U [        [        45      (       ak  [	        U 5      (       a[  [        U S   5      (       d  U S   R                  U:X  a  U /$ U S   R                  US-   :X  a  U  Vs/ s H  n[        U5      PM     sn$ [        U 5      (       aC  [        U 5      (       d  U R                  U:X  a  U //$ U R                  US-   :X  a  [        U 5      /$ [        S5      es  snf )aO  
Ensure that the output is a nested list of images.
Args:
    images (`Union[list[ImageInput], ImageInput]`):
        The input image.
    expected_ndims (`int`, *optional*, defaults to 3):
        The expected number of dimensions for a single input image.
Returns:
    list: A list of list of images or a list of 4d array of images.
c              3   óN   #   • U  H  n[        U[        [        45      v •  M     g 7fr6   ry   rz   s     r-   rQ   Ú-make_nested_list_of_images.<locals>.<genexpr>  r}   r~   c              3   óT   #   • U  H  n[        U5      =(       d    U(       + v •  M      g 7fr6   r€   rz   s     r-   rQ   rˆ     r�   r‚   r   r
   z]Invalid input type. Must be a single image, a list of images, or a list of batches of images.rƒ   )rM   rr   rI   s      r-   Úmake_nested_list_of_imagesrŠ   ð   s	  € ô  	�6œD¤%˜=×)Ñ)ÜÑKÁFÓK×KÑKÜÑYÑRXÓY×YÑYàˆô �&œ4¤˜-×(Ñ(Ô-DÀV×-LÑ-LÜ˜˜q™	×"Ñ" f¨Q¡i§n¡n¸Ó&FØ�8ˆOØ�!‰9�>‰>˜^¨aÑ/Ó/Ù-3Ó4ªV E”D˜–K©VÑ4Ð4ô �f×ÑÜ˜×Ñ 6§;¡;°.Ó#@Ø�H�:ÐØ�;‰;˜.¨1Ñ,Ó,Ü˜“L�>Ð!ä
ÐtÓ
uÐuùò 5s   Â:D0c                 ó  • [        U 5      (       d  [        S[        U 5       35      e[        5       (       a?  [	        U [
        R                  R                  5      (       a  [        R                  " U 5      $ [        U 5      $ )NzInvalid image type: )
rL   rF   rG   r   r7   r8   r9   r\   Úarrayr   r:   s    r-   Úto_numpy_arrayr�     sY   € Ü˜#×ÑÜÐ/´°S³	¨{Ð;Ó<Ð<ä×Ñ¤¨C´·±·±×!AÑ!AÜ�xŠx˜‹}ÐÜ�C‹=Ðr,   Únum_channels.c                 óF  • Ub  UOSn[        U[        5      (       a  U4OUnU R                  S:X  a  Su  p#OBU R                  S:X  a  Su  p#O-U R                  S:X  a  Su  p#O[        SU R                   35      eU R                  U   U;   aF  U R                  U   U;   a3  [
        R                  SU R                   S	35        [        R                  $ U R                  U   U;   a  [        R                  $ U R                  U   U;   a  [        R                  $ [        S
5      e)a7  
Infers the channel dimension format of `image`.

Args:
    image (`np.ndarray`):
        The image to infer the channel dimension of.
    num_channels (`int` or `tuple[int, ...]`, *optional*, defaults to `(1, 3)`):
        The number of channels of the image.

Returns:
    The channel dimension of the image.
©r
   é   r‘   )r   é   é   é   )r’   r“   z(Unsupported number of image dimensions: z4The channel dimension is ambiguous. Got image shape zú. Assuming channels are the first dimension. Use the [input_data_format](https://huggingface.co/docs/transformers/main/internal/image_processing_utils#transformers.image_transforms.rescale.input_data_format) parameter to assign the channel dimension.z(Unable to infer channel dimension format)
r7   Úintru   rF   ÚshapeÚloggerÚwarningr    r)   r*   )rI   rŽ   Ú	first_dimÚlast_dims       r-   Úinfer_channel_dimension_formatr›      s  € ð $0Ñ#;‘<À€LÜ&0°¼s×&CÑ&C�L‘?È€Là‡z�z�QƒØ"Ñˆ	�8Ø	�‰�q‹Ø"Ñˆ	�8Ø	�‰�q‹Ø"Ñˆ	�8äÐCÀEÇJÁJÀ<ÐPÓQÐQà‡{�{�9Ñ Ó-°%·+±+¸hÑ2GÈ<Ó2WÜ�‰ØBÀ5Ç;Á;À-ð  PJð  Kô	
ô  ×%Ñ%Ð%Ø	�‰�YÑ	 <Ó	/Ü×%Ñ%Ð%Ø	�‰�XÑ	 ,Ó	.Ü×$Ñ$Ð$Ü
Ð?Ó
@Ð@r,   Úinput_data_formatc                 óÆ   • Uc  [        U 5      nU[        R                  :X  a  U R                  S-
  $ U[        R                  :X  a  U R                  S-
  $ [        SU 35      e)ar  
Returns the channel dimension axis of the image.

Args:
    image (`np.ndarray`):
        The image to get the channel dimension axis of.
    input_data_format (`ChannelDimension` or `str`, *optional*):
        The channel dimension format of the image. If `None`, will infer the channel dimension from the image.

Returns:
    The channel dimension axis of the image.
r‘   r
   úUnsupported data format: )r›   r    r)   ru   r*   rF   )rI   rœ   s     r-   Úget_channel_dimension_axisrŸ   G  sd   € ð Ñ Ü:¸5ÓAÐØÔ,×2Ñ2Ó2Ø�z‰z˜A‰~ÐØ	Ô.×3Ñ3Ó	3Ø�z‰z˜A‰~ÐÜ
Ð0Ð1BÐ0CÐDÓ
EÐEr,   Úchannel_dimc                 ól  • [        U [        R                  R                  5      (       a  U R                  $ Uc  [	        U 5      nU[
        R                  :X  a  U R                  S   U R                  S   4$ U[
        R                  :X  a  U R                  S   U R                  S   4$ [        SU 35      e)ao  
Returns the (height, width) dimensions of the image.

Args:
    image (`np.ndarray | PIL.Image.Image`):
        The image to get the dimensions of.
    channel_dim (`ChannelDimension`, *optional*):
        Which dimension the channel dimension is in. If `None`, will infer the channel dimension from the image.

Returns:
    A tuple of the image's height and width.
éþÿÿÿéÿÿÿÿéýÿÿÿrž   )
r7   r8   r9   Úsizer›   r    r)   r–   r*   rF   )rI   r    s     r-   Úget_image_sizer¦   ]  sš   € ô �%œŸ™Ÿ™×)Ñ)Ø�z‰zÐàÑÜ4°UÓ;ˆàÔ&×,Ñ,Ó,Ø�{‰{˜2‰ §¡¨B¡Ð/Ð/Ø	Ô(×-Ñ-Ó	-Ø�{‰{˜2‰ §¡¨B¡Ð/Ð/äÐ4°[°MÐBÓCÐCr,   Ú
image_sizeÚ
max_heightÚ	max_widthc                 ój   • U u  p4X-  nX$-  n[        XV5      n[        X7-  5      n[        XG-  5      n	X‰4$ )a“  
Computes the output image size given the input image and the maximum allowed height and width. Keep aspect ratio.
Important, even if image_height < max_height and image_width < max_width, the image will be resized
to at least one of the edges be equal to max_height or max_width.

For example:
    - input_size: (100, 200), max_height: 50, max_width: 50 -> output_size: (25, 50)
    - input_size: (100, 200), max_height: 200, max_width: 500 -> output_size: (200, 400)

Args:
    image_size (`tuple[int, int]`):
        The image to resize.
    max_height (`int`):
        The maximum allowed height.
    max_width (`int`):
        The maximum allowed width.
)ro   r•   )
r§   r¨   r©   ÚheightÚwidthÚheight_scaleÚwidth_scaleÚ	min_scaleÚ
new_heightÚ	new_widths
             r-   Ú#get_image_size_for_max_height_widthr²   z  sH   € ð, �M€FØÑ&€LØÑ#€KÜ�LÓ.€IÜ�VÑ'Ó(€JÜ�EÑ%Ó&€IØÐ Ð r,   Úvaluesc                 óP   • [        U 6  Vs/ s H  n[        U5      PM     sn$ s  snf )zG
Return the maximum value across all indices of an iterable of values.
)Úziprp   )r³   Úvalues_is     r-   Úmax_across_indicesr·   ™  s$   € ô +.¨v©,Ó7ª,˜hŒC�ŽM©,Ñ7Ð7ùÒ7s   ‹#c                 ó.  • U[         R                  :X  a+  [        U  Vs/ s H  o"R                  PM     sn5      u  p4nXE4$ U[         R                  :X  a+  [        U  Vs/ s H  o"R                  PM     sn5      u  pEnXE4$ [        SU 35      es  snf s  snf )z@
Get the maximum height and width across all images in a batch.
z"Invalid channel dimension format: )r    r)   r·   r–   r*   rF   )rM   rœ   r;   Ú_r¨   r©   s         r-   Úget_max_height_widthrº      sš   € ð Ô,×2Ñ2Ó2Ü#5ÉFÓ6SÊFÀS·y´yÉFÑ6SÓ#TÑ ˆ�yð
 Ð"Ð"ð	 
Ô.×3Ñ3Ó	3Ü#5ÉFÓ6SÊFÀS·y´yÉFÑ6SÓ#TÑ ˆ
˜qð Ð"Ð"ô Ð=Ð>OÐ=PÐQÓRÐRùò	 7Tùâ6Ss   žBÁBÚ
annotationc                 óÞ   • [        U [        5      (       aX  SU ;   aR  SU ;   aL  [        U S   [        [        45      (       a.  [	        U S   5      S:X  d  [        U S   S   [        5      (       a  gg)NÚimage_idÚannotationsr   TF©r7   Údictr[   rf   Úlen©r»   s    r-   Ú"is_valid_annotation_coco_detectionrÃ   ¯  si   € ä�:œt×$Ñ$Ø˜*Ó$Ø˜ZÓ'Ü�z -Ñ0´4¼°-×@Ñ@ô �
˜=Ñ)Ó*¨aÓ/´:¸jÈÑ>WÐXYÑ>ZÔ\`×3aÑ3að Ør,   c                 óê   • [        U [        5      (       a^  SU ;   aX  SU ;   aR  SU ;   aL  [        U S   [        [        45      (       a.  [	        U S   5      S:X  d  [        U S   S   [        5      (       a  gg)Nr½   Úsegments_infoÚ	file_namer   TFr¿   rÂ   s    r-   Ú!is_valid_annotation_coco_panopticrÇ   ¾  sq   € ä�:œt×$Ñ$Ø˜*Ó$Ø˜zÓ)Ø˜:Ó%Ü�z /Ñ2´T¼5°M×BÑBô �
˜?Ñ+Ó,°Ó1´ZÀ
È?Ñ@[Ð\]Ñ@^Ô`d×5eÑ5eð Ør,   r¾   c                 ó&   • [        S U  5       5      $ )Nc              3   ó8   #   • U  H  n[        U5      v •  M     g 7fr6   )rÃ   ©rP   Úanns     r-   rQ   Ú3valid_coco_detection_annotations.<locals>.<genexpr>Ï  s   é € ÐNÂ+¸3Ô1°#×6Ð6Â+ùrS   rT   ©r¾   s    r-   Ú valid_coco_detection_annotationsrÎ   Î  s   € ÜÑNÁ+ÓNÓNÐNr,   c                 ó&   • [        S U  5       5      $ )Nc              3   ó8   #   • U  H  n[        U5      v •  M     g 7fr6   )rÇ   rÊ   s     r-   rQ   Ú2valid_coco_panoptic_annotations.<locals>.<genexpr>Ó  s   é € ÐMÂ¸#Ô0°×5Ð5ÂùrS   rT   rÍ   s    r-   Úvalid_coco_panoptic_annotationsrÒ   Ò  s   € ÜÑMÁÓMÓMÐMr,   Útimeoutc           
      ó¾  • [        [        S/5        [        U [        5      (       Ga.  U R	                  S5      (       d  U R	                  S5      (       aF  [
        R                  R                  [        [        R                  " XSS9R                  5      5      n Oð[        R                  R                  U 5      (       a   [
        R                  R                  U 5      n O¬U R	                  S5      (       a  U R                  S5      S   n  [         R"                  " U R%                  5       5      n[
        R                  R                  [        U5      5      n O4[        U [
        R                  R                  5      (       d  [+        S5      e[
        R,                  R/                  U 5      n U R1                  S5      n U $ ! [&         a  n[)        S	U  S
U 35      eSnAff = f)a  
Loads `image` to a PIL Image.

Args:
    image (`str` or `PIL.Image.Image`):
        The image to convert to the PIL Image format.
    timeout (`float`, *optional*):
        The timeout value in seconds for the URL request.

Returns:
    `PIL.Image.Image`: A PIL Image.
Úvisionúhttp://úhttps://T©rÓ   Úfollow_redirectsúdata:image/Ú,r
   ú’Incorrect image source. Must be a valid URL starting with `http://` or `https://`, a valid path to an image file, or a base64 encoded string. Got ú. Failed with NzuIncorrect format used for image. Should be an url linking to an image, a base64 string, a local path, or a PIL image.ÚRGB)r   Ú
load_imager7   ÚstrÚ
startswithr8   r9   Úopenr   ÚhttpxÚgetÚcontentÚosÚpathÚisfileÚsplitÚbase64ÚdecodebytesÚencodeÚ	ExceptionrF   Ú	TypeErrorÚImageOpsÚexif_transposeÚconvert)rI   rÓ   Úb64Úes       r-   rß   rß   Ö  s„  € ô  ”j 8 *Ô-Ü�%œ×ÒØ×Ñ˜I×&Ñ&¨%×*:Ñ*:¸:×*FÑ*Fô —I‘I—N‘N¤7¬5¯9ª9°UÐ^bÑ+c×+kÑ+kÓ#lÓm‰EÜ�W‰W�^‰^˜E×"Ñ"Ü—I‘I—N‘N 5Ó)‰Eà×Ñ ×.Ñ.ØŸ™ CÓ(¨Ñ+�ðÜ×(Ò(¨¯©«Ó8�ÜŸ	™	Ÿ™¤w¨s£|Ó4‘ô
 ˜œsŸy™yŸ™×/Ñ/Üð Dó
ð 	
ô �L‰L×'Ñ'¨Ó.€EØ�M‰M˜%Ó €EØ€Løô ó Ü ð ið  joð  ipð  p~ð  @ð  ~Að  Bóð ûðús   Ä	AF< Æ<
GÇGÇG)Útorchvision)Úbackendsc                 óò  • SSK n[        U [        5      (       GaN  U R                  S5      (       d  U R                  S5      (       a[  [        R
                  " XSS9R                  nUR                  " [        U5      UR                  S9n[        U[        R                  S9$ [        R                  R                  U 5      (       a  [        U [        R                  S9$ U R                  S	5      (       a  U R!                  S
5      S   n  ["        R$                  " U R'                  5       5      nUR                  " [        U5      UR                  S9n[        U[        R                  S9$ [        U [,        R.                  R.                  5      (       a9  [,        R0                  R3                  U 5      n [5        U R7                  S5      5      $ [9        S5      e! [(         a  n[+        SU  SU 35      eSnAff = f)aP  
Loads `image` directly to a `torch.Tensor` using torchvision.

Args:
    image (`str` or `PIL.Image.Image`):
        The image to convert to the PIL Image format.
    timeout (`float`, *optional*):
        The timeout value in seconds for the URL request.

Returns:
    `torch.Tensor`: A `[C, H, W]` uint8 tensor in RGB channel order.
r   NrÖ   r×   TrØ   )rm   )ÚmoderÚ   rÛ   r
   rÜ   rÝ   rÞ   z`Incorrect format used for image. Should be a URL, a local path, a base64 string, or a PIL image.)rA   r7   rà   rá   rã   rä   rå   Ú
frombufferÚ	bytearrayrn   r   r   rÞ   ræ   rç   rè   ré   rê   rë   rì   rí   rF   r8   r9   rï   rð   r   rñ   rî   )rI   rÓ   rA   ÚrawÚbufró   s         r-   Úload_image_as_tensorrü     s§  € ó" ä�%œ×ÒØ×Ñ˜I×&Ñ&¨%×*:Ñ*:¸:×*FÑ*FÜ—)’)˜EÀTÑJ×RÑRˆCØ×"Ò"¤9¨S£>¸¿¹ÑEˆCÜ ¬-×*;Ñ*;Ñ<Ð<Ü�W‰W�^‰^˜E×"Ñ"Ü ¬M×,=Ñ,=Ñ>Ð>à×Ñ ×.Ñ.ØŸ™ CÓ(¨Ñ+�ðÜ×(Ò(¨¯©«Ó8�ð
 ×"Ò"¤9¨S£>¸¿¹ÑEˆCÜ ¬-×*;Ñ*;Ñ<Ð<Ü	�Eœ3Ÿ9™9Ÿ?™?×	+Ñ	+Ü—‘×+Ñ+¨EÓ2ˆÜ˜UŸ]™]¨5Ó1Ó2Ð2äØnó
ð 	
øô ó Ü ð ið  joð  ipð  p~ð  @ð  ~Að  Bóð ûðús   Ä	$G Ç
G6Ç G1Ç1G6c                 óR  • [        U [        [        45      (       at  [        U 5      (       aJ  [        U S   [        [        45      (       a,  U  VVs/ s H  o" Vs/ s H  n[	        X1S9PM     snPM     snn$ U  Vs/ s H  n[	        X1S9PM     sn$ [	        XS9$ s  snf s  snnf s  snf )zýLoads images, handling different levels of nesting.

Args:
  images: A single image, a list of images, or a list of lists of images to load.
  timeout: Timeout for loading images.

Returns:
  A single image, a list of images, a list of lists of images.
r   )rÓ   )r7   r[   rf   rÁ   rß   )rM   rÓ   Úimage_grouprI   s       r-   Úload_imagesrÿ   1  s�   € ô �&œ4¤˜-×(Ñ(Üˆv�;‰;œ: f¨Q¡i´$¼°×?Ñ?ÙekÔlÒekÐVaÀ[ÓQÂ[¸E”Z Ô7Á[ÔQÑekÒlÐláDJÓKÂF¸5”J˜uÔ6ÁFÑKÐKä˜&Ñ2Ð2ùò	 RùÓlùâKs   Á	BÁBÁ+BÁ:B$ÂBÚ
do_rescaleÚrescale_factorÚdo_normalizeÚ
image_meanÚ	image_stdÚdo_padÚpad_sizeÚdo_center_cropÚ	crop_sizeÚ	do_resizer¥   ÚresampleÚPILImageResamplingr   c                 óä   • U (       a  Uc  [        S5      eU(       a  Uc  [        S5      eU(       a  Ub  Uc  [        S5      eU(       a  Uc  [        S5      eU	(       a  U
b  Uc  [        S5      egg)ao  
Checks validity of typically used arguments in an `ImageProcessor` `preprocess` method.
Raises `ValueError` if arguments incompatibility is caught.
Many incompatibilities are model-specific. `do_pad` sometimes needs `size_divisor`,
sometimes `size_divisibility`, and sometimes `size`. New models and processors added should follow
existing arguments when possible.

Nz=`rescale_factor` must be specified if `do_rescale` is `True`.zgDepending on the model, `size_divisor` or `pad_size` or `size` must be specified if `do_pad` is `True`.zP`image_mean` and `image_std` must both be specified if `do_normalize` is `True`.z<`crop_size` must be specified if `do_center_crop` is `True`.zA`size` and `resample` must be specified if `do_resize` is `True`.)rF   )r   r  r  r  r  r  r  r  r  r	  r¥   r
  s               r-   Úvalidate_preprocess_argumentsr  F  s‚   € ö, �nÑ,ÜÐXÓYÐYæ�(Ñ"ô Øuó
ð 	
ö ˜Ñ+¨yÑ/@ÜÐkÓlÐlæ˜)Ñ+ÜÐWÓXÐXæ˜$Ñ*¨xÑ/CÜÐ\Ó]Ð]ð 0D€yr,   c                   ó¬   • \ rS rSrSrS rSS jrS rS\R                  S\
\-  S	\R                  4S
 jrSS jrS rSS jrSS jrS rS rSS jrSrg)ÚImageFeatureExtractionMixinit  z<
Mixin that contain utilities for preparing image features.
c                 óÈ   • [        U[        R                  R                  [        R                  45      (       d)  [        U5      (       d  [        S[        U5       S35      eg g )Nz	Got type zU which is not supported, only `PIL.Image.Image`, `np.ndarray` and `torch.Tensor` are.)r7   r8   r9   r\   r]   r   rF   rG   ©ÚselfrI   s     r-   Ú_ensure_format_supportedÚ4ImageFeatureExtractionMixin._ensure_format_supportedy  sW   € Ü˜%¤#§)¡)§/¡/´2·:±:Ð!>×?Ñ?ÌÐX]×H^ÑH^ÜØœD ›K˜=ð )&ð &óð ð I_Ð?r,   Nc                 óú  • U R                  U5        [        U5      (       a  UR                  5       n[        U[        R
                  5      (       aª  Uc'  [        UR                  S   [        R                  5      nUR                  S:X  a&  UR                  S   S;   a  UR                  SSS5      nU(       a  US-  nUR                  [        R                  5      n[        R                  R                  U5      $ U$ )aÚ  
Converts `image` to a PIL Image. Optionally rescales it and puts the channel dimension back as the last axis if
needed.

Args:
    image (`PIL.Image.Image` or `numpy.ndarray` or `torch.Tensor`):
        The image to convert to the PIL Image format.
    rescale (`bool`, *optional*):
        Whether or not to apply the scaling factor (to make pixel values integers between 0 and 255). Will
        default to `True` if the image type is a floating type, `False` otherwise.
r   r‘   r�   r
   r’   éÿ   )r  r   rB   r7   r\   r]   ÚflatÚfloatingru   r–   Ú	transposeÚastypern   r8   r9   Ú	fromarray)r  rI   Úrescales      r-   Úto_pil_imageÚ(ImageFeatureExtractionMixin.to_pil_image€  sº   € ð 	×%Ñ% eÔ,ä˜5×!Ñ!Ø—K‘K“MˆEä�eœRŸZ™Z×(Ñ(Ø‰ä$ U§Z¡Z°¡]´B·K±KÓ@�à�z‰z˜Q‹ 5§;¡;¨q¡>°VÓ#;ØŸ™¨¨1¨aÓ0�ÞØ ™�Ø—L‘L¤§¡Ó*ˆEÜ—9‘9×&Ñ& uÓ-Ð-Øˆr,   c                 óœ   • U R                  U5        [        U[        R                  R                  5      (       d  U$ UR	                  S5      $ )zo
Converts `PIL.Image.Image` to RGB format.

Args:
    image (`PIL.Image.Image`):
        The image to convert.
rÞ   )r  r7   r8   r9   rñ   r  s     r-   Úconvert_rgbÚ'ImageFeatureExtractionMixin.convert_rgbž  s;   € ð 	×%Ñ% eÔ,Ü˜%¤§¡§¡×1Ñ1ØˆLà�}‰}˜UÓ#Ð#r,   rI   Úscalerk   c                 ó,   • U R                  U5        X-  $ )z'
Rescale a numpy image by scale amount
)r  )r  rI   r"  s      r-   r  Ú#ImageFeatureExtractionMixin.rescale¬  s   € ð 	×%Ñ% eÔ,Ø‰}Ðr,   c                 óþ  • U R                  U5        [        U[        R                  R                  5      (       a  [        R
                  " U5      n[        U5      (       a  UR                  5       nUc'  [        UR                  S   [        R                  5      OUnU(       a/  U R                  UR                  [        R                  5      S5      nU(       a#  UR                  S:X  a  UR                  SSS5      nU$ )a{  
Converts `image` to a numpy array. Optionally rescales it and puts the channel dimension as the first
dimension.

Args:
    image (`PIL.Image.Image` or `np.ndarray` or `torch.Tensor`):
        The image to convert to a NumPy array.
    rescale (`bool`, *optional*):
        Whether or not to apply the scaling factor (to make pixel values floats between 0. and 1.). Will
        default to `True` if the image is a PIL Image or an array/tensor of integers, `False` otherwise.
    channel_first (`bool`, *optional*, defaults to `True`):
        Whether or not to permute the dimensions of the image to put the channel dimension first.
r   çp?r‘   r’   r
   )r  r7   r8   r9   r\   rŒ   r   rB   r  Úintegerr  r  Úfloat32ru   r  )r  rI   r  Úchannel_firsts       r-   r�   Ú*ImageFeatureExtractionMixin.to_numpy_array³  s­   € ð 	×%Ñ% eÔ,ä�eœSŸY™YŸ_™_×-Ñ-Ü—H’H˜U“OˆEä˜5×!Ñ!Ø—K‘K“MˆEà;B¹?”*˜UŸZ™Z¨™]¬B¯J©JÔ7ÐPWˆæØ—L‘L §¡¬b¯j©jÓ!9¸9ÓEˆEæ˜UŸZ™Z¨1›_Ø—O‘O A q¨!Ó,ˆEàˆr,   c                 óî   • U R                  U5        [        U[        R                  R                  5      (       a  U$ [	        U5      (       a  UR                  S5      nU$ [        R                  " USS9nU$ )z•
Expands 2-dimensional `image` to 3 dimensions.

Args:
    image (`PIL.Image.Image` or `np.ndarray` or `torch.Tensor`):
        The image to expand.
r   rX   )r  r7   r8   r9   r   Ú	unsqueezer\   Úexpand_dimsr  s     r-   r-  Ú'ImageFeatureExtractionMixin.expand_dimsÓ  se   € ð 	×%Ñ% eÔ,ô �eœSŸY™YŸ_™_×-Ñ-ØˆLä˜5×!Ñ!Ø—O‘O AÓ&ˆEð ˆô —N’N 5¨qÑ1ˆEØˆr,   c                 ó>  • U R                  U5        [        U[        R                  R                  5      (       a  U R	                  USS9nO†U(       a  [        U[
        R                  5      (       a0  U R                  UR                  [
        R                  5      S5      nO0[        U5      (       a   U R                  UR                  5       S5      n[        U[
        R                  5      (       a�  [        U[
        R                  5      (       d/  [
        R                  " U5      R                  UR                  5      n[        U[
        R                  5      (       d/  [
        R                  " U5      R                  UR                  5      nOÐ[        U5      (       aÀ  SSKn[        X%R                  5      (       dD  [        U[
        R                  5      (       a  UR                   " U5      nOUR"                  " U5      n[        X5R                  5      (       dD  [        U[
        R                  5      (       a  UR                   " U5      nOUR"                  " U5      nUR$                  S:X  a*  UR&                  S   S;   a  XSS2SS4   -
  USS2SS4   -  $ X-
  U-  $ )a¥  
Normalizes `image` with `mean` and `std`. Note that this will trigger a conversion of `image` to a NumPy array
if it's a PIL Image.

Args:
    image (`PIL.Image.Image` or `np.ndarray` or `torch.Tensor`):
        The image to normalize.
    mean (`list[float]` or `np.ndarray` or `torch.Tensor`):
        The mean (per channel) to use for normalization.
    std (`list[float]` or `np.ndarray` or `torch.Tensor`):
        The standard deviation (per channel) to use for normalization.
    rescale (`bool`, *optional*, defaults to `False`):
        Whether or not to rescale the image to be between 0 and 1. If a PIL image is provided, scaling will
        happen automatically.
T)r  r&  r   Nr‘   r�   )r  r7   r8   r9   r�   r\   r]   r  r  r(  r   ÚfloatrŒ   rm   rA   r_   Ú
from_numpyÚtensorru   r–   )r  rI   ÚmeanÚstdr  rA   s         r-   Ú	normalizeÚ%ImageFeatureExtractionMixin.normalizeç  sÑ  € ð  	×%Ñ% eÔ,ä�eœSŸY™YŸ_™_×-Ñ-Ø×'Ñ'¨°tÐ'Ð<‰Eö Ü˜%¤§¡×,Ñ,ØŸ™ U§\¡\´"·*±*Ó%=¸yÓI‘Ü  ×'Ñ'ØŸ™ U§[¡[£]°IÓ>�ä�eœRŸZ™Z×(Ñ(Ü˜d¤B§J¡J×/Ñ/Ü—x’x “~×,Ñ,¨U¯[©[Ó9�Ü˜c¤2§:¡:×.Ñ.Ü—h’h˜s“m×*Ñ*¨5¯;©;Ó7�øÜ˜U×#Ñ#Ûä˜d§L¡L×1Ñ1Ü˜d¤B§J¡J×/Ñ/Ø ×+Ò+¨DÓ1‘Dà Ÿ<š<¨Ó-�DÜ˜c§<¡<×0Ñ0Ü˜c¤2§:¡:×.Ñ.Ø×*Ò*¨3Ó/‘CàŸ,š, sÓ+�Cà�:‰:˜‹?˜uŸ{™{¨1™~°Ó7Ø¢ D¨$ Ñ/Ñ/°3²q¸$À°}Ñ3EÑEÐEà‘L CÑ'Ð'r,   c                 óÎ  • Ub  UO[         R                  nU R                  U5        [        U[        R
                  R
                  5      (       d  U R                  U5      n[        U[        5      (       a  [        U5      n[        U[        5      (       d  [        U5      S:X  a³  U(       a#  [        U[        5      (       a  X"4O	US   US   4nO‰UR                  u  pgXg::  a  Xg4OXv4u  p‰[        U[        5      (       a  UOUS   n
XŠ:X  a  U$ U
[        X©-  U-  5      pËUb,  XZ::  a  [        SU SU 35      eXÅ:”  a  [        X[-  U-  5      UpËXg::  a  X¼4OXË4nUR                  X#S9$ )aÓ  
Resizes `image`. Enforces conversion of input to PIL.Image.

Args:
    image (`PIL.Image.Image` or `np.ndarray` or `torch.Tensor`):
        The image to resize.
    size (`int` or `tuple[int, int]`):
        The size to use for resizing the image. If `size` is a sequence like (h, w), output size will be
        matched to this.

        If `size` is an int and `default_to_square` is `True`, then image will be resized to (size, size). If
        `size` is an int and `default_to_square` is `False`, then smaller edge of the image will be matched to
        this number. i.e, if height > width, then image will be rescaled to (size * height / width, size).
    resample (`int`, *optional*, defaults to `PILImageResampling.BILINEAR`):
        The filter to user for resampling.
    default_to_square (`bool`, *optional*, defaults to `True`):
        How to convert `size` when it is a single int. If set to `True`, the `size` will be converted to a
        square (`size`,`size`). If set to `False`, will replicate
        [`torchvision.transforms.Resize`](https://pytorch.org/vision/stable/transforms.html#torchvision.transforms.Resize)
        with support for resizing only the smallest edge and providing an optional `max_size`.
    max_size (`int`, *optional*, defaults to `None`):
        The maximum allowed for the longer edge of the resized image: if the longer edge of the image is
        greater than `max_size` after being resized according to `size`, then the image is resized again so
        that the longer edge is equal to `max_size`. As a result, `size` might be overruled, i.e the smaller
        edge may be shorter than `size`. Only used if `default_to_square` is `False`.

Returns:
    image: A resized `PIL.Image.Image`.
r
   r   zmax_size = zN must be strictly greater than the requested size for the smaller edge size = )r
  )r  ÚBILINEARr  r7   r8   r9   r  r[   rf   r•   rÁ   r¥   rF   Úresize)r  rI   r¥   r
  Údefault_to_squareÚmax_sizer¬   r«   ÚshortÚlongÚrequested_new_shortÚ	new_shortÚnew_longs                r-   r9  Ú"ImageFeatureExtractionMixin.resize  sb  € ð<  (Ñ3‘8Ô9K×9TÑ9Tˆà×%Ñ% eÔ,ä˜%¤§¡§¡×1Ñ1Ø×%Ñ% eÓ,ˆEä�dœD×!Ñ!Ü˜“;ˆDä�dœC× Ñ ¤C¨£I°£NÞ Ü'1°$¼×'<Ñ'<˜‘|À4ÈÁ7ÈDÐQRÉGÐBT‘à %§
¡
‘�à16³˜u™oÀvÀo‘�Ü.8¸¼s×.CÑ.C¡dÈÈaÉÐ#àÓ/Ø �Là&9¼3Ð?RÑ?YÐ\aÑ?aÓ;b˜8àÑ'ØÓ6Ü(Ø)¨(¨ð 4@Ø@D¸vðGóð ð  Ó*Ü.1°(Ñ2FÈÑ2QÓ.RÐT\ 8à05³˜	Ñ,ÀhÐEZ�à�|‰|˜Dˆ|Ð4Ð4r,   c                 óÂ  • U R                  U5        [        U[        5      (       d  X"4n[        U5      (       d  [        U[        R
                  5      (       aS  UR                  S:X  a  U R                  U5      nUR                  S   S;   a  UR                  SS OUR                  SS nOUR                  S   UR                  S   4nUS   US   -
  S-  nXBS   -   nUS   US   -
  S-  nXbS   -   n[        U[        R                  R                  5      (       a  UR                  XdXu45      $ UR                  S   S;   nU(       dU  [        U[        R
                  5      (       a  UR                  SSS5      n[        U5      (       a  UR                  SSS5      nUS:¼  a   XSS   ::  a  US:¼  a  XsS   ::  a
  USXE2Xg24   $ UR                  SS [        US   US   5      [        US   US   5      4-   n	[        U[        R
                  5      (       a  [        R                   " XS9n
O![        U5      (       a  UR#                  U	5      n
U	S   US   -
  S-  nX³S   -   nU	S	   US   -
  S-  nXÓS   -   nUW
SX¼2XÞ24'   XK-  nX[-  nXm-  nX}-  nU
S[        SU5      [%        U
R                  S   U5      2[        SU5      [%        U
R                  S	   U5      24   n
U
$ )
a=  
Crops `image` to the given size using a center crop. Note that if the image is too small to be cropped to the
size given, it will be padded (so the returned result has the size asked).

Args:
    image (`PIL.Image.Image` or `np.ndarray` or `torch.Tensor` of shape (n_channels, height, width) or (height, width, n_channels)):
        The image to resize.
    size (`int` or `tuple[int, int]`):
        The size to which crop the image.

Returns:
    new_image: A center cropped `PIL.Image.Image` or `np.ndarray` or `torch.Tensor` of shape: (n_channels,
    height, width).
r’   r   r�   r
   N.r¢   )r–   r£   )r  r7   rf   r   r\   r]   ru   r-  r–   r¥   r8   r9   Úcropr  Úpermuterp   Ú
zeros_likeÚ	new_zerosro   )r  rI   r¥   Úimage_shapeÚtopÚbottomÚleftÚrightr)  Ú	new_shapeÚ	new_imageÚtop_padÚ
bottom_padÚleft_padÚ	right_pads                  r-   Úcenter_cropÚ'ImageFeatureExtractionMixin.center_crop^  sí  € ð 	×%Ñ% eÔ,ä˜$¤×&Ñ&Ø�<ˆDô ˜5×!Ñ!¤Z°´r·z±z×%BÑ%BØ�z‰z˜Q‹Ø×(Ñ(¨Ó/�Ø-2¯[©[¸©^¸vÓ-E˜%Ÿ+™+ a b™/È5Ï;É;ÐWYÐXYÈ?‰Kà Ÿ:™: a™=¨%¯*©*°Q©-Ð8ˆKà˜1‰~  Q¡Ñ'¨AÑ-ˆØ˜A‘w‘ˆØ˜A‘  a¡Ñ(¨QÑ.ˆØ˜A‘w‘ˆô �eœSŸY™YŸ_™_×-Ñ-Ø—:‘:˜t¨%Ð8Ó9Ð9ð Ÿ™ A™¨&Ñ0ˆö Ü˜%¤§¡×,Ñ,ØŸ™¨¨1¨aÓ0�Ü˜u×%Ñ%ØŸ™ a¨¨AÓ.�ð �!‹8˜¨a¡.Ó0°T¸Q³YÀ5ÐXYÉNÓCZØ˜˜c˜j¨$¨*Ð4Ñ5Ð5ð —K‘K  Ð$¬¨D°©G°[À±^Ó(DÄcÈ$ÈqÉ'ÐS^Ð_`ÑSaÓFbÐ'cÑcˆ	Ü�eœRŸZ™Z×(Ñ(ÜŸš eÑ=‰IÜ˜U×#Ñ#ØŸ™¨	Ó2ˆIà˜R‘= ;¨q¡>Ñ1°aÑ7ˆØ¨1™~Ñ-ˆ
Ø˜b‘M K°¡NÑ2°qÑ8ˆØ¨1™~Ñ-ˆ	ØAFˆ	�#�wÐ)¨8Ð+=Ð=Ñ>à‰ˆØÑˆØÑˆØÑˆàØ”�Q˜“œs 9§?¡?°2Ñ#6¸Ó?Ð?ÄÀQÈÃÔPSÐT]×TcÑTcÐdfÑTgÐinÓPoÐAoÐoñ
ˆ	ð Ðr,   c                 ó¶   • U R                  U5        [        U[        R                  R                  5      (       a  U R	                  U5      nUSSS2SS2SS24   $ )ah  
Flips the channel order of `image` from RGB to BGR, or vice versa. Note that this will trigger a conversion of
`image` to a NumPy array if it's a PIL Image.

Args:
    image (`PIL.Image.Image` or `np.ndarray` or `torch.Tensor`):
        The image whose color channels to flip. If `np.ndarray` or `torch.Tensor`, the channel dimension should
        be first.
Nr£   )r  r7   r8   r9   r�   r  s     r-   Úflip_channel_orderÚ.ImageFeatureExtractionMixin.flip_channel_order©  sL   € ð 	×%Ñ% eÔ,ä�eœSŸY™YŸ_™_×-Ñ-Ø×'Ñ'¨Ó.ˆEà‘T�r�Tš1ša�ZÑ Ð r,   c           	      óø   • Ub  UO[         R                  R                  nU R                  U5        [	        U[         R                  R                  5      (       d  U R                  U5      nUR                  X#XEXgS9$ )aŽ  
Returns a rotated copy of `image`. This method returns a copy of `image`, rotated the given number of degrees
counter clockwise around its centre.

Args:
    image (`PIL.Image.Image` or `np.ndarray` or `torch.Tensor`):
        The image to rotate. If `np.ndarray` or `torch.Tensor`, will be converted to `PIL.Image.Image` before
        rotating.

Returns:
    image: A rotated `PIL.Image.Image`.
)r
  ÚexpandÚcenterÚ	translateÚ	fillcolor)r8   r9   ÚNEARESTr  r7   r  Úrotate)r  rI   Úangler
  rX  rY  rZ  r[  s           r-   r]  Ú"ImageFeatureExtractionMixin.rotateº  sj   € ð  (Ñ3‘8¼¿¹×9JÑ9Jˆà×%Ñ% eÔ,ä˜%¤§¡§¡×1Ñ1Ø×%Ñ% eÓ,ˆEà�|‰|Ø¨VÈið ð 
ð 	
r,   r$   r6   )NT)F)NTN)Nr   NNN)r%   r&   r'   r(   Ú__doc__r  r  r   r\   r]   r0  r•   r  r�   r-  r5  r9  rR  rU  r]  r+   r$   r,   r-   r  r  t  se   † ñòôò<$ð˜RŸZ™Zð °¸±ð ÀÇ
Á
ô ôò@ô(2(ôhA5òFIòV!÷"
r,   r  Úannotation_formatÚsupported_annotation_formatsc                 óò   • X;  a  [        S[         SU 35      eU [        R                  L a  [	        U5      (       d  [        S5      eU [        R
                  L a  [        U5      (       d  [        S5      eg g )NzUnsupported annotation format: z must be one of zäInvalid COCO detection annotations. Annotations must a dict (single image) or list of dicts (batch of images) with the following keys: `image_id` and `annotations`, with the latter being a list of annotations in the COCO format.zòInvalid COCO panoptic annotations. Annotations must a dict (single image) or list of dicts (batch of images) with the following keys: `image_id`, `file_name` and `segments_info`, with the latter being a list of annotations in the COCO format.)rF   Úformatr/   r3   rÎ   r4   rÒ   )ra  rb  r¾   s      r-   Úvalidate_annotationsre  Ó  sŒ   € ð
 Ó<ÜÐ:¼6¸(ÐBRÐSoÐRpÐqÓrÐràÔ,×;Ñ;Ò;Ü/°×<Ñ<ÜðBóð ð Ô,×:Ñ:Ò:Ü.¨{×;Ñ;ÜðMóð ð <ð ;r,   Úvalid_processor_keysÚcaptured_kwargsc                 ó®   • [        U5      R                  [        U 5      5      nU(       a+  SR                  U5      n[        R	                  SU S35        g g )Nz, zUnused or unrecognized kwargs: rt   )ÚsetÚ
differenceÚjoinr—   r˜   )rf  rg  Úunused_keysÚunused_key_strs       r-   Úvalidate_kwargsrn  ì  sJ   € Ü�oÓ&×1Ñ1´#Ð6JÓ2KÓL€KÞØŸ™ ;Ó/ˆä�‰Ð8¸Ð8HÈÐJÕKð r,   c                   ó   • \ rS rSr% SrSr\S-  \S'   Sr\S-  \S'   Sr	\S-  \S'   Sr
\S-  \S'   Sr\S-  \S'   Sr\S-  \S	'   Sr\S-  \S
'   Sr\S-  \S'   S rSS jrS rS rS rS rS rSS jrS\4S jrSrg)ÚSizeDictiô  z6
Hashable dictionary to store image size information.
Nr«   r¬   Úlongest_edgeÚshortest_edger¨   r©   Ú
min_pixelsÚ
max_pixelsc                 óV   • [        X5      (       a  [        X5      $ [        SU S35      e)NúKey z not found in SizeDict.)ÚhasattrÚgetattrÚKeyError©r  Úkeys     r-   Ú__getitem__ÚSizeDict.__getitem__  s-   € Ü�4×ÑÜ˜4Ó%Ð%Ü˜˜c˜UÐ"9Ð:Ó;Ð;r,   c                 óT   • [        X5      (       a  [        X5      b  [        X5      $ U$ r6   ©rw  rx  )r  r{  Údefaults      r-   rä   ÚSizeDict.get  s'   € Ü�4×Ñ¤'¨$Ó"4Ñ"@Ü˜4Ó%Ð%Øˆr,   c              #   ó„   #   • [        U 5       H-  n[        XR                  5      nUc  M  UR                  U4v •  M/     g 7fr6   )r   rx  Úname)r  ÚfÚvals      r-   Ú__iter__ÚSizeDict.__iter__  s4   é € ä˜–ˆAÜ˜$§¡Ó'ˆCØ‹Ø—f‘f˜c�kÔ!ò ùs
   ‚%A «A c                 ó*   • [        [        U 5      5      $ r6   )Úhashr   )r  s    r-   Ú__hash__ÚSizeDict.__hash__  s   € Ü”G˜D“MÓ"Ð"r,   c                 ó@   • [        X5      =(       a    [        X5      S L$ r6   r  rz  s     r-   Ú__contains__ÚSizeDict.__contains__  s   € Ü�tÓ!×D¤g¨dÓ&8ÀÐ&DÐDr,   c                 ón   • [        X5      (       d  [        SU S35      e[        R                  XU5        g )Nrv  z" is not a valid field of SizeDict.)rw  ry  ÚobjectÚ__setattr__)r  r{  Úvalues      r-   Ú__setitem__ÚSizeDict.__setitem__  s2   € Ü�t×!Ñ!Ü˜T # Ð&HÐIÓJÐJÜ×Ñ˜4 eÕ,r,   c                 óü   ^ ^• [        T[        5      (       a  [        T 5      T:H  $ [        T[        5      (       a=  [        U 4S j[	        T 5       5       5      [        U4S j[	        T 5       5       5      :H  $ [
        $ )Nc              3   óP   >#   • U  H  n[        TUR                  5      v •  M     g 7fr6   ©rx  rƒ  )rP   r„  r  s     €r-   rQ   Ú"SizeDict.__eq__.<locals>.<genexpr>#  s   øé € ÐEº°1œ  q§v¡v×.Ð.ºùó   ƒ#&c              3   óP   >#   • U  H  n[        TUR                  5      v •  M     g 7fr6   r—  )rP   r„  Úothers     €r-   rQ   r˜  #  s#   øé € ð OÚ0<¨1”˜˜qŸv™v×&Ð&²ùr™  )r7   rÀ   rp  rf   r   ÚNotImplemented)r  r›  s   ``r-   Ú__eq__ÚSizeDict.__eq__  sk   ù€ Ü�eœT×"Ñ"Ü˜“: Ñ&Ð&Ü�eœX×&Ñ&ÜÔE¼¸t¼ÓEÓEÌô OÜ06°t´óOó Jñ ð ô Ðr,   rk   c                 ó¦   • [        U[        [        -  5      (       a0  [        U 5      nUR                  [        U5      5        [        S0 UD6$ [        $ )Nr$   )r7   rÀ   rp  Úupdaterœ  ©r  r›  Úmergeds      r-   Ú__or__ÚSizeDict.__or__(  s@   € Ü�eœT¤H™_×-Ñ-Ü˜$“ZˆFØ�M‰Mœ$˜u›+Ô&ÜÑ%˜fÑ%Ð%ÜÐr,   c                 ó†   • [        U[        5      (       a'  [        U5      nUR                  [        U 5      5        U$ [        $ r6   )r7   rÀ   r   rœ  r¡  s      r-   Ú__ror__ÚSizeDict.__ror__/  s3   € Ü�eœT×"Ñ"Ü˜%“[ˆFØ�M‰Mœ$˜t›*Ô%ØˆMÜÐr,   r$   r6   )rk   rp  )r%   r&   r'   r(   r`  r«   r•   Ú__annotations__r¬   rq  rr  r¨   r©   rs  rt  r|  rä   r†  rŠ  r�  r“  r�  r£  rÀ   r¦  r+   r$   r,   r-   rp  rp  ô  s®   ‡ ñð €FˆC�$‰JÓØ€Eˆ3�‰:ÓØ#€L�#˜‘*Ó#Ø $€M�3˜‘:Ó$Ø!€J��d‘
Ó!Ø €Iˆs�T‰zÓ Ø!€J��d‘
Ó!Ø!€J��d‘
Ó!ò<ô
ò
"ò#òEò-ò
ôð ÷ r,   rp  )r‘   r6   )NNNNNNNNNNNN)jrê   ræ   Úcollections.abcr   Údataclassesr   r   r   Úior   Útypingr   r	   rã   rB   r\   Úutilsr   r   r   r   r   r   r   r   r   Úutils.constantsr   r   r   r   r   r   Úutils.import_utilsr   Ú	PIL.Imager8   ÚPIL.ImageOpsr9   Ú
Resamplingr  Útorchvision.ior   r   Útorchvision.transformsr   Ú!torchvision.transforms.functionalr   r\  ÚNEAREST_EXACTÚBOXr8  ÚHAMMINGÚBICUBICÚLANCZOSÚpil_torch_interpolation_mappingÚitemsÚtorch_pil_interpolation_mappingrA   Ú
get_loggerr%   r—   r]   r[   Ú
ImageInputr    r/   rÀ   rà   r•   ÚAnnotationTyper<   r>   rJ   rL   rV   rd   rg   rj   Úboolrq   rv   r…   rŠ   r�   rf   r›   rŸ   r¦   r²   r·   r)   rº   rÃ   rÇ   rÎ   rÒ   r0  rß   rü   rÿ   r  r  re  rn  rp  )ÚkÚvs   00r-   Ú<module>rÄ     sì  ðó Û 	Ý $ß 2Ñ 2Ý ß ã Û ÷
÷ 
õ 
÷÷ õ )ñ ×ÑÛÛàŸ™×-Ñ-Ðá×Ñß:Ý8Ý?ð 	×"Ñ"Ð$5×$CÑ$CØ×ÑÐ 1× 5Ñ 5Ø×#Ñ#Ð%6×%?Ñ%?Ø×"Ñ"Ð$5×$=Ñ$=Ø×"Ñ"Ð$5×$=Ñ$=Ø×"Ñ"Ð$5×$=Ñ$=ð'Ð#ð 9X×8]Ñ8]Ô8_Ô&`Ò8_±° q¢tÑ8_Ò&`Ñ#à&(Ð#Ø&(Ð#ñ ×ÑÛð 
×	Ò	˜HÓ	%€ð Ø�r—z‘z >°4Ð8IÑ3JÈDÐQS×Q[ÑQ[ÑL\Ð^bÐcqÑ^rÐrñ€
ô
�|ô ô
$�|ô $ð
 �c˜3 ™9 t¨D¡zÑ1Ð1Ñ2€òFô�ô ò?òLðE Dô Eò,ò	òð5˜2Ÿ:™:ð 5¨$ô 5ñ#°ð #¸DÀÑ<Lõ #ðP ñ#LØ�Ñ˜zÑ)ð#Làð#Lð õ#LðP ñ$vØ�Ñ˜zÑ)ð$vàð$vð 
ˆ*Ñõ$vðN˜2Ÿ:™:ô ð EIñ$AØ�:‰:ð$AØ%(¨5°°c°©?Ñ%:¸TÑ%Að$Aàõ$AñNF b§j¡jð FÐEUÐX[ÑE[Ð^bÑEbð FÐnqõ Fð. Y]ñDØ�—‘Ð.Ð.Ñ/ðDØ>NÐQUÑ>UðDà
ˆ3�ˆ8�_õDð:!Ø�c˜3�h‘ð!àð!ð ð!ð ˆ3�ˆ8�_ô	!ð>8˜x¨™}ð 8°°c±ô 8ð br×awÑawñ#Ø��~ r§z¡zÐ1Ñ2Ñ3ð#ØHKÐN^ÑH^ð#à	ˆ#�Yõ#ð°4¸¸TÀE¹\Ð8IÑ3Jð Ètô ð°$°s¸DÀ5¹LÐ7HÑ2Ið Èdô ð O°(¸4ÀÀTÈEÁ\Ð@QÑ;RÑ2Sð OÐX\ô OðN°¸$¸sÀDÈ5ÁLÐ?PÑ:QÑ1Rð NÐW[ô Nð !ñ*Ø�Ð'Ð'Ñ(ð*à�T‰\ð*ð õ*ñZ 
Ð#Ñ$ð !ñ*
Ø�Ð'Ð'Ñ(ð*
à�T‰\ð*
ð ô*
ó %ð*
ð\ QUñ3Ø�$˜˜sÐ$5Ð5Ñ6ð3ØAFÈÁð3à
Ð˜dÐ#4Ñ5°t¸DÐARÑ<SÑ7TÐTÑUõ3ð, #Ø#'Ø $Ø-1Ø,0ØØ,0Ø"&Ø'+Ø!Ø"&ØMQñ+^Ø�t‘ð+^à˜D‘Lð+^ð ˜‘+ð+^ð ˜˜U™Ñ# dÑ*ð	+^ð
 �t˜E‘{Ñ" TÑ)ð+^ð �4‰Kð+^ð �3˜�8‰n˜sÑ" TÑ)ð+^ð ˜4‘Kð+^ð �C˜�H‰~ Ñ$ð+^ð �d‰{ð+^ð ˆs�Cˆx‰.˜4Ñ
ð+^ð Ð(Ð*=¸sÐBÑCÀdÑJõ+^÷\\
ñ \
ð~
Ø'ðà"'Ð(8¸#Ð(=Ñ">ðð �d‘ðð 
ô	ð2L¨$¨s©)ð LÀdÈ3Áiô Lñ ƒ÷?ð ?ó ñ?ùóe 'as   Ä>Q