§
    Ý˜ºh½“  ã                   óÞ  — d dl Z d dlZd dlmZ d dlmZ d dlmZ d dlm	Z	m
Z
 d dlZd dlZd dlmZ ddlmZmZmZmZmZmZmZmZmZmZmZmZ dd	lmZmZm Z m!Z!m"Z"m#Z#  e¦   «         rÄd dl$Z%d dl&Z% ej'         ej'        e%j(        ¦  «        j)        ¦  «         ej'        d
¦  «        k    re%j*        j+        Z,ne%j*        Z, e¦   «         rbd dl-m.Z. e,j/         e¦   «         re.j0        ne.j/        e,j1        e.j1        e,j2        e.j2        e,j3        e.j3        e,j4        e.j4        e,j5        e.j5        iZ6ni Z6 e¦   «         rd dl7Z7 ej8        e9¦  «        Z:e
dej;        de<d         e<ej;                 e<d         f         Z= G d„ de¦  «        Z> G d„ de¦  «        Z? G d„ de¦  «        Z@eAeBe
eCeBe<eA         f         f         ZDd„ ZE G d„ de¦  «        ZFd„ ZGd„ ZHde<fd„ZId„ ZJd„ ZKd„ ZLdej;        deMfd „ZNdWd"eCde<e=         fd#„ZO	 dWde
e<e=         e=f         d"eCde=fd$„ZP	 dWde
e<e=         e=f         d"eCde=fd%„ZQdej;        fd&„ZR	 dXdej;        d'e	e
eCeSeCd(f         f                  de>fd)„ZT	 dXdej;        d*e	e
e>eBf                  deCfd+„ZUdXdej;        d,e>deSeCeCf         fd-„ZVd.eSeCeCf         d/eCd0eCdeSeCeCf         fd1„ZWd2eAeBe
e<eSf         f         deMfd3„ZXd2eAeBe
e<eSf         f         deMfd4„ZYd5eeAeBe
e<eSf         f                  deMfd6„ZZd5eeAeBe
e<eSf         f                  deMfd7„Z[dXde
eBdf         d8e	e\         ddfd9„Z]	 dXde
e<eSeBdf         d8e	e\         de
de<d         e<e<d                  f         fd:„Z^	 	 	 	 	 	 	 	 	 	 	 	 	 dYd;e	eM         d<e	e\         d=e	eM         d>e	e
e\e<e\         f                  d?e	e
e\e<e\         f                  d@e	eM         dAe	eC         dBe	eM         dCe	eAeBeCf                  dDe	eM         dEe	eAeBeCf                  dFe	dG         dHe	dI         fdJ„Z_ G dK„ dL¦  «        Z`dMe?dNeSe?d(f         d5e<eA         ddfdO„ZadPe<eB         dQe<eB         fdR„Zb edS¬T¦  «         G dU„ dV¦  «        ¦   «         ZcdS )Zé    N)ÚIterable)Ú	dataclass)ÚBytesIO)ÚOptionalÚUnion)Úversioné   )ÚExplicitEnumÚis_jax_tensorÚis_numpy_arrayÚis_tf_tensorÚis_torch_availableÚis_torch_tensorÚis_torchvision_availableÚis_torchvision_v2_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_STDz9.1.0)ÚInterpolationModezPIL.Image.Imageztorch.Tensorc                   ó   — e Zd ZdZdZdS )ÚChannelDimensionÚchannels_firstÚchannels_lastN)Ú__name__Ú
__module__Ú__qualname__ÚFIRSTÚLAST© ó    ú`/var/www/html/services/rag-service/venv/lib/python3.11/site-packages/transformers/image_utils.pyr   r   X   s   € € € € € Ø€EØ€D€D€Dr'   r   c                   ó   — e Zd ZdZdZdS )ÚAnnotationFormatÚcoco_detectionÚcoco_panopticN)r!   r"   r#   ÚCOCO_DETECTIONÚCOCO_PANOPTICr&   r'   r(   r*   r*   ]   s   € € € € € Ø%€NØ#€M€M€Mr'   r*   c                   ó>   — e Zd Zej        j        Zej        j        ZdS )ÚAnnotionFormatN)r!   r"   r#   r*   r-   Úvaluer.   r&   r'   r(   r0   r0   b   s$   € € € € € Ø%Ô4Ô:€NØ$Ô2Ô8€M€M€Mr'   r0   c                 ó\   — t          ¦   «         ot          | t          j        j        ¦  «        S ©N)r   Ú
isinstanceÚPILÚImage©Úimgs    r(   Úis_pil_imager9   j   s!   € ÝÑ Ô ÐE¥Z°µS´Y´_Ñ%EÔ%EÐEr'   c                   ó"   — e Zd ZdZdZdZdZdZdS )Ú	ImageTypeÚpillowÚtorchÚnumpyÚ
tensorflowÚjaxN)r!   r"   r#   r5   ÚTORCHÚNUMPYÚ
TENSORFLOWÚJAXr&   r'   r(   r;   r;   n   s'   € € € € € Ø
€CØ€EØ€EØ€JØ
€C€C€Cr'   r;   c                 óN  — t          | ¦  «        rt          j        S t          | ¦  «        rt          j        S t          | ¦  «        rt          j        S t          | ¦  «        rt          j        S t          | ¦  «        rt          j
        S t          dt          | ¦  «        › �¦  «        ‚)NzUnrecognized image type )r9   r;   r5   r   rA   r   rB   r   rC   r   rD   Ú
ValueErrorÚtype©Úimages    r(   Úget_image_typerJ   v   s˜   € Ý�EÑÔð ÝŒ}ÐÝ�uÑÔð ÝŒÐÝ�eÑÔð ÝŒÐÝ�EÑÔð $ÝÔ#Ð#Ý�UÑÔð ÝŒ}ÐÝ
Ð=µ°U±´Ð=Ð=Ñ
>Ô
>Ð>r'   c                 ó˜   — t          | ¦  «        p;t          | ¦  «        p,t          | ¦  «        pt          | ¦  «        pt	          | ¦  «        S r3   )r9   r   r   r   r   r7   s    r(   Úis_valid_imagerL   „   sG   € Ý˜ÑÔÐv¥¨sÑ 3Ô 3ÐvµÀsÑ7KÔ7KÐvÍ|Ð\_ÑO`ÔO`ÐvÕdqÐruÑdvÔdvÐvr'   Úimagesc                 ó8   — | ot          d„ | D ¦   «         ¦  «        S )Nc              3   ó4   K  — | ]}t          |¦  «        V — Œd S r3   )rL   ©Ú.0rI   s     r(   ú	<genexpr>z*is_valid_list_of_images.<locals>.<genexpr>‰   s*   è è € ÐDÐD°E�.¨Ñ/Ô/ÐDÐDÐDÐDÐDÐDr'   ©Úall)rM   s    r(   Úis_valid_list_of_imagesrU   ˆ   s$   € ØÐD•cÐDÐD¸VÐDÑDÔDÑDÔDÐDr'   c                 ó,  — t          | d         t          ¦  «        rd„ | D ¦   «         S t          | d         t          j        ¦  «        rt          j        | d¬¦  «        S t          | d         t
          j        ¦  «        rt          j        | d¬¦  «        S d S )Nr   c                 ó   — g | ]	}|D ]}|‘ŒŒ
S r&   r&   )rQ   ÚsublistÚitems      r(   ú
<listcomp>z$concatenate_list.<locals>.<listcomp>Ž   s%   € ÐCÐCÐC˜¸7ÐCÐC°4�ÐCÐCÐCÐCr'   ©Úaxis)Údim)r4   ÚlistÚnpÚndarrayÚconcatenater=   ÚTensorÚcat)Ú
input_lists    r(   Úconcatenate_listre   Œ   s�   € Ý�*˜Q”-¥Ñ&Ô&ð ,ØCÐC JÐCÑCÔCÐCÝ	�J˜q”M¥2¤:Ñ	.Ô	.ð ,ÝŒ~˜j¨qÐ1Ñ1Ô1Ð1Ý	�J˜q”M¥5¤<Ñ	0Ô	0ð ,ÝŒy˜¨Ð+Ñ+Ô+Ð+ð,ð ,r'   c                 ó�   — t          | t          t          f¦  «        r| D ]}t          |¦  «        s dS Œnt	          | ¦  «        sdS dS )NFT)r4   r^   ÚtupleÚvalid_imagesrL   )Úimgsr8   s     r(   rh   rh   •   sd   € å�$��u˜Ñ&Ô&ð Øð 	ð 	ˆCÝ Ñ$Ô$ð Ø�u�uðð	õ ˜DÑ!Ô!ð ØˆuØˆ4r'   c                 óh   — t          | t          t          f¦  «        rt          | d         ¦  «        S dS )Nr   F)r4   r^   rg   rL   r7   s    r(   Ú
is_batchedrk   ¡   s/   € Ý�#��e�}Ñ%Ô%ð &Ý˜c !œfÑ%Ô%Ð%Øˆ5r'   rI   Úreturnc                 ó�   — | j         t          j        k    rdS t          j        | ¦  «        dk    ot          j        | ¦  «        dk    S )zV
    Checks to see whether the pixel values have already been rescaled to [0, 1].
    Fr   r	   )Údtyper_   Úuint8ÚminÚmaxrH   s    r(   Úis_scaled_imagerr   §   s?   € ð „{•b”hÒÐØˆuõ Œ6�%‰=Œ=˜AÒÐ4¥"¤&¨¡-¤-°1Ò"4Ð4r'   é   Úexpected_ndimsc           	      óF  — t          | ¦  «        r| S t          | ¦  «        r| gS t          | ¦  «        rP| j        |dz   k    rt	          | ¦  «        } n0| j        |k    r| g} n!t          d|dz   › d|› d| j        › d�¦  «        ‚| S t          dt          | ¦  «        › d�¦  «        ‚)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 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.ztInvalid image type. Expected either PIL.Image.Image, numpy.ndarray, torch.Tensor, tf.Tensor or jax.ndarray, but got ú.)rk   r9   rL   Úndimr^   rF   rG   ©rM   rt   s     r(   Úmake_list_of_imagesry   ²   sö   € õ �&ÑÔð Øˆõ �FÑÔð àˆxˆå�fÑÔð ØŒ;˜.¨1Ñ,Ò,Ð,å˜&‘\”\ˆFˆFØŒ[˜NÒ*Ð*à�XˆFˆFåð.¸ÈÑ8Jð .ð .ÐP^ð .ð .Ø”Kð.ð .ð .ñô ð ð ˆÝ
ð	0Ý $ V¡¤ð	0ð 	0ð 	0ñô ð r'   c                 óR  — t          | t          t          f¦  «        r>t          d„ | D ¦   «         ¦  «        r%t          d„ | D ¦   «         ¦  «        rd„ | D ¦   «         S t          | t          t          f¦  «        rWt	          | ¦  «        rHt          | d         ¦  «        s| d         j        |k    r| S | d         j        |dz   k    rd„ | D ¦   «         S t          | ¦  «        r:t          | ¦  «        s| j        |k    r| gS | j        |dz   k    rt          | ¦  «        S t          d| › �¦  «        ‚)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   K  — | ] }t          |t          t          f¦  «        V — Œ!d S r3   ©r4   r^   rg   ©rQ   Úimages_is     r(   rR   z+make_flat_list_of_images.<locals>.<genexpr>ë   ó0   è è € ÐKÐK¸•
˜8¥d­E ]Ñ3Ô3ÐKÐKÐKÐKÐKÐKr'   c              3   ó4   K  — | ]}t          |¦  «        V — Œd S r3   ©rU   r}   s     r(   rR   z+make_flat_list_of_images.<locals>.<genexpr>ì   ó+   è è € ÐIÐI°hÕ'¨Ñ1Ô1ÐIÐIÐIÐIÐIÐIr'   c                 ó   — g | ]	}|D ]}|‘ŒŒ
S r&   r&   ©rQ   Úimg_listr8   s      r(   rZ   z,make_flat_list_of_images.<locals>.<listcomp>î   s%   € Ð?Ð?Ð?˜°hÐ?Ð?¨s�Ð?Ð?Ð?Ð?r'   r   r	   c                 ó   — g | ]	}|D ]}|‘ŒŒ
S r&   r&   r„   s      r(   rZ   z,make_flat_list_of_images.<locals>.<listcomp>ô   s%   € ÐCÐCÐC˜H¸(ÐCÐC°3�CÐCÐCÐCÐCr'   z*Could not make a flat list of images from ©	r4   r^   rg   rT   rU   r9   rw   rL   rF   rx   s     r(   Úmake_flat_list_of_imagesrˆ   Ù   sW  € õ" 	�6�D¥%˜=Ñ)Ô)ð@åÐKÐKÀFÐKÑKÔKÑKÔKð@õ ÐIÐIÀ&ÐIÑIÔIÑIÔIð@ð
 @Ð? FÐ?Ñ?Ô?Ð?å�&�4¥˜-Ñ(Ô(ð DÕ-DÀVÑ-LÔ-Lð DÝ˜˜qœ	Ñ"Ô"ð 	 f¨Q¤i¤n¸Ò&FÐ&FØˆMØ�!Œ9Œ>˜^¨aÑ/Ò/Ð/ØCÐC¨ÐCÑCÔCÐCå�fÑÔð  Ý˜ÑÔð 	 6¤;°.Ò#@Ð#@Ø�8ˆOØŒ;˜.¨1Ñ,Ò,Ð,Ý˜‘<”<Ðå
ÐJÀ&ÐJÐJÑ
KÔ
KÐKr'   c                 ó>  — t          | t          t          f¦  «        r4t          d„ | D ¦   «         ¦  «        rt          d„ | D ¦   «         ¦  «        r| S t          | t          t          f¦  «        rXt	          | ¦  «        rIt          | d         ¦  «        s| d         j        |k    r| gS | d         j        |dz   k    rd„ | D ¦   «         S t          | ¦  «        r<t          | ¦  «        s| j        |k    r| ggS | j        |dz   k    rt          | ¦  «        gS t          d¦  «        ‚)as  
    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   K  — | ] }t          |t          t          f¦  «        V — Œ!d S r3   r|   r}   s     r(   rR   z-make_nested_list_of_images.<locals>.<genexpr>  r   r'   c              3   ó4   K  — | ]}t          |¦  «        V — Œd S r3   r�   r}   s     r(   rR   z-make_nested_list_of_images.<locals>.<genexpr>  r‚   r'   r   r	   c                 ó,   — g | ]}t          |¦  «        ‘ŒS r&   )r^   rP   s     r(   rZ   z.make_nested_list_of_images.<locals>.<listcomp>  s   € Ð4Ð4Ð4 E•D˜‘K”KÐ4Ð4Ð4r'   z]Invalid input type. Must be a single image, a list of images, or a list of batches of images.r‡   rx   s     r(   Úmake_nested_list_of_imagesr�   ÿ   sE  € õ  	�6�D¥%˜=Ñ)Ô)ðåÐKÐKÀFÐKÑKÔKÑKÔKðõ ÐIÐIÀ&ÐIÑIÔIÑIÔIðð
 ˆõ �&�4¥˜-Ñ(Ô(ð 5Õ-DÀVÑ-LÔ-Lð 5Ý˜˜qœ	Ñ"Ô"ð 	 f¨Q¤i¤n¸Ò&FÐ&FØ�8ˆOØ�!Œ9Œ>˜^¨aÑ/Ò/Ð/Ø4Ð4¨VÐ4Ñ4Ô4Ð4õ �fÑÔð "Ý˜ÑÔð 	 6¤;°.Ò#@Ð#@Ø�H�:ÐØŒ;˜.¨1Ñ,Ò,Ð,Ý˜‘L”L�>Ð!å
ÐtÑ
uÔ
uÐur'   c                 óþ   — t          | ¦  «        st          dt          | ¦  «        › �¦  «        ‚t          ¦   «         r3t	          | t
          j        j        ¦  «        rt          j        | ¦  «        S t          | ¦  «        S )NzInvalid image type: )
rL   rF   rG   r   r4   r5   r6   r_   Úarrayr   r7   s    r(   Úto_numpy_arrayr�   &  sl   € Ý˜#ÑÔð =ÝÐ;µ°S±	´	Ð;Ð;Ñ<Ô<Ð<åÑÔð ¥¨Cµ´´Ñ!AÔ!Að ÝŒx˜‰}Œ}ÐÝ�C‰=Œ=Ðr'   Únum_channels.c                 óú  — |�|nd}t          |t          ¦  «        r|fn|}| j        dk    rd\  }}n9| j        dk    rd\  }}n(| j        dk    rd\  }}nt          d| j        › �¦  «        ‚| j        |         |v r>| j        |         |v r/t
                               d	| j        › d
�¦  «         t          j        S | j        |         |v rt          j        S | j        |         |v rt          j	        S t          d¦  «        ‚)a[  
    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.
    N©r	   rs   rs   )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)
r4   Úintrw   rF   ÚshapeÚloggerÚwarningr   r$   r%   )rI   r‘   Ú	first_dimÚlast_dims       r(   Úinfer_channel_dimension_formatr�   /  s/  € ð $0Ð#;�<�<À€LÝ&0°½sÑ&CÔ&CÐU�L�?�?È€Là„z�Q‚€Ø"Ñˆ	�8�8Ø	Œ�qŠˆØ"Ñˆ	�8�8Ø	Œ�qŠˆØ"Ñˆ	�8�8åÐPÀEÄJÐPÐPÑQÔQÐQà„{�9Ô Ð-Ð-°%´+¸hÔ2GÈ<Ð2WÐ2WÝ�Šð KÀ5Ä;ð  Kð  Kð  Kñ	
ô 	
ð 	
õ  Ô%Ð%Ø	Œ�YÔ	 <Ð	/Ð	/ÝÔ%Ð%Ø	Œ�XÔ	 ,Ð	.Ð	.ÝÔ$Ð$Ý
Ð?Ñ
@Ô
@Ð@r'   Úinput_data_formatc                 ó°   — |€t          | ¦  «        }|t          j        k    r
| j        dz
  S |t          j        k    r
| j        dz
  S t          d|› �¦  «        ‚)a–  
    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.
    Nrs   r	   úUnsupported data format: )r�   r   r$   rw   r%   rF   )rI   rž   s     r(   Úget_channel_dimension_axisr¡   V  sf   € ð Ð Ý:¸5ÑAÔAÐØÕ,Ô2Ò2Ð2ØŒz˜A‰~ÐØ	Õ.Ô3Ò	3Ð	3ØŒz˜A‰~ÐÝ
ÐDÐ1BÐDÐDÑ
EÔ
EÐEr'   Úchannel_dimc                 óð   — |€t          | ¦  «        }|t          j        k    r| j        d         | j        d         fS |t          j        k    r| j        d         | j        d         fS t          d|› �¦  «        ‚)a�  
    Returns the (height, width) dimensions of the image.

    Args:
        image (`np.ndarray`):
            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.
    Néþÿÿÿéÿÿÿÿéýÿÿÿr    )r�   r   r$   r˜   r%   rF   )rI   r¢   s     r(   Úget_image_sizer§   n  sz   € ð ÐÝ4°UÑ;Ô;ˆàÕ&Ô,Ò,Ð,ØŒ{˜2Œ ¤¨B¤Ð/Ð/Ø	Õ(Ô-Ò	-Ð	-ØŒ{˜2Œ ¤¨B¤Ð/Ð/åÐB°[ÐBÐBÑCÔCÐCr'   Ú
image_sizeÚ
max_heightÚ	max_widthc                 ó�   — | \  }}||z  }||z  }t          ||¦  «        }t          ||z  ¦  «        }t          ||z  ¦  «        }	||	fS )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.
    )rp   r—   )
r¨   r©   rª   ÚheightÚwidthÚheight_scaleÚwidth_scaleÚ	min_scaleÚ
new_heightÚ	new_widths
             r(   Ú#get_image_size_for_max_height_widthr³   †  s_   € ð, �M€FˆEØ Ñ&€LØ˜eÑ#€KÝ�L +Ñ.Ô.€IÝ�V˜iÑ'Ñ(Ô(€JÝ�E˜IÑ%Ñ&Ô&€IØ�yÐ Ð r'   Ú
annotationc                 óü   — t          | t          ¦  «        rfd| v rbd| v r^t          | d         t          t          f¦  «        r<t	          | d         ¦  «        dk    s!t          | d         d         t          ¦  «        rdS dS )NÚimage_idÚannotationsr   TF©r4   Údictr^   rg   Úlen©r´   s    r(   Ú"is_valid_annotation_coco_detectionr¼   ¥  s†   € å�:�tÑ$Ô$ð
à˜*Ð$Ð$Ø˜ZÐ'Ð'Ý�z -Ô0µ4½°-Ñ@Ô@ð (õ �
˜=Ô)Ñ*Ô*¨aÒ/Ð/µ:¸jÈÔ>WÐXYÔ>ZÕ\`Ñ3aÔ3aÐ/ð ˆtØˆ5r'   c                 ó  — t          | t          ¦  «        rjd| v rfd| v rbd| v r^t          | d         t          t          f¦  «        r<t	          | d         ¦  «        dk    s!t          | d         d         t          ¦  «        rdS dS )Nr¶   Úsegments_infoÚ	file_namer   TFr¸   r»   s    r(   Ú!is_valid_annotation_coco_panopticrÀ   ´  s‘   € å�:�tÑ$Ô$ðà˜*Ð$Ð$Ø˜zÐ)Ð)Ø˜:Ð%Ð%Ý�z /Ô2µT½5°MÑBÔBð &õ �
˜?Ô+Ñ,Ô,°Ò1Ð1µZÀ
È?Ô@[Ð\]Ô@^Õ`dÑ5eÔ5eÐ1ð ˆtØˆ5r'   r·   c                 ó4   — t          d„ | D ¦   «         ¦  «        S )Nc              3   ó4   K  — | ]}t          |¦  «        V — Œd S r3   )r¼   ©rQ   Úanns     r(   rR   z3valid_coco_detection_annotations.<locals>.<genexpr>Å  s+   è è € ÐNÐN¸3Õ1°#Ñ6Ô6ÐNÐNÐNÐNÐNÐNr'   rS   ©r·   s    r(   Ú valid_coco_detection_annotationsrÆ   Ä  s   € ÝÐNÐNÀ+ÐNÑNÔNÑNÔNÐNr'   c                 ó4   — t          d„ | D ¦   «         ¦  «        S )Nc              3   ó4   K  — | ]}t          |¦  «        V — Œd S r3   )rÀ   rÃ   s     r(   rR   z2valid_coco_panoptic_annotations.<locals>.<genexpr>É  s+   è è € ÐMÐM¸#Õ0°Ñ5Ô5ÐMÐMÐMÐMÐMÐMr'   rS   rÅ   s    r(   Úvalid_coco_panoptic_annotationsrÉ   È  s   € ÝÐMÐMÀÐMÑMÔMÑMÔMÐMr'   Útimeoutc                 óÞ  — t          t          dg¦  «         t          | t          ¦  «        �r[|                      d¦  «        s|                      d¦  «        rGt
          j                             t          t          j
        | |¬¦  «        j        ¦  «        ¦  «        } �nt          j                             | ¦  «        r t
          j                             | ¦  «        } nÜ|                      d¦  «        r|                      d¦  «        d         } 	 t!          j        |                      ¦   «         ¦  «        }t
          j                             t          |¦  «        ¦  «        } nX# t&          $ r}t)          d| › d	|› �¦  «        ‚d
}~ww xY wt          | t
          j        j        ¦  «        r| } nt+          d¦  «        ‚t
          j                             | ¦  «        } |                      d¦  «        } | S )a3  
    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.
    Úvisionzhttp://zhttps://©rÊ   zdata:image/ú,r	   z’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 z. 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_imager4   ÚstrÚ
startswithr5   r6   Úopenr   ÚrequestsÚ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—N’N¥7­8¬<¸ÀwÐ+OÑ+OÔ+OÔ+WÑ#XÔ#XÑYÔYˆE‰EÝŒW�^Š^˜EÑ"Ô"ð 	Ý”I—N’N 5Ñ)Ô)ˆEˆEà×Ò Ñ.Ô.ð ,ØŸš CÑ(Ô(¨Ô+�ðÝÔ(¨¯ª©¬Ñ8Ô8�Ýœ	Ÿš¥w¨s¡|¤|Ñ4Ô4��øÝð ð ð Ý ð Bð  joð  Bð  Bð  @ð  Bð  Bñô ð øøøøðøøøõ 
�E�3œ9œ?Ñ	+Ô	+ð 
Øˆˆåð Dñ
ô 
ð 	
õ ŒL×'Ò'¨Ñ.Ô.€EØ�MŠM˜%Ñ Ô €EØ€Ls   ÄAE! Å!
FÅ+F Æ Fc                 óø   ‡— t          | t          t          f¦  «        rMt          | ¦  «        r0t          | d         t          t          f¦  «        rˆfd„| D ¦   «         S ˆfd„| D ¦   «         S t	          | ‰¬¦  «        S )a  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   c                 ó,   •— g | ]}ˆfd „|D ¦   «         ‘ŒS )c                 ó2   •— g | ]}t          |‰¬ ¦  «        ‘ŒS ©rÍ   ©rÐ   ©rQ   rI   rÊ   s     €r(   rZ   z*load_images.<locals>.<listcomp>.<listcomp>  s&   ø€ ÐQÐQÐQ¸E•Z ¨wÐ7Ñ7Ô7ÐQÐQÐQr'   r&   )rQ   Úimage_grouprÊ   s     €r(   rZ   zload_images.<locals>.<listcomp>  s/   ø€ ÐlÐlÐlÐVaÐQÐQÐQÐQÀ[ÐQÑQÔQÐlÐlÐlr'   c                 ó2   •— g | ]}t          |‰¬ ¦  «        ‘ŒS rè   ré   rê   s     €r(   rZ   zload_images.<locals>.<listcomp>  s&   ø€ ÐKÐKÐK¸5•J˜u¨gÐ6Ñ6Ô6ÐKÐKÐKr'   rÍ   )r4   r^   rg   rº   rÐ   )rM   rÊ   s    `r(   Úload_imagesrí   ø  sŒ   ø€ õ �&�4¥˜-Ñ(Ô(ð 3Ýˆv‰;Œ;ð 	L�: f¨Q¤iµ$½°Ñ?Ô?ð 	LØlÐlÐlÐlÐekÐlÑlÔlÐlàKÐKÐKÐKÀFÐKÑKÔKÐKå˜&¨'Ð2Ñ2Ô2Ð2r'   Ú
do_rescaleÚrescale_factorÚdo_normalizeÚ
image_meanÚ	image_stdÚdo_padÚsize_divisibilityÚdo_center_cropÚ	crop_sizeÚ	do_resizeÚsizeÚresampleÚPILImageResamplingÚinterpolationr   c                 óþ   — | r|€t          d¦  «        ‚|r|€t          d¦  «        ‚|r|�|€t          d¦  «        ‚|r|€t          d¦  «        ‚|�|�t          d¦  «        ‚|	r|
�|€|€t          d¦  «        ‚dS dS dS )a‡  
    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`.zzDepending on the model, `size_divisibility`, `size_divisor`, `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`.zbOnly one of `interpolation` and `resample` should be specified, depending on image processor type.zO`size` and `resample/interpolation` must be specified if `do_resize` is `True`.)rF   )rî   rï   rð   rñ   rò   ró   rô   rõ   rö   r÷   rø   rù   rû   s                r(   Úvalidate_preprocess_argumentsrý     sé   € ð. ð Z�nÐ,ÝÐXÑYÔYÐYàð 
Ð#Ð+åð Iñ
ô 
ð 	
ð ð m˜Ð+¨yÐ/@ÝÐkÑlÔlÐlàð Y˜)Ð+ÝÐWÑXÔXÐXàÐ  XÐ%9ÝØpñ
ô 
ð 	
ð ð l˜$Ð*°Ð0DÈÐHaÝÐjÑkÔkÐkðlð lÐ0DÐ0DÐHaÐHar'   c                   ó�   — e Zd ZdZd„ Zdd„Zd„ Zdej        de	e
ef         dej        fd	„Zdd„Zd„ Zdd„Zdd„Zd„ Zd„ Zdd„ZdS )ÚImageFeatureExtractionMixinzD
    Mixin that contain utilities for preparing image features.
    c                 ó¾   — t          |t          j        j        t          j        f¦  «        s/t          |¦  «        s"t          dt          |¦  «        › d�¦  «        ‚d S d S )Nz	Got type zS which is not supported, only `PIL.Image.Image`, `np.array` and `torch.Tensor` are.)r4   r5   r6   r_   r`   r   rF   rG   ©ÚselfrI   s     r(   Ú_ensure_format_supportedz4ImageFeatureExtractionMixin._ensure_format_supportedB  sq   € Ý˜%¥#¤)¤/µ2´:Ð!>Ñ?Ô?ð 	ÍÐX]ÑH^ÔH^ð 	Ýð&�D ™KœKð &ð &ð &ñô ð ð	ð 	ð 	ð 	r'   Nc                 óä  — |                       |¦  «         t          |¦  «        r|                     ¦   «         }t          |t          j        ¦  «        r�|€%t          |j        d         t          j        ¦  «        }|j        dk    r&|j	        d         dv r| 
                    ddd¦  «        }|r|dz  }|                     t          j        ¦  «        }t          j                             |¦  «        S |S )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.
        Nr   rs   r“   r	   r”   éÿ   )r  r   r>   r4   r_   r`   ÚflatÚfloatingrw   r˜   Ú	transposeÚastypero   r5   r6   Ú	fromarray)r  rI   Úrescales      r(   Úto_pil_imagez(ImageFeatureExtractionMixin.to_pil_imageI  sÔ   € ð 	×%Ò% eÑ,Ô,Ð,å˜5Ñ!Ô!ð 	"Ø—K’K‘M”MˆEå�e�RœZÑ(Ô(ð 
	.Øˆå$ U¤Z°¤]µB´KÑ@Ô@�àŒz˜QŠˆ 5¤;¨q¤>°VÐ#;Ð#;ØŸš¨¨1¨aÑ0Ô0�Øð $Ø ™�Ø—L’L¥¤Ñ*Ô*ˆEÝ”9×&Ò& uÑ-Ô-Ð-Øˆr'   c                 ó˜   — |                       |¦  «         t          |t          j        j        ¦  «        s|S |                     d¦  «        S )z—
        Converts `PIL.Image.Image` to RGB format.

        Args:
            image (`PIL.Image.Image`):
                The image to convert.
        rÏ   )r  r4   r5   r6   râ   r  s     r(   Úconvert_rgbz'ImageFeatureExtractionMixin.convert_rgbg  sE   € ð 	×%Ò% eÑ,Ô,Ð,Ý˜%¥¤¤Ñ1Ô1ð 	ØˆLà�}Š}˜UÑ#Ô#Ð#r'   rI   Úscalerl   c                 ó6   — |                       |¦  «         ||z  S )z7
        Rescale a numpy image by scale amount
        )r  )r  rI   r  s      r(   r  z#ImageFeatureExtractionMixin.rescaleu  s"   € ð 	×%Ò% eÑ,Ô,Ð,Ø�u‰}Ðr'   Tc                 óà  — |                       |¦  «         t          |t          j        j        ¦  «        rt	          j        |¦  «        }t          |¦  «        r|                     ¦   «         }|€%t          |j        d         t          j	        ¦  «        n|}|r3|  
                    |                     t          j        ¦  «        d¦  «        }|r"|j        dk    r|                     ddd¦  «        }|S )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.
        Nr   çp?rs   r”   r	   )r  r4   r5   r6   r_   r�   r   r>   r  Úintegerr  r	  Úfloat32rw   r  )r  rI   r  Úchannel_firsts       r(   r�   z*ImageFeatureExtractionMixin.to_numpy_array|  sÏ   € ð 	×%Ò% eÑ,Ô,Ð,å�e�SœYœ_Ñ-Ô-ð 	$Ý”H˜U‘O”OˆEå˜5Ñ!Ô!ð 	"Ø—K’K‘M”MˆEà;B¸?•*˜UœZ¨œ]­B¬JÑ7Ô7Ð7ÐPWˆàð 	FØ—L’L §¢­b¬jÑ!9Ô!9¸9ÑEÔEˆEàð 	-˜UœZ¨1š_˜_Ø—O’O A q¨!Ñ,Ô,ˆEàˆr'   c                 óè   — |                       |¦  «         t          |t          j        j        ¦  «        r|S t	          |¦  «        r|                     d¦  «        }nt          j        |d¬¦  «        }|S )z½
        Expands 2-dimensional `image` to 3 dimensions.

        Args:
            image (`PIL.Image.Image` or `np.ndarray` or `torch.Tensor`):
                The image to expand.
        r   r[   )r  r4   r5   r6   r   Ú	unsqueezer_   Úexpand_dimsr  s     r(   r  z'ImageFeatureExtractionMixin.expand_dimsœ  sq   € ð 	×%Ò% eÑ,Ô,Ð,õ �e�SœYœ_Ñ-Ô-ð 	ØˆLå˜5Ñ!Ô!ð 	2Ø—O’O AÑ&Ô&ˆEˆEå”N 5¨qÐ1Ñ1Ô1ˆEØˆr'   Fc                 óÜ  — |                       |¦  «         t          |t          j        j        ¦  «        r|                      |d¬¦  «        }n‡|r…t          |t
          j        ¦  «        r4|                      |                     t
          j	        ¦  «        d¦  «        }n7t          |¦  «        r(|                      |                     ¦   «         d¦  «        }t          |t
          j        ¦  «        r�t          |t
          j        ¦  «        s,t          j        |¦  «                             |j        ¦  «        }t          |t
          j        ¦  «        s,t          j        |¦  «                             |j        ¦  «        }n³t          |¦  «        r¤ddl}t          ||j        ¦  «        s;t          |t
          j        ¦  «        r |j        |¦  «        }n |j        |¦  «        }t          ||j        ¦  «        s;t          |t
          j        ¦  «        r |j        |¦  «        }n |j        |¦  «        }|j        dk    r-|j        d         dv r||dd…ddf         z
  |dd…ddf         z  S ||z
  |z  S )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   Nrs   r“   )r  r4   r5   r6   r�   r_   r`   r  r	  r  r   Úfloatr�   rn   r=   rb   Ú
from_numpyÚtensorrw   r˜   )r  rI   ÚmeanÚstdr  r=   s         r(   Ú	normalizez%ImageFeatureExtractionMixin.normalize°  s6  € ð  	×%Ò% eÑ,Ô,Ð,å�e�SœYœ_Ñ-Ô-ð 	?Ø×'Ò'¨°tÐ'Ñ<Ô<ˆEˆEð ð 	?Ý˜%¥¤Ñ,Ô,ð ?ØŸš U§\¢\µ"´*Ñ%=Ô%=¸yÑIÔI��Ý  Ñ'Ô'ð ?ØŸš U§[¢[¡]¤]°IÑ>Ô>�å�e�RœZÑ(Ô(ð 	,Ý˜d¥B¤JÑ/Ô/ð :Ý”x ‘~”~×,Ò,¨U¬[Ñ9Ô9�Ý˜c¥2¤:Ñ.Ô.ð 8Ý”h˜s‘m”m×*Ò*¨5¬;Ñ7Ô7�øÝ˜UÑ#Ô#ð 	,ØˆLˆLˆLå˜d E¤LÑ1Ô1ð .Ý˜d¥B¤JÑ/Ô/ð .Ø+˜5Ô+¨DÑ1Ô1�D�Dà'˜5œ<¨Ñ-Ô-�DÝ˜c 5¤<Ñ0Ô0ð ,Ý˜c¥2¤:Ñ.Ô.ð ,Ø*˜%Ô*¨3Ñ/Ô/�C�Cà&˜%œ, sÑ+Ô+�CàŒ:˜Š?ˆ?˜uœ{¨1œ~°Ð7Ð7Ø˜D    D¨$ Ô/Ñ/°3°q°q°q¸$À°}Ô3EÑEÐEà˜D‘L CÑ'Ð'r'   c                 ó  — |�|nt           j        }|                      |¦  «         t          |t          j        j        ¦  «        s|                      |¦  «        }t          |t          ¦  «        rt          |¦  «        }t          |t          ¦  «        st          |¦  «        dk    rÍ|r*t          |t          ¦  «        r||fn|d         |d         f}n¡|j        \  }}||k    r||fn||f\  }}	t          |t          ¦  «        r|n|d         }
||
k    r|S |
t          |
|	z  |z  ¦  «        }}|�8||
k    rt          d|› d|› �¦  «        ‚||k    rt          ||z  |z  ¦  «        |}}||k    r||fn||f}|                     ||¬¦  «        S )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`.
        Nr	   r   zmax_size = zN must be strictly greater than the requested size for the smaller edge size = )rù   )rú   ÚBILINEARr  r4   r5   r6   r  r^   rg   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(   r"  z"ImageFeatureExtractionMixin.resizeä  sÝ  € ð<  (Ð3�8�8Õ9KÔ9Tˆà×%Ò% eÑ,Ô,Ð,å˜%¥¤¤Ñ1Ô1ð 	-Ø×%Ò% eÑ,Ô,ˆEå�d�DÑ!Ô!ð 	Ý˜‘;”;ˆDå�d�CÑ Ô ð 	[¥C¨¡I¤I°¢N NØ ð [Ý'1°$½Ñ'<Ô'<ÐT˜˜d�|�|À4ÈÄ7ÈDÐQRÌGÐBT��à %¤
‘��và16¸&²°˜u f˜o˜oÀvÈuÀo‘��tÝ.8¸½sÑ.CÔ.CÐ&P d dÈÈaÌÐ#àÐ/Ò/Ð/Ø �Là&9½3Ð?RÐUYÑ?YÐ\aÑ?aÑ;bÔ;b˜8�	àÐ'ØÐ#6Ò6Ð6Ý(ðG¨(ð Gð GØ@DðGð Gñô ð ð   (Ò*Ð*Ý.1°(¸YÑ2FÈÑ2QÑ.RÔ.RÐT\ 8˜	à05¸²°˜	 8Ð,Ð,ÀhÐPYÐEZ�à�|Š|˜D¨8ˆ|Ñ4Ô4Ð4r'   c                 óV  — |                       |¦  «         t          |t          ¦  «        s||f}t          |¦  «        st          |t          j        ¦  «        rN|j        dk    r|                      |¦  «        }|j        d         dv r|j        dd…         n|j        dd…         }n|j	        d         |j	        d         f}|d         |d         z
  dz  }||d         z   }|d         |d         z
  dz  }||d         z   }t          |t          j        j        ¦  «        r|                     ||||f¦  «        S |j        d         dv }|sWt          |t          j        ¦  «        r|                     ddd¦  «        }t          |¦  «        r|                     ddd¦  «        }|dk    r-||d         k    r!|dk    r||d         k    r|d||…||…f         S |j        dd…         t          |d         |d         ¦  «        t          |d         |d         ¦  «        fz   }	t          |t          j        ¦  «        rt	          j        ||	¬¦  «        }
n$t          |¦  «        r|                     |	¦  «        }
|	d         |d         z
  dz  }||d         z   }|	d	         |d         z
  dz  }||d         z   }||
d||…||…f<   ||z  }||z  }||z  }||z  }|
dt          d|¦  «        t%          |
j        d         |¦  «        …t          d|¦  «        t%          |
j        d	         |¦  «        …f         }
|
S )
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  r4   rg   r   r_   r`   rw   r  r˜   rø   r5   r6   Úcropr  Úpermuterq   Ú
zeros_likeÚ	new_zerosrp   )r  rI   rø   Úimage_shapeÚtopÚbottomÚleftÚrightr  Ú	new_shapeÚ	new_imageÚtop_padÚ
bottom_padÚleft_padÚ	right_pads                  r(   Úcenter_cropz'ImageFeatureExtractionMixin.center_crop'  sd  € ð 	×%Ò% eÑ,Ô,Ð,å˜$¥Ñ&Ô&ð 	 Ø˜$�<ˆDõ ˜5Ñ!Ô!ð 	9¥Z°µr´zÑ%BÔ%Bð 	9ØŒz˜QŠˆØ×(Ò(¨Ñ/Ô/�Ø-2¬[¸¬^¸vÐ-EÐ-E˜%œ+ a b bœ/˜/È5Ì;ÐWYÐXYÐWYÌ?ˆKˆKà œ: aœ=¨%¬*°Q¬-Ð8ˆKà˜1Œ~  Q¤Ñ'¨AÑ-ˆØ�t˜A”w‘ˆØ˜A”  a¤Ñ(¨QÑ.ˆØ�t˜A”w‘ˆõ �e�SœYœ_Ñ-Ô-ð 	:Ø—:’:˜t S¨%°Ð8Ñ9Ô9Ð9ð œ Aœ¨&Ð0ˆð ð 	/Ý˜%¥¤Ñ,Ô,ð 1ØŸš¨¨1¨aÑ0Ô0�Ý˜uÑ%Ô%ð /ØŸš a¨¨AÑ.Ô.�ð �!Š8ˆ8˜ +¨a¤.Ò0Ð0°T¸Q²Y°YÀ5ÈKÐXYÌNÒCZÐCZØ˜˜c &˜j¨$¨u¨*Ð4Ô5Ð5ð ”K   Ô$­¨D°¬G°[À´^Ñ(DÔ(DÅcÈ$ÈqÌ'ÐS^Ð_`ÔSaÑFbÔFbÐ'cÑcˆ	Ý�e�RœZÑ(Ô(ð 	3Ýœ e°9Ð=Ñ=Ô=ˆIˆIÝ˜UÑ#Ô#ð 	3ØŸš¨	Ñ2Ô2ˆIà˜R”= ;¨q¤>Ñ1°aÑ7ˆØ˜{¨1œ~Ñ-ˆ
Ø˜b”M K°¤NÑ2°qÑ8ˆØ˜{¨1œ~Ñ-ˆ	ØAFˆ	�#�w˜zÐ)¨8°IÐ+=Ð=Ñ>àˆw‰ˆØ�'ÑˆØ�ÑˆØ�ÑˆàØ•�Q˜‘”�s 9¤?°2Ô#6¸Ñ?Ô?Ð?ÅÀQÈÁÄÕPSÐT]ÔTcÐdfÔTgÐinÑPoÔPoÐAoÐoô
ˆ	ð Ðr'   c                 ó¸   — |                       |¦  «         t          |t          j        j        ¦  «        r|                      |¦  «        }|ddd…dd…dd…f         S )a   
        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  r4   r5   r6   r�   r  s     r(   Úflip_channel_orderz.ImageFeatureExtractionMixin.flip_channel_orderr  s`   € ð 	×%Ò% eÑ,Ô,Ð,å�e�SœYœ_Ñ-Ô-ð 	/Ø×'Ò'¨Ñ.Ô.ˆEà�T�T�r�T˜1˜1˜1˜a˜a˜a�ZÔ Ð r'   r   c                 óô   — |�|nt           j        j        }|                      |¦  «         t	          |t           j        j        ¦  «        s|                      |¦  «        }|                     ||||||¬¦  «        S )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`.
        N)rù   ÚexpandÚcenterÚ	translateÚ	fillcolor)r5   r6   ÚNEARESTr  r4   r  Úrotate)r  rI   Úanglerù   r>  r?  r@  rA  s           r(   rC  z"ImageFeatureExtractionMixin.rotateƒ  s}   € ð  (Ð3�8�8½¼Ô9Jˆà×%Ò% eÑ,Ô,Ð,å˜%¥¤¤Ñ1Ô1ð 	-Ø×%Ò% eÑ,Ô,ˆEà�|Š|Ø˜H¨V¸FÈiÐclð ñ 
ô 
ð 	
r'   r3   )NT)F)NTN)Nr   NNN)r!   r"   r#   Ú__doc__r  r  r  r_   r`   r   r  r—   r  r�   r  r  r"  r:  r<  rC  r&   r'   r(   rÿ   rÿ   =  s  € € € € € ðð ðð ð ðð ð ð ð<$ð $ð $ð˜RœZð °°e¸S°jÔ0Að ÀbÄjð ð ð ð ðð ð ð ð@ð ð ð(2(ð 2(ð 2(ð 2(ðhA5ð A5ð A5ð A5ðFIð Ið IðV!ð !ð !ð"
ð 
ð 
ð 
ð 
ð 
r'   rÿ   Úannotation_formatÚsupported_annotation_formatsc                 óö   — | |vrt          dt          › d|› �¦  «        ‚| t          j        u rt	          |¦  «        st          d¦  «        ‚| t          j        u rt          |¦  «        st          d¦  «        ‚d S d S )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*   r-   rÆ   r.   rÉ   )rF  rG  r·   s      r(   Úvalidate_annotationsrJ  œ  s²   € ð
 Ð <Ð<Ð<ÝÐq½6ÐqÐqÐSoÐqÐqÑrÔrÐràÕ,Ô;Ð;Ð;Ý/°Ñ<Ô<ð 	ÝðBñô ð ð Õ,Ô:Ð:Ð:Ý.¨{Ñ;Ô;ð 	ÝðMñô ð ð ;Ð:ð	ð 	r'   Úvalid_processor_keysÚcaptured_kwargsc                 óÒ   — t          |¦  «                             t          | ¦  «        ¦  «        }|r5d                     |¦  «        }t                               d|› d�¦  «         d S d S )Nz, zUnused or unrecognized kwargs: rv   )ÚsetÚ
differenceÚjoinr™   rš   )rK  rL  Úunused_keysÚunused_key_strs       r(   Úvalidate_kwargsrS  µ  sp   € Ý�oÑ&Ô&×1Ò1µ#Ð6JÑ2KÔ2KÑLÔL€KØð LØŸš ;Ñ/Ô/ˆå�ŠÐJ¸ÐJÐJÐJÑKÔKÐKÐKÐKðLð Lr'   T)Úfrozenc                   ó¶   — e Zd ZU dZdZee         ed<   dZee         ed<   dZ	ee         ed<   dZ
ee         ed<   dZee         ed<   dZee         ed<   d	„ ZdS )
ÚSizeDictz>
    Hashable dictionary to store image size information.
    Nr¬   r­   Úlongest_edgeÚshortest_edger©   rª   c                 óh   — t          | |¦  «        rt          | |¦  «        S t          d|› d�¦  «        ‚)NzKey z not found in SizeDict.)ÚhasattrÚgetattrÚKeyError)r  Úkeys     r(   Ú__getitem__zSizeDict.__getitem__Ê  s>   € Ý�4˜ÑÔð 	&Ý˜4 Ñ%Ô%Ð%ÝÐ:˜cÐ:Ð:Ð:Ñ;Ô;Ð;r'   )r!   r"   r#   rE  r¬   r   r—   Ú__annotations__r­   rW  rX  r©   rª   r^  r&   r'   r(   rV  rV  ½  s©   € € € € € € ðð ð !€FˆH�SŒMÐ Ð Ñ Ø€Eˆ8�CŒ=ÐÐÑØ"&€L�(˜3”-Ð&Ð&Ñ&Ø#'€M�8˜C”=Ð'Ð'Ñ'Ø $€J�˜”Ð$Ð$Ñ$Ø#€Iˆx˜Œ}Ð#Ð#Ñ#ð<ð <ð <ð <ð <r'   rV  )rs   r3   )NNNNNNNNNNNNN)drÛ   r×   Úcollections.abcr   Údataclassesr   Úior   Útypingr   r   r>   r_   rÔ   Ú	packagingr   Úutilsr
   r   r   r   r   r   r   r   r   r   r   r   Úutils.constantsr   r   r   r   r   r   Ú	PIL.Imager5   ÚPIL.ImageOpsÚparseÚ__version__Úbase_versionr6   Ú
Resamplingrú   Útorchvision.transformsr   rB  ÚNEAREST_EXACTÚBOXr!  ÚHAMMINGÚBICUBICÚLANCZOSÚpil_torch_interpolation_mappingr=   Ú
get_loggerr!   r™   r`   r^   Ú
ImageInputr   r*   r0   r¹   rÑ   r—   ÚAnnotationTyper9   r;   rJ   rL   rU   re   rh   rk   Úboolrr   ry   rˆ   r�   r�   rg   r�   r¡   r§   r³   r¼   rÀ   rÆ   rÉ   r  rÐ   rí   rý   rÿ   rJ  rS  rV  r&   r'   r(   ú<module>rx     s4
  ðð €€€Ø 	€	€	€	Ø $Ð $Ð $Ð $Ð $Ð $Ø !Ð !Ð !Ð !Ð !Ð !Ø Ð Ð Ð Ð Ð Ø "Ð "Ð "Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ø €€€Ø Ð Ð Ð Ð Ð ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ÐÑÔð -ØÐÐÐØÐÐÐà€w„}�]�W”] 3¤?Ñ3Ô3Ô@ÑAÔAÀ]ÀWÄ]ÐSZÑE[ÔE[Ò[Ð[Ø œYÔ1ÐÐà œYÐàÐÑ!Ô!ð -Ø<Ð<Ð<Ð<Ð<Ð<ð Ô&Ø*Ð*Ñ,Ô,ð)+Ð(9Ô(GÐ(Gà"Ô*ØÔ"Ð$5Ô$9ØÔ'Ð):Ô)CØÔ&Ð(9Ô(AØÔ&Ð(9Ô(AØÔ&Ð(9Ô(Að	+
Ð'Ð'ð +-Ð'ð ÐÑÔð Ø€L€L€Lð 
ˆÔ	˜HÑ	%Ô	%€ð Ø�r”z >°4Ð8IÔ3JÈDÐQSÔQ[ÔL\Ð^bÐcqÔ^rÐrô€
ð
ð ð ð ð �|ñ ô ð ð
$ð $ð $ð $ð $�|ñ $ô $ð $ð
9ð 9ð 9ð 9ð 9�\ñ 9ô 9ð 9ð
 �c˜5  c¨4°¬:Ð!5Ô6Ð6Ô7€ðFð Fð Fðð ð ð ð �ñ ô ð ð?ð ?ð ?ðwð wð wðE Dð Eð Eð Eð Eð,ð ,ð ,ð	ð 	ð 	ðð ð ð5˜2œ:ð 5¨$ð 5ð 5ð 5ð 5ð$ð $°ð $¸DÀÔ<Lð $ð $ð $ð $ðR ð#Lð #LØ�$�zÔ" JÐ.Ô/ð#Làð#Lð ð#Lð #Lð #Lð #LðP ð$vð $vØ�$�zÔ" JÐ.Ô/ð$vàð$vð ð$vð $vð $vð $vðN˜2œ:ð ð ð ð ð NRð$Að $AØŒ:ð$AØ%-¨e°C¸¸sÀC¸x¼Ð4HÔ.IÔ%Jð$Aàð$Að $Að $Að $AðP TXðFð FØŒ:ðFØ*2°5Ð9IÈ3Ð9NÔ3OÔ*PðFàðFð Fð Fð Fð0Dð D˜"œ*ð DÐ3Cð DÈuÐUXÐZ]ÐU]Ìð Dð Dð Dð Dð0!Ø�c˜3�h”ð!àð!ð ð!ð ˆ3�ˆ8„_ð	!ð !ð !ð !ð>°4¸¸UÀ4ÈÀ;Ô=OÐ8OÔ3Pð ÐUYð ð ð ð ð°$°s¸EÀ$ÈÀ+Ô<NÐ7NÔ2Oð ÐTXð ð ð ð ð O°(¸4ÀÀUÈ4ÐQVÈ;ÔEWÐ@WÔ;XÔ2Yð OÐ^bð Oð Oð Oð OðN°¸$¸sÀEÈ$ÐPUÈ+ÔDVÐ?VÔ:WÔ1Xð NÐ]að Nð Nð Nð Nð)ð )�e˜CÐ!2Ð2Ô3ð )¸hÀu¼oð )ÐYjð )ð )ð )ð )ðZ TXð3ð 3Ø�$˜˜sÐ$5Ð5Ô6ð3ØAIÈ%Äð3à
Ð˜dÐ#4Ô5°t¸DÐARÔ<SÔ7TÐTÔUð3ð 3ð 3ð 3ð, "&Ø&*Ø#'Ø6:Ø59Ø!Ø'+Ø%)Ø*.Ø $Ø%)Ø/3Ø37ð,lð ,lØ˜”ð,là˜U”Oð,lð ˜4”.ð,lð ˜˜u d¨5¤kÐ1Ô2Ô3ð	,lð
 ˜˜e T¨%¤[Ð0Ô1Ô2ð,lð �TŒNð,lð   ”}ð,lð ˜T”Nð,lð ˜˜S #˜XœÔ'ð,lð ˜Œ~ð,lð �4˜˜S˜”>Ô
"ð,lð Ð+Ô,ð,lð Ð/Ô0ð,lð ,lð ,lð ,lð`\
ð \
ð \
ð \
ð \
ñ \
ô \
ð \
ð~
Ø'ðà"'Ð(8¸#Ð(=Ô">ðð �d”ðð 
ð	ð ð ð ð2L¨$¨s¬)ð LÀdÈ3Äið Lð Lð Lð Lð €�$ÐÑÔð<ð <ð <ð <ð <ñ <ô <ñ Ôð<ð <ð <r'   