
     `i`                        d dl mZ d dlmZ d dlmZmZ d dlmZm	Z	m
Z
mZ d dlZddlmZmZmZ ddl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mZm Z m!Z!m"Z"m#Z# dd
l$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m/Z/  e)            rd dl0Z0 e*            rd dl1m2Z3 ddlm4Z4 ndZ4 e,j5        e6          Z7 ed          dddddddddddej8        fde	e9         de	e:         de	e9         de	ee:e;e:         f                  de	ee:e;e:         f                  de	e9         de	e         de	e9         de	e         de	d         de	ee<e'f                  defd            Z=d3d d!d"e	e>         d#d!fd$Z?d%ee         d#e;e         fd&Z@d'e;d!         d#eAe>d(f         fd)ZBd*eejC        d!f         d+e>d#e;eejC        d!f                  fd,ZD G d- d.e
d/0          ZEe( G d1 d2e                      ZFdS )4    )Iterable)deepcopy)	lru_cachepartial)AnyOptional	TypedDictUnionN   )BaseImageProcessorBatchFeatureget_size_dict)convert_to_rgbget_resize_output_image_sizeget_size_with_aspect_ratiogroup_images_by_shapereorder_images)ChannelDimension
ImageInput	ImageTypeSizeDictget_image_size#get_image_size_for_max_height_widthget_image_typeinfer_channel_dimension_formatmake_flat_list_of_imagesvalidate_kwargsvalidate_preprocess_arguments)Unpack)
TensorTypeauto_docstringis_torch_availableis_torchvision_availableis_vision_availablelogging)is_rocm_platform)PILImageResampling)
functional)pil_torch_interpolation_mapping
   maxsize
do_rescalerescale_factordo_normalize
image_mean	image_stddo_center_crop	crop_size	do_resizesizeinterpolationF.InterpolationModereturn_tensorsdata_formatc                     t          | |||||||||	
  
         |
|
dk    rt          d          |t          j        k    rt          d          dS )z
    Checks validity of typically used arguments in an `ImageProcessorFast` `preprocess` method.
    Raises `ValueError` if arguments incompatibility is caught.
    )
r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   Nptz6Only returning PyTorch tensors is currently supported.z6Only channel first data format is currently supported.)r   
ValueErrorr   FIRST)r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r8   r9   s               |/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/transformers/image_processing_utils_fast.py"validate_fast_preprocess_argumentsr?   I   s    & "%!%#    !n&<&<QRRR&,,,QRRR -,    tensortorch.Tensoraxisreturnc                     ||                                  S 	 |                      |          S # t          $ r | cY S w xY w)zF
    Squeezes a tensor, but only if the axis specified has dim 1.
    N)rC   )squeezer<   )rA   rC   s     r>   safe_squeezerG   p   sV     |~~~~4~(((   s   . ==valuesc                 (    d t          |  D             S )zO
    Return the maximum value across all indices of an iterable of values.
    c                 ,    g | ]}t          |          S  )max).0values_is     r>   
<listcomp>z&max_across_indices.<locals>.<listcomp>   s    777hCMM777r@   )zip)rH   s    r>   max_across_indicesrQ   }   s     87#v,7777r@   images.c                 D    t          d | D                       \  }}}||fS )zH
    Get the maximum height and width across all images in a batch.
    c                     g | ]	}|j         
S rK   )shape)rM   imgs     r>   rO   z(get_max_height_width.<locals>.<listcomp>   s    2O2O2O392O2O2Or@   )rQ   )rR   _
max_height	max_widths       r>   get_max_height_widthrZ      s2    
  22O2O2O2O2OPPAz9	""r@   image
patch_sizec                     g }t          | t          j                  \  }}t          d||          D ]B}t          d||          D ].}| dd|||z   |||z   f         }|                    |           /C|S )a6  
    Divides an image into patches of a specified size.

    Args:
        image (`Union[np.array, "torch.Tensor"]`):
            The input image.
        patch_size (`int`):
            The size of each patch.
    Returns:
        list: A list of Union[np.array, "torch.Tensor"] representing the patches.
    )channel_dimr   N)r   r   r=   rangeappend)r[   r\   patchesheightwidthijpatchs           r>   divide_to_patchesrg      s     G"56F6LMMMMFE1fj)) " "q%,, 	" 	"A!!!QZ/Q^1CCDENN5!!!!	" Nr@   c                   V   e Zd ZU ee         ed<   eeeef                  ed<   ee         ed<   ee	d                  ed<   ee         ed<   eeeef                  ed<   ee         ed<   ee	ee
f                  ed	<   ee         ed
<   ee	e
ee
         f                  ed<   ee	e
ee
         f                  ed<   ee         ed<   eeeef                  ed<   ee         ed<   ee	eef                  ed<   ee         ed<   ee	eef                  ed<   ed         ed<   ee         ed<   dS )DefaultFastImageProcessorKwargsr4   r5   default_to_square)r'   r7   resampler2   r3   r-   r.   r/   r0   r1   do_padpad_sizedo_convert_rgbr8   r9   input_data_formattorch.devicedevicedisable_groupingN)__name__
__module____qualname__r   bool__annotations__dictstrintr
   floatlistr    r   rK   r@   r>   ri   ri      s        ~
4S>
""""~%%%uHIJJJJTN"""S#X''''U3:.////4.   ud5k123333eT%[012222TNtCH~&&&&TN"""U3
?34444*++++c+;&; <====^$$$$tn$$$$$r@   ri   F)totalc            !           e Zd ZdZdZdZdZdZdZdZ	dZ
dZdZdZdZdZdZdZej        ZdZdZdgZeZdZdee         f fdZedefd            Z	 	 	 	 	 dEddde de!e"         de!e#         dede!e         ddfdZ$	 	 dFddde de!d         deddf
dZ%e&	 	 dFddde'e"e"f         de!d         deddf
d            Z(ddde)ddfdZ*ddde+e)e,e)         f         de+e)e,e)         f         ddfd Z- e.d!"          	 	 	 	 	 	 dGd#e!e         d$e!e+e)e/e)         f                  d%e!e+e)e/e)         f                  d&e!e         d'e!e)         d(e!d)         de'fd*            Z0ddd&ed'e)d#ed$e+e)e/e)         f         d%e+e)e/e)         f         ddfd+Z1ddde ddfd,Z2de3de3fd-Z4de5fd.Z6	 dHde3d0e"de3fd1Z7	 	 	 dIde3d2e!e         d3e!e+e#ef                  d(e!d)         ddf
d4Z8	 	 	 	 dJde3d2e!e         d3e!e+e#ef                  d(e!d)         d0e"de/d         fd5Z9	 	 	 	 	 	 	 dKde!e          d6e!e          de!e          d7e!e         d$e!e+e)e/e)         f                  d%e!e+e)e/e)         f                  d8e!e         de5fd9Z:	 	 	 	 	 	 	 	 	 	 	 	 dLd&e!e         d'e!e)         d#e!e         d$e!e+e)e'e)         f                  d%e!e+e)e'e)         f                  d:e!e         de!e          d;e!e         d6e!e          de!d         d<e!e+e#e;f                  d8e!e         fd=Z<de3dee         de=fd>Z>e?de3dee         de=fd?            Z@dd@de3d2ed3ed(e!e+e#d)f                  dee         de=fdAZAde/d         d:ede de!d         d;ed6e d&ed'e)d#ed$e!e+e)e/e)         f                  d%e!e+e)e/e)         f                  dBe!e         de!e          de!e         d<e!e+e#e;f                  de=f dCZB fdDZC xZDS )MBaseImageProcessorFastNTgp?pixel_valueskwargsc                      t                      j        di | |                     |          }|                    d| j                  }|*t          ||                    d| j                            nd | _        |                    d| j                  }|t          |d          nd | _        |                    d| j                  }|t          |d          nd | _        | j	        j
        D ]Y}|                    |d           }|t          | ||           ,t          | |t          t          | |d                                Zt          | j	        j
                                                  | _        d S )	Nr5   rj   r5   rj   r3   
param_namerm   r5   r   rK   )super__init__filter_out_unused_kwargspopr5   r   rj   r3   rm   valid_kwargsrw   setattrr   getattrr|   keys_valid_kwargs_names)selfr   r5   r3   rm   keykwarg	__class__s          r>   r   zBaseImageProcessorFast.__init__   s   ""6"""..v66zz&$),,  tvzzBUW[Wm7n7noooo 		
 JJ{DN;;	MVMby[IIIIhl::j$-88OWOc8
KKKKim$4 	G 	GCJJsD))E c5))))c8GD#t,D,D#E#EFFFF $((9(I(N(N(P(P#Q#Q   r@   rD   c                     dS )zv
        `bool`: Whether or not this image processor is a fast processor (backed by PyTorch and TorchVision).
        TrK   )r   s    r>   is_fastzBaseImageProcessorFast.is_fast   s	    
 tr@   r   constantFrR   rB   rm   
fill_valuepadding_modereturn_maskrr   c                    |0|j         r|j        st          d| d          |j         |j        f}nt          |          }t	          ||          \  }}	i }
i }|                                D ]\  }}|j        dd         }|d         |d         z
  }|d         |d         z
  }|dk     s|dk     rt          d| d	| d          ||k    rdd||f}t          j        ||||
          }||
|<   |rKt          j
        |t          j                  ddddddf         }d|dd|d         d|d         f<   |||<   t          |
|	          }|rt          ||	          }||fS |S )a  
        Pads images to `(pad_size["height"], pad_size["width"])` or to the largest size in the batch.

        Args:
            images (`torch.Tensor`):
                Images to pad.
            pad_size (`SizeDict`, *optional*):
                Dictionary in the format `{"height": int, "width": int}` specifying the size of the output image.
            fill_value (`int`, *optional*, defaults to `0`):
                The constant value used to fill the padded area.
            padding_mode (`str`, *optional*, defaults to "constant"):
                The padding mode to use. Can be any of the modes supported by
                `torch.nn.functional.pad` (e.g. constant, reflection, replication).
            return_mask (`bool`, *optional*, defaults to `False`):
                Whether to return a pixel mask to denote padded regions.
            disable_grouping (`bool`, *optional*, defaults to `False`):
                Whether to disable grouping of images by size.

        Returns:
            `torch.Tensor`: The resized image.
        NzCPad size must contain 'height' and 'width' keys only. Got pad_size=.rr   r   r   zrPadding dimensions are negative. Please make sure that the `pad_size` is larger than the image size. Got pad_size=z, image_size=)fillr   dtype.)rb   rc   r<   rZ   r   itemsrU   Fpadtorch
zeros_likeint64r   )r   rR   rm   r   r   r   rr   r   grouped_imagesgrouped_images_indexprocessed_images_groupedprocessed_masks_groupedrU   stacked_images
image_sizepadding_heightpadding_widthpaddingstacked_masksprocessed_imagesprocessed_maskss                        r>   r   zBaseImageProcessorFast.pad   s   > O t t !rgo!r!r!rsss 8HH+F33H/DV^n/o/o/o,,#% "$%3%9%9%;%; 	? 	?!E>'-bcc2J%a[:a=8N$QK*Q-7M!!]Q%6%6 U08U UGQU U U   X%%a?!"~wZ^j!k!k!k.<$U+ ? % 0u{ S S STWYZ\]\]\]_`_`_`T` aGHc?Z]?OjmOCD1>'.)*BDXYY 	5,-DFZ[[O#_44r@   r[   r5   r6   r7   	antialiasc                    ||nt           j        j        }|j        r=|j        r6t          |                                dd         |j        |j                  }n|j        r#t          ||j        dt          j	                  }nt|j
        r=|j        r6t          |                                dd         |j
        |j                  }n0|j        r|j        r|j        |j        f}nt          d| d          t           j                                        r&t'                      r|                     ||||          S t          j        ||||          S )a@  
        Resize an image to `(size["height"], size["width"])`.

        Args:
            image (`torch.Tensor`):
                Image to resize.
            size (`SizeDict`):
                Dictionary in the format `{"height": int, "width": int}` specifying the size of the output image.
            interpolation (`InterpolationMode`, *optional*, defaults to `InterpolationMode.BILINEAR`):
                `InterpolationMode` filter to use when resizing the image e.g. `InterpolationMode.BICUBIC`.

        Returns:
            `torch.Tensor`: The resized image.
        Nr   F)r5   rj   ro   zjSize must contain 'height' and 'width' keys, or 'max_height' and 'max_width', or 'shortest_edge' key. Got r   r6   r   )r   InterpolationModeBILINEARshortest_edgelongest_edger   r5   r   r   r=   rX   rY   r   rb   rc   r<   r   compileris_compilingr&   compile_friendly_resizeresize)r   r[   r5   r6   r   r   new_sizes          r>   r   zBaseImageProcessorFast.resize7  s}   , *7)BH[Hd 	$"3 	 2

RSS!"! HH
  	3'"'"2"8	  HH _ 	 	:5::<<;Ldo_c_mnnHH[ 	TZ 	TZ0HH     >&&(( 	[-=-?-? 	[//xPYZZZxx}PYZZZZr@   r   c                    | j         t          j        k    r|                                 dz  } t	          j        | |||          } | dz  } t          j        | dk    d|           } t          j        | dk     d|           } |                                                     t          j                  } nt	          j        | |||          } | S )z{
        A wrapper around `F.resize` so that it is compatible with torch.compile when the image is a uint8 tensor.
           r      r   )	r   r   uint8r{   r   r   whereroundto)r[   r   r6   r   s       r>   r   z.BaseImageProcessorFast.compile_friendly_resizem  s     ;%+%% KKMMC'EHUHMU^___ECKE KS%88EK	1e44EKKMM$$U[11EEHUHMU^___Er@   scalec                     ||z  S )a?  
        Rescale an image by a scale factor. image = image * scale.

        Args:
            image (`torch.Tensor`):
                Image to rescale.
            scale (`float`):
                The scaling factor to rescale pixel values by.

        Returns:
            `torch.Tensor`: The rescaled image.
        rK   )r   r[   r   r   s       r>   rescalezBaseImageProcessorFast.rescale  s    $ u}r@   meanstdc                 .    t          j        |||          S )a  
        Normalize an image. image = (image - image_mean) / image_std.

        Args:
            image (`torch.Tensor`):
                Image to normalize.
            mean (`torch.Tensor`, `float` or `Iterable[float]`):
                Image mean to use for normalization.
            std (`torch.Tensor`, `float` or `Iterable[float]`):
                Image standard deviation to use for normalization.

        Returns:
            `torch.Tensor`: The normalized image.
        )r   	normalize)r   r[   r   r   r   s        r>   r   z BaseImageProcessorFast.normalize  s    * {5$,,,r@   r*   r+   r/   r0   r1   r-   r.   rq   rp   c                     |r<|r:t          j        ||          d|z  z  }t          j        ||          d|z  z  }d}|||fS )Nrq   g      ?F)r   rA   )r   r/   r0   r1   r-   r.   rq   s          r>   !_fuse_mean_std_and_rescale_factorz8BaseImageProcessorFast._fuse_mean_std_and_rescale_factor  sa      	, 	j@@@C.DXYJYv>>>#BVWIJ9j00r@   c                     |                      ||||||j                  \  }}}|r6|                     |                    t          j                  ||          }n|r|                     ||          }|S )z/
        Rescale and normalize images.
        )r/   r0   r1   r-   r.   rq   r   )r   rq   r   r   r   float32r   )r   rR   r-   r.   r/   r0   r1   s          r>   rescale_and_normalizez,BaseImageProcessorFast.rescale_and_normalize  s     -1,R,R%!!)= -S -
 -
)
Iz  	:^^FIIEMI$B$BJPYZZFF 	:\\&.99Fr@   c                 8   |j         |j        $t          d|                                           |j        dd         \  }}|j         |j        }}||k    s||k    r{||k    r||z
  dz  nd||k    r||z
  dz  nd||k    r||z
  dz   dz  nd||k    r||z
  dz   dz  ndg}t          j        ||d          }|j        dd         \  }}||k    r||k    r|S t          ||z
  dz            }	t          ||z
  dz            }
t          j        ||	|
||          S )	a  
        Note: override torchvision's center_crop to have the same behavior as the slow processor.
        Center crop an image to `(size["height"], size["width"])`. If the input size is smaller than `crop_size` along
        any edge, the image is padded with 0's and then center cropped.

        Args:
            image (`"torch.Tensor"`):
                Image to center crop.
            size (`dict[str, int]`):
                Size of the output image.

        Returns:
            `torch.Tensor`: The center cropped image.
        Nz=The size dictionary must have keys 'height' and 'width'. Got r      r   r   )r   g       @)	rb   rc   r<   r   rU   r   r   rz   crop)r   r[   r5   r   image_heightimage_widthcrop_height
crop_widthpadding_ltrbcrop_top	crop_lefts              r>   center_cropz"BaseImageProcessorFast.center_crop  s   ( ;$*"4j]a]f]f]h]hjjkkk$)K$4!k"&+tzZ##{\'A'A3=3K3Kk)a//QR5@<5O5O|+11UV7AK7O7Ok)A-!33UV9D|9S9S|+a/A55YZ	L E%A666E(-BCC(8%L+[(([L-H-H{2c9::z1S899	veXy+zJJJr@   c                      t          |          S )a'  
        Converts an image to RGB format. Only converts if the image is of type PIL.Image.Image, otherwise returns the image
        as is.
        Args:
            image (ImageInput):
                The image to convert.

        Returns:
            ImageInput: The converted image.
        )r   )r   r[   s     r>   r   z%BaseImageProcessorFast.convert_to_rgb  s     e$$$r@   c                     | j         |S | j         D ]9}||v r3t                              d| d           |                    |           :|S )zJ
        Filter out the unused kwargs from the kwargs dictionary.
        Nz!This processor does not use the `z ` parameter. It will be ignored.)unused_kwargsloggerwarning_oncer   )r   r   
kwarg_names      r>   r   z/BaseImageProcessorFast.filter_out_unused_kwargs  sg     %M, 	' 	'JV####$t
$t$t$tuuu

:&&&r@      expected_ndimsc                 N    |                      |          }t          ||          S )z
        Prepare the images structure for processing.

        Args:
            images (`ImageInput`):
                The input images to process.

        Returns:
            `ImageInput`: The images with a valid nesting.
        r   )fetch_imagesr   )r   rR   r   s      r>   _prepare_images_structurez0BaseImageProcessorFast._prepare_images_structure$  s*      ""6**'~NNNNr@   rn   ro   c                 x   t          |          }|t          j        t          j        t          j        fvrt          d|           |r|                     |          }|t          j        k    rt          j        |          }n6|t          j        k    r&t          j
        |                                          }|j        dk    r|                    d          }|t          |          }|t          j        k    r)|                    ddd                                          }||                    |          }|S )NzUnsupported input image type r   r   r   )r   r   PILTORCHNUMPYr<   r   r   pil_to_tensorr   
from_numpy
contiguousndim	unsqueezer   r   LASTpermuter   )r   r[   rn   ro   rq   
image_types         r>   _process_imagez%BaseImageProcessorFast._process_image7  s$    $E**
imY_ioNNNIZIIJJJ 	/''..E&&OE**EE9?**$U++6688E :??OOA&&E $ >u E E 0 555MM!Q**5577E HHV$$Er@   c                    |                      ||          }t          | j        |||          t          |          dk    o!t	          |d         t
          t          f          }|rfd|D             }nfd|D             }|S )a  
        Prepare image-like inputs for processing.

        Args:
            images (`ImageInput`):
                The image-like inputs to process.
            do_convert_rgb (`bool`, *optional*):
                Whether to convert the images to RGB.
            input_data_format (`str` or `ChannelDimension`, *optional*):
                The input data format of the images.
            device (`torch.device`, *optional*):
                The device to put the processed images on.
            expected_ndims (`int`, *optional*):
                The expected number of dimensions for the images. (can be 2 for segmentation maps etc.)

        Returns:
            List[`torch.Tensor`]: The processed images.
        r   rn   ro   rq   r   c                 ,    g | ]}fd |D             S )c                 &    g | ]} |          S rK   rK   rM   rV   process_image_partials     r>   rO   zPBaseImageProcessorFast._prepare_image_like_inputs.<locals>.<listcomp>.<listcomp>  s%     S S S!6!6s!;!; S S Sr@   rK   )rM   nested_listr   s     r>   rO   zEBaseImageProcessorFast._prepare_image_like_inputs.<locals>.<listcomp>  s/    nnnXc S S S S{ S S Snnnr@   c                 &    g | ]} |          S rK   rK   r   s     r>   rO   zEBaseImageProcessorFast._prepare_image_like_inputs.<locals>.<listcomp>  s%    MMMs 5 5c : :MMMr@   )r   r   r   len
isinstancer|   tuple)	r   rR   rn   ro   rq   r   has_nested_structurer   r   s	           @r>   _prepare_image_like_inputsz1BaseImageProcessorFast._prepare_image_like_inputs]  s    8 //~/VV 'Rclr!
 !
 !

  #6{{QW:fQi$PU3W3W 	NnnnngmnnnMMMMfMMMr@   r3   rj   r9   c                 *   |i }|t          di t          ||          }|t          di t          |d          }|t          di t          |d          }t          |t                    rt	          |          }t          |t                    rt	          |          }|t
          j        }||d<   ||d<   ||d<   ||d<   ||d	<   ||d
<   |                    d          }	t          |	t          t          f          rt          |	         n|	|d<   |S )z
        Update kwargs that need further processing before being validated
        Can be overridden by subclasses to customize the processing of kwargs.
        Nr   r3   r   rm   r   r5   r0   r1   r9   rk   r6   rK   )r   r   r   r|   r  r   r=   r   r'   rz   r)   )
r   r5   r3   rm   rj   r0   r1   r9   r   rk   s
             r>   _further_process_kwargsz.BaseImageProcessorFast._further_process_kwargs  sQ    >F\\mIZ[[[\\D  TT={#S#S#STTIVV-X*"U"U"UVVHj$'' 	+z**Ji&& 	)i((I*0Kv'{%z)|'{ +} ::j))9CHOacfNg9h9hv+H55nv 	 r@   r4   r2   r8   c                 <    t          |||||||||	|
||           dS )z@
        validate the kwargs for the preprocess method.
        )r-   r.   r/   r0   r1   r4   r5   r2   r3   r6   r8   r9   N)r?   )r   r-   r.   r/   r0   r1   r4   r5   r2   r3   r6   r8   r9   r   s                 r>   _validate_preprocess_kwargsz2BaseImageProcessorFast._validate_preprocess_kwargs  sI    & 	+!)%!)')#	
 	
 	
 	
 	
 	
r@   c                 $     | j         |g|R i |S N)
preprocess)r   rR   argsr   s       r>   __call__zBaseImageProcessorFast.__call__  s$    tv7777777r@   c           	         t          |                                | j                   | j        D ]'}|                    |t	          | |d                      (|                    d          }|                    d          }|                    d          } | j        di |} | j        di | |                    d            | j        |g|R |||d|S )N)captured_kwargsvalid_processor_keysrn   ro   rq   r9   r   rK   )	r   r   r   
setdefaultr   r   r  r  _preprocess_image_like_inputs)r   rR   r  r   r   rn   ro   rq   s           r>   r
  z!BaseImageProcessorFast.preprocess  s     	DLdeeee 2 	K 	KJj'$
D*I*IJJJJ  $455"JJ':;;H%% .-7777 	)(226222 	

=!!!1t1

 
*8L]fl
 
pv
 
 	
r@   r   c                V    |                      ||||          } | j        |g|R i |S )z
        Preprocess image-like inputs.
        To be overridden by subclasses when image-like inputs other than images should be processed.
        It can be used for segmentation maps, depth maps, etc.
        )rR   rn   ro   rq   )r  _preprocess)r   rR   rn   ro   rq   r  r   s          r>   r  z4BaseImageProcessorFast._preprocess_image_like_inputs  sN     00.L]fl 1 
 
  t8888888r@   rl   c           	      <   t          ||          \  }}i }|                                D ]$\  }}|r|                     |||          }|||<   %t          ||          }t          ||          \  }}i }|                                D ]<\  }}|r|                     ||          }|                     ||||	|
|          }|||<   =t          ||          }|r|                     |||          }|rt          j        |d          n|}t          d|i|          S )Nr   )r[   r5   r6   )rm   rr   r   )dimr   )datatensor_type)
r   r   r   r   r   r   r   r   stackr   )r   rR   r4   r5   r6   r2   r3   r-   r.   r/   r0   r1   rl   rm   rr   r8   r   r   r   resized_images_groupedrU   r   resized_imagesr   r   s                            r>   r  z"BaseImageProcessorFast._preprocess  s   ( 0EV^n/o/o/o,,!#%3%9%9%;%; 	; 	;!E> k!%>\i!j!j,:"5))'(>@TUU 0E^fv/w/w/w,,#% %3%9%9%;%; 	= 	=!E> M!%!1!1.)!L!L!77
NL*V_ N /=$U++)*BDXYY 	p#xx(88^nxooCQg5;'7Q????Wg.2B!CQ_````r@   c                     t                                                      }|                    dd            |                    dd            |S )N_valid_processor_keysr   )r   to_dictr   )r   encoder_dictr   s     r>   r  zBaseImageProcessorFast.to_dict=  sJ    ww((0$777.555r@   )Nr   r   FF)NT)NNNNNN)r   )NNN)NNNr   )NNNNNNN)NNNNNNNNNNNN)Ers   rt   ru   rk   r0   r1   r5   rj   r3   r4   r2   rl   rm   r-   r.   r/   rn   r8   r   r=   r9   ro   rq   model_input_namesri   r   r   r   r   propertyrv   r   r   r   rz   ry   r   r   staticmethodr  r   r{   r   r
   r   r   r   r|   r   r   r   r   r   rx   r   r   r   r  r  r    r  r   r  r!   r
  r  r  r  __classcell__)r   s   @r>   r   r      s~	       HJIDIINFHJNLNN"(KF'(2LMR(G!H R R R R R R0     X "$%&0!+0B  B B  B  SM	B 
 smB  B  #4.B  
B  B  B  B P :>4[ 4[4[ 4[   56	4[
 4[ 
4[ 4[ 4[ 4[l  :>	 S/   56 	
 
   \0 
 
   (-- E8E?*+- 5(5/)*	- 
- - - -. Yr (,:>9=%)*.+/1 1tn1 U5$u+#5671 E%e"456	1
 TN1 !1 (1 
1 1 1 1   	
  %e,- U+, 
   8'K'K 'K
 
'K 'K 'K 'KR%% 
% % % % t       O OO O 
	O O O O, *.DH+/$ $$ !$ $E#/?*?$@A	$
 ($ 
$ $ $ $R *.DH+/*  * *  !*  $E#/?*?$@A	* 
 (*  *  
n	*  *  *  * \ $((,'+,0:>9=26. .x . H%. 8$	.
 $D>. U5$u+#567. E%e"456. ./. 
. . . .d &**.'+;?:>$(#')-(,9=;?26 
  
TN 
 ! 
 tn	 

 U5%,#678 
 E%u"567 
 D> 
 x  
 ! 
 H% 
   56 
 !sJ!78 
 ./ 
  
  
  
D8z 8FCb<c 8ht 8 8 8 8 
 
fEd>e 
jv 
 
 
 ^
@ 8<9 9 99 	9
 ,9 sN2349 899 
9 9 9 9(.a^$.a .a 	.a
   56.a .a .a .a .a .a U5$u+#567.a E%e"456.a .a 8$.a #4..a  !sJ!78!.a$ 
%.a .a .a .a`        r@   r   r	  )Gcollections.abcr   copyr   	functoolsr   r   typingr   r   r	   r
   numpynpimage_processing_utilsr   r   r   image_transformsr   r   r   r   r   image_utilsr   r   r   r   r   r   r   r   r   r   r   processing_utilsr   utilsr    r!   r"   r#   r$   r%   utils.import_utilsr&   r'   r   torchvision.transforms.v2r(   r   r)   
get_loggerrs   r   r=   rv   r{   r|   ry   r?   rz   rG   rQ   r  rZ   ndarrayrg   ri   r   rK   r@   r>   <module>r2     s   % $ $ $ $ $       ( ( ( ( ( ( ( ( 2 2 2 2 2 2 2 2 2 2 2 2     S S S S S S S S S S                                       % $ $ $ $ $                1 0 0 0 0 0  0////// LLL +999999<<<<<<< '+# 
	H	%	% 2!%&*#'6:59%)$( $#597;$4$:#S #S#SUO#S 4.#S ud5k123	#S
 eT%[012#S TN#S !#S ~#S 8
#S 12#S U3
?34#S "#S #S #S #SL
 
 
x} 
 
 
 
 
8x} 8c 8 8 8 8#n!5 #%S/ # # # #^+,:=	%
N*
+,   0% % % % %iu % % % %, D
 D
 D
 D
 D
/ D
 D
 D
 D
 D
r@   