§
    ‚Štj±¢  ã                   óž  — d dl Z d dlZd dlmZ d dlmZ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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 dd	l m!Z!  e¦   «         rd dl"Z#d dl$Z#e#j%        j&        Z' e¦   «         r}d d
l(m)Z)m*Z* d dl+m,Z, d dl-m.Z. e'j/        e,j0        e'j1        e,j1        e'j2        e,j2        e'j3        e,j3        e'j4        e,j4        e'j5        e,j5        iZ6d„ e6 7                    ¦   «         D ¦   «         Z8ni Z6i Z8 e¦   «         rd dl9Z9 ej:        e;¦  «        Z<edej=        de>d         e>ej=                 e>d         f         Z? G d„ de¦  «        Z@ G d„ de¦  «        ZAeBeCeDeCz  e>eB         z  f         ZEd„ ZF G d„ de¦  «        ZGd„ ZHd„ ZIde>fd„ZJd„ ZKd„ ZLd„ ZMdej=        deNfd „ZOdZd"eDde>e?         fd#„ZP	 dZde>e?         e?z  d"eDde?fd$„ZQ	 dZde>e?         e?z  d"eDde>e?         fd%„ZRdej=        fd&„ZS	 d[dej=        d'eDeTeDd(f         z  dz  de@fd)„ZUd[dej=        d*e@eCz  dz  deDfd+„ZVd[dej=        d,e@dz  deTeDeDf         fd-„ZWd.eTeDeDf         d/eDd0eDdeTeDeDf         fd1„ZXd2ee
         de>e
         fd3„ZYe@jZ        fde>edej=        f                  d*eCe@z  de>eD         fd4„Z[d5eBeCe>eTz  f         deNfd6„Z\d5eBeCe>eTz  f         deNfd7„Z]d8eeBeCe>eTz  f                  deNfd9„Z^d8eeBeCe>eTz  f                  deNfd:„Z_	 d[deeCdf         d;e`dz  ddfd<„Za e!d=¬>¦  «        	 d[deeCdf         d;e`dz  ddfd?„¦   «         Zb	 d[dee>eTeCdf         d;e`dz  dede>d         e>e>d                  f         fd@„Zc	 	 	 	 	 	 	 	 	 	 	 	 d\dAeNdz  dBe`dz  dCeNdz  dDe`e>e`         z  dz  dEe`e>e`         z  dz  dFeNdz  dGeBeCeDf         eDz  dz  dHeNdz  dIeBeCeDf         dz  dJeNdz  dKeBeCeDf         dz  dLedMdNeDf         dz  fdO„Zd G dP„ dQ¦  «        ZedReAdSeTeAd(f         d8e>eB         ddfdT„ZfdUe>eC         dVe>eC         fdW„Zg e¦   «          G dX„ dY¦  «        ¦   «         ZhdS )]é    N)ÚIterable)Ú	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_tensorc                 ó   — i | ]\  }}||“Œ	S © r   )Ú.0ÚkÚvs      úV/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/transformers/image_utils.pyú
<dictcomp>r$   C   s   € Ð&`Ð&`Ð&`±°°1 q¨!Ð&`Ð&`Ð&`ó    zPIL.Image.Imageztorch.Tensorc                   ó   — e Zd ZdZdZdS )ÚChannelDimensionÚchannels_firstÚchannels_lastN)Ú__name__Ú
__module__Ú__qualname__ÚFIRSTÚLASTr   r%   r#   r'   r'   U   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#   r0   r0   Z   s   € € € € € Ø%€NØ#€M€M€Mr%   r0   c                 ó\   — t          ¦   «         ot          | t          j        j        ¦  «        S ©N)r   Ú
isinstanceÚPILÚImage©Úimgs    r#   Úis_pil_imager<   b   s!   € ÝÑ Ô ÐE¥Z°µS´Y´_Ñ%EÔ%EÐEr%   c                   ó   — e Zd ZdZdZdZdS )Ú	ImageTypeÚpillowÚtorchÚnumpyN)r*   r+   r,   r8   ÚTORCHÚNUMPYr   r%   r#   r>   r>   f   s   € € € € € Ø
€CØ€EØ€E€E€Er%   r>   c                 óâ   — t          | ¦  «        rt          j        S t          | ¦  «        rt          j        S t          | ¦  «        rt          j        S t          dt          | ¦  «        › �¦  «        ‚)NzUnrecognized image type )	r<   r>   r8   r   rB   r   rC   Ú
ValueErrorÚtype©Úimages    r#   Úget_image_typerI   l   sg   € Ý�EÑÔð ÝŒ}ÐÝ�uÑÔð ÝŒÐÝ�eÑÔð ÝŒÐÝ
Ð=µ°U±´Ð=Ð=Ñ
>Ô
>Ð>r%   c                 ó\   — t          | ¦  «        pt          | ¦  «        pt          | ¦  «        S r6   )r<   r   r   r:   s    r#   Úis_valid_imagerK   v   s*   € Ý˜ÑÔÐK¥¨sÑ 3Ô 3ÐKµÀsÑ7KÔ7KÐKr%   Úimagesc                 ó8   — | ot          d„ | D ¦   «         ¦  «        S )Nc              3   ó4   K  — | ]}t          |¦  «        V — Œd S r6   )rK   ©r    rH   s     r#   ú	<genexpr>z*is_valid_list_of_images.<locals>.<genexpr>{   s*   è è € ÐDÐD°E�.¨Ñ/Ô/ÐDÐDÐDÐDÐDÐDr%   ©Úall)rL   s    r#   Úis_valid_list_of_imagesrS   z   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   )r    ÚsublistÚitems      r#   ú
<listcomp>z$concatenate_list.<locals>.<listcomp>€   s%   € ÐCÐCÐC˜¸7ÐCÐC°4�ÐCÐCÐCÐCr%   ©Úaxis)Údim)r7   ÚlistÚnpÚndarrayÚconcatenater@   ÚTensorÚcat)Ú
input_lists    r#   Úconcatenate_listrc   ~   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)r7   r\   ÚtupleÚvalid_imagesrK   )Úimgsr;   s     r#   rf   rf   ‡   sd   € å�$��u˜Ñ&Ô&ð Øð 	ð 	ˆCÝ Ñ$Ô$ð Ø�u�uðð	õ ˜DÑ!Ô!ð ØˆuØˆ4r%   c                 óh   — t          | t          t          f¦  «        rt          | d         ¦  «        S dS )Nr   F)r7   r\   re   rK   r:   s    r#   Ú
is_batchedri   “   s/   € Ý�#��e�}Ñ%Ô%ð &Ý˜c !œfÑ%Ô%Ð%Øˆ5r%   rH   Ú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ÚmaxrG   s    r#   Úis_scaled_imagerp   ™   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 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 ú.)ri   r<   rK   Úndimr\   rE   rF   ©rL   rr   s     r#   Úmake_list_of_imagesrw   ¤   sñ   € õ �&ÑÔð Øˆõ �FÑÔð àˆxˆå�fÑÔð ØŒ;˜.¨1Ñ,Ò,Ð,å˜&‘\”\ˆFˆFØŒ[˜NÒ*Ð*à�XˆFˆFåð.¸ÈÑ8Jð .ð .ÐP^ð .ð .Ø”Kð.ð .ð .ñô ð ð ˆÝ
ØwÕhlÐmsÑhtÔhtÐwÐwÐwñô ð 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 r6   ©r7   r\   re   ©r    Úimages_is     r#   rP   z+make_flat_list_of_images.<locals>.<genexpr>Ü   ó0   è è € ÐKÐK¸•
˜8¥d­E ]Ñ3Ô3ÐKÐKÐKÐKÐKÐKr%   c              3   ó:   K  — | ]}t          |¦  «        p| V — Œd S r6   ©rS   r{   s     r#   rP   z+make_flat_list_of_images.<locals>.<genexpr>Ý   ó2   è è € ÐYÐYÀhÕ'¨Ñ1Ô1ÐA¸°\ÐYÐYÐYÐYÐYÐYr%   c                 ó   — g | ]	}|D ]}|‘ŒŒ
S r   r   ©r    Úimg_listr;   s      r#   rX   z,make_flat_list_of_images.<locals>.<listcomp>ß   s%   € Ð?Ð?Ð?˜°hÐ?Ð?¨s�Ð?Ð?Ð?Ð?r%   r   r	   c                 ó   — g | ]	}|D ]}|‘ŒŒ
S r   r   r‚   s      r#   rX   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 ©	r7   r\   re   rR   rS   r<   ru   rK   rE   rv   s     r#   Úmake_flat_list_of_imagesr†   Ê   sX  € õ" 	�6�D¥%˜=Ñ)Ô)ð@åÐKÐKÀFÐKÑKÔKÑKÔKð@õ ÐYÐYÐRXÐYÑYÔYÑYÔYð@ð
 @Ð? 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 r6   rz   r{   s     r#   rP   z-make_nested_list_of_images.<locals>.<genexpr>  r}   r%   c              3   ó:   K  — | ]}t          |¦  «        p| V — Œd S r6   r   r{   s     r#   rP   z-make_nested_list_of_images.<locals>.<genexpr>  r€   r%   r   r	   c                 ó,   — g | ]}t          |¦  «        ‘ŒS r   )r\   rO   s     r#   rX   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…   rv   s     r#   Úmake_nested_list_of_imagesr‹   ð   sF  € õ  	�6�D¥%˜=Ñ)Ô)ðåÐKÐKÀFÐKÑKÔKÑKÔKðõ ÐYÐYÐRXÐYÑYÔYÑYÔYðð
 ˆõ �&�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: )
rK   rE   rF   r   r7   r8   r9   r]   Úarrayr   r:   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	   rq   rq   )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   rE   ÚshapeÚloggerÚwarningr'   r-   r.   )rH   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.
    Nrq   r	   úUnsupported data format: )r›   r'   r-   ru   r.   rE   )rH   rœ   s     r#   Úget_channel_dimension_axisrŸ   G  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.   rE   )rH   r    s     r#   Úget_image_sizer¥   ]  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.
    )rn   r•   )
r¦   r§   r¨   ÚheightÚwidthÚheight_scaleÚwidth_scaleÚ	min_scaleÚ
new_heightÚ	new_widths
             r#   Ú#get_image_size_for_max_height_widthr±   u  s_   € ð, �M€FˆEØ Ñ&€LØ˜eÑ#€KÝ�L +Ñ.Ô.€IÝ�V˜iÑ'Ñ(Ô(€JÝ�E˜IÑ%Ñ&Ô&€IØ�yÐ Ð r%   Úvaluesc                 ó(   — d„ t          | Ž D ¦   «         S )zO
    Return the maximum value across all indices of an iterable of values.
    c                 ó,   — g | ]}t          |¦  «        ‘ŒS r   )ro   )r    Úvalues_is     r#   rX   z&max_across_indices.<locals>.<listcomp>˜  s   € Ð7Ð7Ð7˜h�C�‰MŒMÐ7Ð7Ð7r%   )Úzip)r²   s    r#   Úmax_across_indicesr·   ”  s   € ð 8Ð7­#¨v¨,Ð7Ñ7Ô7Ð7r%   c                 óæ   — |t           j        k    rt          d„ | D ¦   «         ¦  «        \  }}}n@|t           j        k    rt          d„ | D ¦   «         ¦  «        \  }}}nt	          d|› �¦  «        ‚||fS )zH
    Get the maximum height and width across all images in a batch.
    c                 ó   — g | ]	}|j         ‘Œ
S r   ©r–   ©r    r;   s     r#   rX   z(get_max_height_width.<locals>.<listcomp>¢  ó   € Ð6SÐ6SÐ6SÀS°s´yÐ6SÐ6SÐ6Sr%   c                 ó   — g | ]	}|j         ‘Œ
S r   rº   r»   s     r#   rX   z(get_max_height_width.<locals>.<listcomp>¤  r¼   r%   z"Invalid channel dimension format: )r'   r-   r·   r.   rE   )rL   rœ   Ú_r§   r¨   s        r#   Úget_max_height_widthr¿   ›  s�   € ð Õ,Ô2Ò2Ð2Ý#5Ð6SÐ6SÈFÐ6SÑ6SÔ6SÑ#TÔ#TÑ ˆˆ:�y�yØ	Õ.Ô3Ò	3Ð	3Ý#5Ð6SÐ6SÈFÐ6SÑ6SÔ6SÑ#TÔ#TÑ ˆ
�I˜q˜qåÐQÐ>OÐQÐQÑRÔRÐRØ˜	Ð"Ð"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©r7   Údictr\   re   Ú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 r6   )rÈ   ©r    Úanns     r#   rP   z3valid_coco_detection_annotations.<locals>.<genexpr>Ê  s+   è è € ÐNÐN¸3Õ1°#Ñ6Ô6ÐNÐNÐNÐNÐNÐNr%   rQ   ©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 r6   )rÌ   rÏ   s     r#   rP   z2valid_coco_panoptic_annotations.<locals>.<genexpr>Î  s+   è è € ÐMÐM¸#Õ0°Ñ5Ô5ÐMÐMÐMÐMÐMÐMr%   rQ   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¦  «        rHt
          j                             t          t          j
        | |d¬¦  «        j        ¦  «        ¦  «        } �nt          j                             | ¦  «        r t
          j                             | ¦  «        } nÙ|                      d¦  «        r|                      d¦  «        d         } 	 t!          j        |                      ¦   «         ¦  «        }t
          j                             t          |¦  «        ¦  «        } nU# t&          $ r}t)          d	| › d
|› �¦  «        ‚d}~ww xY wt          | t
          j        j        ¦  «        s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.
    Ú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Ú	ExceptionrE   Ú	TypeErrorÚImageOpsÚexif_transposeÚconvert)rH   rÖ   Úb64Úes       r#   râ   râ   Ñ  sÐ  € õ  •j 8 *Ñ-Ô-Ð-Ý�%�ÑÔñ 
Ø×Ò˜IÑ&Ô&ð 	¨%×*:Ò*:¸:Ñ*FÔ*Fð 	õ ”I—N’N¥7­5¬9°UÀGÐ^bÐ+cÑ+cÔ+cÔ+kÑ#lÔ#lÑmÔmˆE‰EÝŒW�^Š^˜EÑ"Ô"ð 	Ý”I—N’N 5Ñ)Ô)ˆEˆEà×Ò Ñ.Ô.ð ,ØŸš CÑ(Ô(¨Ô+�ðÝÔ(¨¯ª©¬Ñ8Ô8�Ýœ	Ÿš¥w¨s¡|¤|Ñ4Ô4��øÝð ð ð Ý ð Bð  joð  Bð  Bð  @ð  Bð  Bñô ð øøøøðøøøõ ˜�sœyœÑ/Ô/ð 
Ýð Dñ
ô 
ð 	
õ ŒL×'Ò'¨Ñ.Ô.€EØ�MŠM˜%Ñ Ô €EØ€Ls   ÄAE" Å"
FÅ,FÆF)Útorchvision)Úbackendsc                 ó  — ddl }t          | t          ¦  «        �r}|                      d¦  «        s|                      d¦  «        r[t	          j        | |d¬¦  «        j        } |j        t          |¦  «        |j	        ¬¦  «        }t          |t          j        ¬¦  «        S t          j                             | ¦  «        rt          | t          j        ¬¦  «        S |                      d	¦  «        r|                      d
¦  «        d         } 	 t#          j        |                      ¦   «         ¦  «        }n'# t(          $ r}t+          d| › d|› �¦  «        ‚d}~ww xY w |j        t          |¦  «        |j	        ¬¦  «        }t          |t          j        ¬¦  «        S t          | t,          j        j        ¦  «        rAt,          j                             | ¦  «        } t5          |                      d¦  «        ¦  «        S t9          d¦  «        ‚)at  
    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Û   )rl   )Ú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.)r@   r7   rã   rä   ræ   rç   rè   Ú
frombufferÚ	bytearrayrm   r   r   rá   ré   rê   rë   rì   rí   rî   rï   rð   rE   r8   r9   rò   ró   r   rô   rñ   )rH   rÖ   r@   ÚrawÚbufrö   s         r#   Úload_image_as_tensorrÿ   þ  sý  € ð" €L€L€Lå�%�ÑÔñ 
Ø×Ò˜IÑ&Ô&ð 	=¨%×*:Ò*:¸:Ñ*FÔ*Fð 	=Ý”)˜E¨7ÀTÐJÑJÔJÔRˆCØ"�%Ô"¥9¨S¡>¤>¸¼ÐEÑEÔEˆCÝ ­-Ô*;Ð<Ñ<Ô<Ð<ÝŒW�^Š^˜EÑ"Ô"ð 	=Ý ­MÔ,=Ð>Ñ>Ô>Ð>à×Ò Ñ.Ô.ð ,ØŸš CÑ(Ô(¨Ô+�ðÝÔ(¨¯ª©¬Ñ8Ô8��øÝð ð ð Ý ð Bð  joð  Bð  Bð  @ð  Bð  Bñô ð øøøøðøøøð #�%Ô"¥9¨S¡>¤>¸¼ÐEÑEÔEˆCÝ ­-Ô*;Ð<Ñ<Ô<Ð<Ý	�E�3œ9œ?Ñ	+Ô	+ð 
Ý”×+Ò+¨EÑ2Ô2ˆÝ˜UŸ]š]¨5Ñ1Ô1Ñ2Ô2Ð2åØnñ
ô 
ð 	
s   Ä&D2 Ä2
EÄ<EÅE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â   ©r    rH   rÖ   s     €r#   rX   z*load_images.<locals>.<listcomp>.<listcomp>:  s&   ø€ ÐQÐQÐQ¸E•Z ¨wÐ7Ñ7Ô7ÐQÐQÐQr%   r   )r    Úimage_grouprÖ   s     €r#   rX   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#   rX   zload_images.<locals>.<listcomp><  s&   ø€ ÐKÐKÐK¸5•J˜u¨gÐ6Ñ6Ô6ÐKÐKÐKr%   r  )r7   r\   re   rÆ   râ   )rL   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Úpad_sizeÚdo_center_cropÚ	crop_sizeÚ	do_resizeÚsizeÚresampleÚPILImageResamplingr   c                 óÐ   — | r|€t          d¦  «        ‚|r|€t          d¦  «        ‚|r|�|€t          d¦  «        ‚|r|€t          d¦  «        ‚|	r|
�|€t          d¦  «        ‚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`.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`.)rE   )r
  r  r  r  r  r  r  r  r  r  r  r  s               r#   Úvalidate_preprocess_argumentsr  A  sº   € ð, ð Z�nÐ,ÝÐXÑYÔYÐYàð 	
�(Ð"õ Øuñ
ô 
ð 	
ð ð m˜Ð+¨yÐ/@ÝÐkÑlÔlÐlàð Y˜)Ð+ÝÐWÑXÔXÐXàð ^˜$Ð*¨xÐ/CÝÐ\Ñ]Ô]Ð]ð^ð ^Ð/CÐ/Cr%   c                   ó†   — e Zd ZdZd„ Zdd„Zd„ Zdej        de	e
z  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 zU which is not supported, only `PIL.Image.Image`, `np.ndarray` and `torch.Tensor` are.)r7   r8   r9   r]   r^   r   rE   rF   ©ÚselfrH   s     r#   Ú_ensure_format_supportedz4ImageFeatureExtractionMixin._ensure_format_supportedt  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   rq   r‘   r	   r’   éÿ   )r  r   rA   r7   r]   r^   ÚflatÚfloatingru   r–   Ú	transposeÚastyperm   r8   r9   Ú	fromarray)r  rH   Úrescales      r#   Úto_pil_imagez(ImageFeatureExtractionMixin.to_pil_image{  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  r7   r8   r9   rô   r  s     r#   Úconvert_rgbz'ImageFeatureExtractionMixin.convert_rgb™  sE   € ð 	×%Ò% eÑ,Ô,Ð,Ý˜%¥¤¤Ñ1Ô1ð 	ØˆLà�}Š}˜UÑ#Ô#Ð#r%   rH   Úscalerj   c                 ó6   — |                       |¦  «         ||z  S )z7
        Rescale a numpy image by scale amount
        )r  )r  rH   r*  s      r#   r&  z#ImageFeatureExtractionMixin.rescale§  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?rq   r’   r	   )r  r7   r8   r9   r]   r�   r   rA   r!  Úintegerr&  r$  Úfloat32ru   r#  )r  rH   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   rY   )r  r7   r8   r9   r   Ú	unsqueezer]   Úexpand_dimsr  s     r#   r3  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   Nrq   r‘   )r  r7   r8   r9   rŽ   r]   r^   r&  r$  r/  r   Úfloatr�   rl   r@   r`   Ú
from_numpyÚtensorru   r–   )r  rH   Ú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  r7   r8   r9   r'  r\   re   r•   rÆ   r  rE   Úresize)r  rH   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  r7   re   r   r]   r^   ru   r3  r–   r  r8   r9   Úcropr#  Úpermutero   Ú
zeros_likeÚ	new_zerosrn   )r  rH   r  Úimage_shapeÚtopÚbottomÚleftÚrightr0  Ú	new_shapeÚ	new_imageÚtop_padÚ
bottom_padÚleft_padÚ	right_pads                  r#   Úcenter_cropz'ImageFeatureExtractionMixin.center_cropY  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  r7   r8   r9   rŽ   r  s     r#   Úflip_channel_orderz.ImageFeatureExtractionMixin.flip_channel_order¤  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)r8   r9   ÚNEARESTr  r7   r'  Úrotate)r  rH   Úangler  rY  rZ  r[  r\  s           r#   r^  z"ImageFeatureExtractionMixin.rotateµ  s}   € ð  (Ð3�8�8½¼Ô9Jˆà×%Ò% eÑ,Ô,Ð,å˜%¥¤¤Ñ1Ô1ð 	-Ø×%Ò% eÑ,Ô,ˆEà�|Š|Ø˜H¨V¸FÈiÐclð ñ 
ô 
ð 	
r%   r6   )NT)F)NTN)Nr   NNN)r*   r+   r,   Ú__doc__r  r'  r)  r]   r^   r5  r•   r&  rŽ   r3  r:  r=  rU  rW  r^  r   r%   r#   r  r  o  s	  € € € € € ðð ðð ð ðð ð ð ð<$ð $ð $ð˜RœZð °¸±ð ÀÄ
ð ð ð ð ðð ð ð ð@ð ð ð(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.)rE   Úformatr0   r3   rÒ   r4   rÕ   )ra  rb  rÃ   s      r#   Úvalidate_annotationsre  Î  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: rt   )ÚsetÚ
differenceÚjoinr—   r˜   )rf  rg  Úunused_keysÚunused_key_strs       r#   Úvalidate_kwargsrn  ç  sp   € Ý�oÑ&Ô&×1Ò1µ#Ð6JÑ2KÔ2KÑLÔL€KØð LØŸš ;Ñ/Ô/ˆå�ŠÐJ¸ÐJÐJÐJÑKÔKÐKÐKÐKðLð Lr%   c                   óÌ   — e Zd ZU dZdZedz  ed<   dZedz  ed<   dZedz  ed<   dZ	edz  ed<   dZ
edz  ed<   dZedz  ed<   d	„ Zdd
„Zd„ Zd„ Zd„ Zd„ Zd„ Zdd„Zdef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�¦  «        ‚)NúKey z not found in SizeDict.)ÚhasattrÚgetattrÚKeyError©r  Úkeys     r#   Ú__getitem__zSizeDict.__getitem__ü  s>   € Ý�4˜ÑÔð 	&Ý˜4 Ñ%Ô%Ð%ÝÐ:˜cÐ:Ð:Ð:Ñ;Ô;Ð;r%   c                 óf   — t          | |¦  «        r t          | |¦  «        �t          | |¦  «        S |S r6   ©ru  rv  )r  ry  Údefaults      r#   rç   zSizeDict.get  s8   € Ý�4˜ÑÔð 	&¥'¨$°Ñ"4Ô"4Ð"@Ý˜4 Ñ%Ô%Ð%Øˆr%   c              #   ór   K  — t          | ¦  «        D ]$}t          | |j        ¦  «        }|�|j        |fV — Œ%d S r6   )r   rv  Úname)r  ÚfÚvals      r#   Ú__iter__zSizeDict.__iter__  sN   è è € å˜‘”ð 	"ð 	"ˆAÝ˜$ ¤Ñ'Ô'ˆCØˆØ”f˜c�kÐ!Ð!Ð!øð	"ð 	"r%   c                 óh   — t          | j        | j        | j        | j        | j        | j        f¦  «        S r6   )Úhashrª   r«   rq  rr  r§   r¨   )r  s    r#   Ú__hash__zSizeDict.__hash__  s/   € Ý�T”[ $¤*¨dÔ.?ÀÔASÐUYÔUdÐfjÔftÐuÑvÔvÐvr%   c                 óF   — t          | |¦  «        ot          | |¦  «        d uS r6   r|  rx  s     r#   Ú__contains__zSizeDict.__contains__  s&   € Ý�t˜SÑ!Ô!ÐD¥g¨d°CÑ&8Ô&8ÀÐ&DÐDr%   c                 ó„   — t          | |¦  «        st          d|› d�¦  «        ‚t                               | ||¦  «         d S )Nrt  z" is not a valid field of SizeDict.)ru  rw  ÚobjectÚ__setattr__)r  ry  Úvalues      r#   Ú__setitem__zSizeDict.__setitem__  sM   € Ý�t˜SÑ!Ô!ð 	KÝÐI #ÐIÐIÐIÑJÔJÐJÝ×Ò˜4  eÑ,Ô,Ð,Ð,Ð,r%   c                 ó2  ‡ ‡— t          ‰t          ¦  «        rt          ‰ ¦  «        ‰k    S t          ‰t          ¦  «        rRt          ˆ fd„t	          ‰ ¦  «        D ¦   «         ¦  «        t          ˆfd„t	          ‰ ¦  «        D ¦   «         ¦  «        k    S t
          S )Nc              3   óB   •K  — | ]}t          ‰|j        ¦  «        V — Œd S r6   ©rv  r  )r    r€  r  s     €r#   rP   z"SizeDict.__eq__.<locals>.<genexpr>  s/   øè è € ÐEÐE°1�  q¤vÑ.Ô.ÐEÐEÐEÐEÐEÐEr%   c              3   óB   •K  — | ]}t          ‰|j        ¦  «        V — Œd S r6   r�  )r    r€  Úothers     €r#   rP   z"SizeDict.__eq__.<locals>.<genexpr>  sH   øè è € ð Oð OØ+,•˜˜qœvÑ&Ô&ðOð Oð Oð Oð Oð Or%   )r7   rÅ   rp  re   r   ÚNotImplemented)r  r‘  s   ``r#   Ú__eq__zSizeDict.__eq__  s²   øø€ Ý�e�TÑ"Ô"ð 	'Ý˜‘:”: Ò&Ð&Ý�e�XÑ&Ô&ð 	ÝÐEÐEÐEÐE½¸t¹¼ÐEÑEÔEÑEÔEÍð Oð Oð Oð OÝ06°t±´ðOñ Oô Oñ Jô Jò ð õ Ðr%   rj   c                 óÄ   — t          |t          t          z  ¦  «        r=t          | ¦  «        }|                     t          |¦  «        ¦  «         t          di |¤ŽS t          S )Nr   )r7   rÅ   rp  Úupdater’  ©r  r‘  Úmergeds      r#   Ú__or__zSizeDict.__or__!  sU   € Ý�e�T¥H™_Ñ-Ô-ð 	&Ý˜$‘Z”ZˆFØ�MŠM�$˜u™+œ+Ñ&Ô&Ð&ÝÐ%Ð%˜fÐ%Ð%Ð%ÝÐr%   c                 ó    — t          |t          ¦  «        r3t          |¦  «        }|                     t          | ¦  «        ¦  «         |S t          S r6   )r7   rÅ   r•  r’  r–  s      r#   Ú__ror__zSizeDict.__ror__(  sB   € Ý�e�TÑ"Ô"ð 	Ý˜%‘[”[ˆFØ�MŠM�$˜t™*œ*Ñ%Ô%Ð%ØˆMÝÐr%   r6   )rj   rp  )r*   r+   r,   r`  rª   r•   Ú__annotations__r«   rq  rr  r§   r¨   rz  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Ð Ð Ñ ð<ð <ð <ð
ð ð ð ð
"ð "ð "ðwð wð wðEð Eð Eð-ð -ð -ð
ð ð ðð ð ð ð ð ð ð ð ð ð r%   rp  )rq   r6   )NNNNNNNNNNNN)irí   ré   Úcollections.abcr   Údataclassesr   r   Úior   Útypingr   r   ræ   rA   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ÚBOXr<  ÚHAMMINGÚBICUBICÚLANCZOSÚpil_torch_interpolation_mappingÚitemsÚtorch_pil_interpolation_mappingr@   Ú
get_loggerr*   r—   r^   r\   Ú
ImageInputr'   r0   rÅ   rã   r•   ÚAnnotationTyper<   r>   rI   rK   rS   rc   rf   ri   Úboolrp   rw   r†   r‹   rŽ   re   r›   rŸ   r¥   r±   r·   r-   r¿   rÈ   rÌ   rÒ   rÕ   r5  râ   rÿ   r	  r  r  re  rn  rp  r   r%   r#   ú<module>rµ     s£
  ðð €€€Ø 	€	€	€	Ø $Ð $Ð $Ð $Ð $Ð $Ø )Ð )Ð )Ð )Ð )Ð )Ð )Ð )Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ð Ð à €€€Ø Ð Ð Ð ð
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð )Ð (Ð (Ð (Ð (Ð (ð ÐÑÔð .ØÐÐÐØÐÐÐàœÔ-ÐàÐÑÔð )Ø:Ð:Ð:Ð:Ð:Ð:Ð:Ð:Ø8Ð8Ð8Ð8Ð8Ð8Ø?Ð?Ð?Ð?Ð?Ð?ð 	Ô"Ð$5Ô$CØÔÐ 1Ô 5ØÔ#Ð%6Ô%?ØÔ"Ð$5Ô$=ØÔ"Ð$5Ô$=ØÔ"Ð$5Ô$=ð'Ð#ð 'aÐ&`Ð8W×8]Ò8]Ñ8_Ô8_Ð&`Ñ&`Ô&`Ð#Ð#à&(Ð#Ø&(Ð#ð ÐÑÔð Ø€L€L€Lð 
ˆÔ	˜HÑ	%Ô	%€ð Ø�r”z >°4Ð8IÔ3JÈDÐQSÔQ[ÔL\Ð^bÐcqÔ^rÐrô€
ð
ð ð ð ð �|ñ ô ð ð
$ð $ð $ð $ð $�|ñ $ô $ð $ð
 �c˜3 ™9 t¨D¤zÑ1Ð1Ô2€ðFð Fð Fðð ð ð ð �ñ ô ð ð?ð ?ð ?ðLð Lð LðE Dð Eð Eð Eð Eð,ð ,ð ,ð	ð 	ð 	ðð ð ð5˜2œ:ð 5¨$ð 5ð 5ð 5ð 5ð#ð #°ð #¸DÀÔ<Lð #ð #ð #ð #ðP ð#Lð #LØ�Ô˜zÑ)ð#Làð#Lð ð#Lð #Lð #Lð #LðP ð$vð $vØ�Ô˜zÑ)ð$vàð$vð 
ˆ*Ôð$vð $vð $vð $vðN˜2œ:ð ð ð ð ð EIð$Að $AØŒ:ð$AØ%(¨5°°c°¬?Ñ%:¸TÑ%Að$Aàð$Að $Að $Að $AðNFð F b¤jð FÐEUÐX[ÑE[Ð^bÑEbð FÐnqð Fð Fð Fð Fð,Dð D˜"œ*ð DÐ3CÀdÑ3Jð DÐV[Ð\_ÐadÐ\dÔVeð Dð Dð Dð Dð0!Ø�c˜3�h”ð!àð!ð ð!ð ˆ3�ˆ8„_ð	!ð !ð !ð !ð>8˜x¨œ}ð 8°°c´ð 8ð 8ð 8ð 8ð brÔawð#ð #Ø��~ r¤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ð Oð Oð OðN°¸$¸sÀDÈ5ÁLÐ?PÔ:QÔ1Rð NÐW[ð Nð Nð Nð Nð !ð*ð *Ø�Ð'Ð'Ô(ð*à�T‰\ð*ð ð*ð *ð *ð *ðZ 
€Ð#Ð$Ñ$Ô$ð !ð*
ð *
Ø�Ð'Ð'Ô(ð*
à�T‰\ð*
ð ð*
ð *
ð *
ñ %Ô$ð*
ð\ QUð3ð 3Ø�$˜˜sÐ$5Ð5Ô6ð3ØAFÈÁð3à
Ð˜dÐ#4Ô5°t¸DÐARÔ<SÔ7TÐTÔUð3ð 3ð 3ð 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ð Lð Lð Lð €�„ð=ð =ð =ð =ð =ñ =ô =ñ „ð=ð =ð =r%   