o
    }ôjCz  ã                   @   s   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 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 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 'e 'e%j(¡j)¡e 'd¡krwe%j*j+Z,ne%j*Z,eƒ r�d d	l-m.Z. e,j/e.j/e,j0e.j0e,j1e.j1e,j2e.j2e,j3e.j3e,j4e.j4iZ5er¦eƒ r¦d dl6Z6e 7e8¡Z9ed
ej:ded
 eej: ed f Z;eed
 dded ed eed
  eed  eed  f Z<G dd„ deƒZ=G dd„ deƒZ>G dd„ deƒZ?ee@eeAe@ee f f ZBdd„ ZCG dd„ deƒZDdd„ ZEdd„ ZFdd„ ZGdd„ ZHd ej:d!eIfd"d#„ZJdZd%eAd!ee; fd&d'„ZKd!ej:fd(d)„ZL	d[d ej:d*e	eeAe
eAd+f f  d!e=fd,d-„ZM	d[d ej:d.e	ee=e@f  d!eAfd/d0„ZNd[d ej:d1e=d!e
eAeAf fd2d3„ZOd4ee@eee
f f d!eIfd5d6„ZPd4ee@eee
f f d!eIfd7d8„ZQd9eee@eee
f f  d!eIfd:d;„ZRd9eee@eee
f f  d!eIfd<d=„ZSd[d ee@d
f d>e	eT d!d
fd?d@„ZU												d\dAe	eI dBe	eT dCe	eI dDe	eeTeeT f  dEe	eeTeeT f  dFe	eI dGe	eA dHe	eI dIe	ee@eAf  dJe	eI dKe	ee@eAf  dLe	dM fdNdO„ZVG dPdQ„ dQƒZWdRe>dSe
e>d+f d9ee d!dfdTdU„ZXdVee@ dWee@ fdXdY„ZYdS )]é    N)ÚBytesIO)ÚTYPE_CHECKINGÚDictÚIterableÚListÚOptionalÚTupleÚUnion)Úversioné   )ÚExplicitEnumÚis_jax_tensorÚis_numpy_arrayÚis_tf_tensorÚ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_STDz9.1.0)ÚInterpolationModezPIL.Image.Imageztorch.Tensorz
np.ndarrayznp.ndarrrayc                   @   ó   e Zd ZdZdZdS )ÚChannelDimensionÚchannels_firstÚchannels_lastN)Ú__name__Ú
__module__Ú__qualname__ÚFIRSTÚLAST© r'   r'   úi/var/www/html/academy/tools/voices/clone/sv-venv/lib/python3.10/site-packages/transformers/image_utils.pyr   _   ó    r   c                   @   r   )ÚAnnotationFormatZcoco_detectionZcoco_panopticN)r"   r#   r$   ÚCOCO_DETECTIONÚCOCO_PANOPTICr'   r'   r'   r(   r*   d   r)   r*   c                   @   s   e Zd ZejjZejjZdS )ÚAnnotionFormatN)r"   r#   r$   r*   r+   Úvaluer,   r'   r'   r'   r(   r-   i   s    r-   c                 C   s   t ƒ o	t| tjjƒS ©N)r   Ú
isinstanceÚPILÚImage©Úimgr'   r'   r(   Úis_pil_imageq   s   r5   c                   @   s    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$   r1   ÚTORCHÚNUMPYÚ
TENSORFLOWÚJAXr'   r'   r'   r(   r6   u   s    r6   c                 C   sX   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Unrecognised image type )r5   r6   r1   r   r<   r   r=   r   r>   r   r?   Ú
ValueErrorÚtype©Úimager'   r'   r(   Úget_image_type}   s   rD   c                 C   s(   t | ƒpt| ƒpt| ƒpt| ƒpt| ƒS r/   )r5   r   r   r   r   r3   r'   r'   r(   Úis_valid_image‹   s   (rE   c                 C   s:   t | ttfƒr| D ]	}t|ƒs dS q	dS t| ƒsdS dS )NFT)r0   ÚlistÚtupleÚvalid_imagesrE   )Zimgsr4   r'   r'   r(   rH   �   s   ÿþrH   c                 C   s   t | ttfƒrt| d ƒS dS )Nr   F)r0   rF   rG   rE   r3   r'   r'   r(   Ú
is_batched›   s   rI   rC   Úreturnc                 C   s,   | j tjkrdS t | ¡dkot | ¡dkS )zV
    Checks to see whether the pixel values have already been rescaled to [0, 1].
    Fr   r   )ÚdtypeÚnpÚuint8ÚminÚmaxrB   r'   r'   r(   Úis_scaled_image¡   s   rP   é   Úexpected_ndimsc                 C   sŒ   t | ƒr| S t| tjjƒr| gS t| ƒr<| j|d kr!t| ƒ} | S | j|kr+| g} | S td|d › d|› d| j› d�ƒ‚tdt| ƒ› d�ƒ‚)a  
    Ensure that the input 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 Ú.)	rI   r0   r1   r2   rE   ÚndimrF   r@   rA   )ÚimagesrR   r'   r'   r(   Úmake_list_of_images¬   s*   	
øüÿÿÿÿrV   c                 C   s@   t | ƒstdt| ƒ› �ƒ‚tƒ rt| tjjƒrt | ¡S t	| ƒS )NzInvalid image type: )
rE   r@   rA   r   r0   r1   r2   rL   Úarrayr   r3   r'   r'   r(   Úto_numpy_arrayÓ   s
   
rX   Únum_channels.c                 C   sÂ   |dur|nd}t |tƒr|fn|}| jdkrd\}}n| jdkr&d\}}ntd| j› �ƒ‚| j| |v rI| j| |v rIt d| j› d�¡ tjS | j| |v rSt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   é   é   z(Unsupported number of image dimensions: z4The channel dimension is ambiguous. Got image shape z,. Assuming channels are the first dimension.z(Unable to infer channel dimension format)
r0   ÚintrT   r@   ÚshapeÚloggerÚwarningr   r%   r&   )rC   rY   Z	first_dimÚlast_dimr'   r'   r(   Úinfer_channel_dimension_formatÜ   s"   



ÿrb   Úinput_data_formatc                 C   sF   |du rt | ƒ}|tjkr| jd S |tjkr| jd 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: )rb   r   r%   rT   r&   r@   )rC   rc   r'   r'   r(   Úget_channel_dimension_axis  s   



re   Úchannel_dimc                 C   sZ   |du r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éþÿÿÿéÿÿÿÿéýÿÿÿrd   )rb   r   r%   r^   r&   r@   )rC   rf   r'   r'   r(   Úget_image_size  s   

rj   Ú
annotationc                 C   sV   t | tƒr)d| v r)d| 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©r0   ÚdictrF   rG   Úlen©rk   r'   r'   r(   Ú"is_valid_annotation_coco_detection1  s   ÿÿ"rr   c                 C   s^   t | tƒr-d| v r-d| v r-d| v r-t | d ttfƒr-t| d ƒdks+t | d d tƒr-dS dS )Nrl   Zsegments_infoÚ	file_namer   TFrn   rq   r'   r'   r(   Ú!is_valid_annotation_coco_panoptic@  s   ÿÿ"rt   rm   c                 C   ó   t dd„ | D ƒƒS )Nc                 s   ó   � | ]}t |ƒV  qd S r/   )rr   ©Ú.0Úannr'   r'   r(   Ú	<genexpr>Q  ó   € z3valid_coco_detection_annotations.<locals>.<genexpr>©Úall©rm   r'   r'   r(   Ú valid_coco_detection_annotationsP  ó   r   c                 C   ru   )Nc                 s   rv   r/   )rt   rw   r'   r'   r(   rz   U  r{   z2valid_coco_panoptic_annotations.<locals>.<genexpr>r|   r~   r'   r'   r(   Úvalid_coco_panoptic_annotationsT  r€   r�   Útimeoutc              
   C   s   t tdgƒ t| tƒre|  d¡s|  d¡r$tj tt	j
| |d�jƒ¡} nOtj | ¡r1tj | ¡} nB|  d¡r=|  d¡d } zt |  ¡ ¡}tj t|ƒ¡} W n$ tyd } z
td| › d	|› �ƒ‚d
}~ww t| tjjƒro| } 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_imager0   ÚstrÚ
startswithr1   r2   Úopenr   ÚrequestsÚgetÚcontentÚosÚpathÚisfileÚsplitÚbase64ÚdecodebytesÚencodeÚ	Exceptionr@   Ú	TypeErrorZImageOpsZexif_transposeÚconvert)rC   r‚   Úb64Úer'   r'   r(   r†   X  s2   

ÿ€ÿÿ
r†   Ú
do_rescaleÚrescale_factorÚdo_normalizeÚ
image_meanÚ	image_stdÚdo_padÚsize_divisibilityÚdo_center_cropÚ	crop_sizeÚ	do_resizeÚsizeÚresampleÚPILImageResamplingc                 C   s|   | r
|du r
t dƒ‚|r|du rt dƒ‚|r"|du s|du r"t dƒ‚|r,|du r,t dƒ‚|	r:|
du s6|du 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`.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`.zA`size` and `resample` must be specified if `do_resize` is `True`.)r@   )r™   rš   r›   rœ   r�   rž   rŸ   r    r¡   r¢   r£   r¤   r'   r'   r(   Úvalidate_preprocess_arguments„  s   ÿÿr¦   c                   @   sŒ   e Zd ZdZdd„ Zddd„Zdd„ Zd	ejd
e	e
ef dejfdd„Zd dd„Zdd„ Zd!dd„Zd"dd„Zdd„ Zdd„ Zd#dd„ZdS )$ÚImageFeatureExtractionMixinzD
    Mixin that contain utilities for preparing image features.
    c                 C   s8   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.)r0   r1   r2   rL   Úndarrayr   r@   rA   ©ÚselfrC   r'   r'   r(   Ú_ensure_format_supported³  s
   ÿÿz4ImageFeatureExtractionMixin._ensure_format_supportedNc                 C   sŽ   |   |¡ t|ƒr| ¡ }t|tjƒrE|du r t|jd tjƒ}|jdkr3|j	d dv r3| 
ddd¡}|r9|d }| 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   rZ   r   r[   éÿ   )r«   r   r9   r0   rL   r¨   ÚflatÚfloatingrT   r^   Ú	transposeÚastyperM   r1   r2   Ú	fromarray)rª   rC   Úrescaler'   r'   r(   Úto_pil_imageº  s   
z(ImageFeatureExtractionMixin.to_pil_imagec                 C   s&   |   |¡ 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«   r0   r1   r2   r–   r©   r'   r'   r(   Úconvert_rgbØ  s   

z'ImageFeatureExtractionMixin.convert_rgbrC   ÚscalerJ   c                 C   s   |   |¡ || S )z7
        Rescale a numpy image by scale amount
        )r«   )rª   rC   rµ   r'   r'   r(   r²   æ  s   
z#ImageFeatureExtractionMixin.rescaleTc                 C   sˆ   |   |¡ t|tjjƒrt |¡}t|ƒr| ¡ }|du r&t|jd tj	ƒn|}|r4|  
| tj¡d¡}|rB|jdkrB| 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«   r0   r1   r2   rL   rW   r   r9   r­   Úintegerr²   r°   Úfloat32rT   r¯   )rª   rC   r²   Úchannel_firstr'   r'   r(   rX   í  s   

z*ImageFeatureExtractionMixin.to_numpy_arrayc                 C   sD   |   |¡ t|tjjƒr|S t|ƒr| d¡}|S tj|d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   )Úaxis)r«   r0   r1   r2   r   Ú	unsqueezerL   Úexpand_dimsr©   r'   r'   r(   r¼     s   

ÿz'ImageFeatureExtractionMixin.expand_dimsFc                 C   sh  |   |¡ t|tjjƒr| j|dd�}n|r3t|tjƒr'|  | tj	¡d¡}nt
|ƒr3|  | ¡ d¡}t|tjƒrXt|tjƒsHt |¡ |j¡}t|tjƒsWt |¡ |j¡}n6t
|ƒrŽddl}t||jƒswt|tjƒrr| |¡}n| |¡}t||jƒsŽt|tjƒr‰| |¡}n| |¡}|jdkr®|jd dv r®||dd…ddf  |dd…ddf  S || | 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   rZ   )r«   r0   r1   r2   rX   rL   r¨   r²   r°   r¸   r   ÚfloatrW   rK   r8   ÚTensorÚ
from_numpyÚtensorrT   r^   )rª   rC   ÚmeanÚstdr²   r8   r'   r'   r(   Ú	normalize!  s6   
€

(z%ImageFeatureExtractionMixin.normalizec                 C   sJ  |dur|nt j}|  |¡ t|tjjƒs|  |¡}t|tƒr#t|ƒ}t|t	ƒs.t
|ƒdkrž|rBt|t	ƒr9||fn|d |d f}n\|j\}}||krO||fn||f\}}	t|t	ƒr\|n|d }
||
krf|S |
t	|
|	 | ƒ}}|dur’||
krƒtd|› d|› �ƒ‚||kr’t	|| | ƒ|}}||krš||fn||f}|j||d�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«   r0   r1   r2   r³   rF   rG   r]   rp   r£   r@   Úresize)rª   rC   r£   r¤   Údefault_to_squareÚmax_sizeÚwidthÚheightÚshortÚlongÚrequested_new_shortÚ	new_shortÚnew_longr'   r'   r(   rÅ   U  s4   


$
ÿÿz"ImageFeatureExtractionMixin.resizec                 C   s€  |   |¡ t|tƒs||f}t|ƒst|tjƒr8|jdkr"|  |¡}|jd dv r0|jdd… n|jdd… }n
|j	d |j	d f}|d |d  d }||d  }|d |d  d }||d  }t|t
jjƒrr| ||||f¡S |jd dv r{dnd}|s—t|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 }	t|tjƒrÝtj||	d
�}
n	t|ƒræ| |	¡}
|	d	 |d  d }||d  }|	d |d  d }||d  }||
d||…||…f< ||7 }||7 }||7 }||7 }|
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   rZ   r   NTF.rg   )r^   rh   )r«   r0   rG   r   rL   r¨   rT   r¼   r^   r£   r1   r2   Úcropr¯   ÚpermuterO   Ú
zeros_likeÚ	new_zerosrN   )rª   rC   r£   Úimage_shapeÚtopÚbottomÚleftÚrightr¹   Ú	new_shapeÚ	new_imageÚtop_padÚ
bottom_padÚleft_padÚ	right_padr'   r'   r(   Úcenter_crop˜  sP   



,(2
4ÿz'ImageFeatureExtractionMixin.center_cropc                 C   s>   |   |¡ 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.
        Nrh   )r«   r0   r1   r2   rX   r©   r'   r'   r(   Úflip_channel_orderã  s   


z.ImageFeatureExtractionMixin.flip_channel_orderr   c                 C   sL   |dur|nt jj}|  |¡ t|t jjƒs|  |¡}|j||||||d�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)r1   r2   ÚNEARESTr«   r0   r³   Úrotate)rª   rC   Úangler¤   rà   rá   râ   rã   r'   r'   r(   rå   ô  s   

ÿz"ImageFeatureExtractionMixin.rotater/   )NT)F)NTN)Nr   NNN)r"   r#   r$   Ú__doc__r«   r³   r´   rL   r¨   r	   r½   r]   r²   rX   r¼   rÃ   rÅ   rÞ   rß   rå   r'   r'   r'   r(   r§   ®  s    
"
 

4CKr§   Úannotation_formatÚsupported_annotation_formatsc                 C   sX   | |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.)r@   Úformatr*   r+   r   r,   r�   )rè   ré   rm   r'   r'   r(   Úvalidate_annotations  s   
ÿ
ÿþrë   Úvalid_processor_keysÚcaptured_kwargsc                 C   s:   t |ƒ t | ƒ¡}|rd |¡}t d|› d�¡ d S d S )Nz, zUnused or unrecognized kwargs: rS   )ÚsetÚ
differenceÚjoinr_   r`   )rì   rí   Zunused_keysZunused_key_strr'   r'   r(   Úvalidate_kwargs&  s
   
ýrñ   )rQ   r/   )NNNNNNNNNNNN)Zr‘   r�   Úior   Útypingr   r   r   r   r   r   r	   r9   rL   rŠ   Ú	packagingr
   Úutilsr   r   r   r   r   r   r   r   r   r   r   Zutils.constantsr   r   r   r   r   r   Ú	PIL.Imager1   ZPIL.ImageOpsÚparseÚ__version__Úbase_versionr2   Ú
Resamplingr¥   Útorchvision.transformsr   rä   ÚBOXrÄ   ÚHAMMINGÚBICUBICÚLANCZOSZpil_torch_interpolation_mappingr8   Ú
get_loggerr"   r_   r¨   Ú
ImageInputZ
VideoInputr   r*   r-   r‡   r]   ZAnnotationTyper5   r6   rD   rE   rH   rI   ÚboolrP   rV   rX   rb   re   rj   rr   rt   r   r�   r½   r†   r¦   r§   rë   rñ   r'   r'   r'   r(   Ú<module>   sþ   $4 

ú

ÿ


ùÿ'
ÿÿÿ
þ&ÿÿÿ
þ"""&&$-ôÿþýüûúùø	÷
öõ
ô*  aÿ
þý
ü