Ë
    S^(hô{  ã                   óž  — d Z ddlZddlmZmZmZmZmZmZm	Z	 erddl
mZ ddlZddlmZmZmZ ddl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!m"Z"m#Z#m$Z$ dd	l%m&Z&m'Z'm(Z(m)Z)m*Z*  e«       rddl+Z+ e(«       rddl,Z, e)jZ                  e.«      Z/	 dd
ej`                  de	e1ee1   f   de2de1dee	e3ef      dee1e1f   fd„Z4 G d„ de«      Z5dgZ6y)zImage processor class for DPT.é    N)ÚTYPE_CHECKINGÚDictÚIterableÚListÚOptionalÚTupleÚUnioné   )ÚDepthEstimatorOutput)ÚBaseImageProcessorÚBatchFeatureÚget_size_dict)ÚpadÚresizeÚto_channel_dimension_format)ÚIMAGENET_STANDARD_MEANÚIMAGENET_STANDARD_STDÚChannelDimensionÚ
ImageInputÚPILImageResamplingÚget_image_sizeÚinfer_channel_dimension_formatÚis_scaled_imageÚis_torch_availableÚis_torch_tensorÚmake_list_of_imagesÚto_numpy_arrayÚvalid_imagesÚvalidate_preprocess_arguments)Ú
TensorTypeÚfilter_out_non_signature_kwargsÚis_vision_availableÚloggingÚrequires_backendsÚinput_imageÚoutput_sizeÚkeep_aspect_ratioÚmultipleÚinput_data_formatÚreturnc                 óö   — dd„}t        |t        «      r||fn|}t        | |«      \  }}|\  }}	||z  }
|	|z  }|r"t        d|z
  «      t        d|
z
  «      k  r|}
n|
} ||
|z  |¬«      } |||z  |¬«      }||fS )Nc                 ó¬   — t        | |z  «      |z  }|� ||kD  rt        j                  | |z  «      |z  }||k  rt        j                  | |z  «      |z  }|S ©N)ÚroundÚmathÚfloorÚceil)Úvalr(   Úmin_valÚmax_valÚxs        új/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/transformers/models/dpt/image_processing_dpt.pyÚconstrain_to_multiple_ofz>get_resize_output_image_size.<locals>.constrain_to_multiple_ofF   s[   € Ü�#˜‘.Ó! HÑ,ˆàÐ 1 w¢;Ü—
‘
˜3 ™>Ó*¨XÑ5ˆAàˆwŠ;Ü—	‘	˜# ™.Ó)¨HÑ4ˆAàˆó    é   )r(   )r   N)Ú
isinstanceÚintr   Úabs)r%   r&   r'   r(   r)   r7   Úinput_heightÚinput_widthÚoutput_heightÚoutput_widthÚscale_heightÚscale_widthÚ
new_heightÚ	new_widths                 r6   Úget_resize_output_image_sizerE   ?   s©   € ó	ô 1;¸;ÌÔ0L�; Ñ,ÐR]€Kä .¨{Ð<MÓ NÑ€L�+Ø"-Ñ€M�<ð ! <Ñ/€LØ Ñ,€Káäˆq�;‰Ó¤# a¨,Ñ&6Ó"7Ò7à&‰Lð 'ˆKá)¨,¸Ñ*EÐPXÔY€JÙ(¨°{Ñ)BÈXÔV€Ià˜	Ð"Ð"r8   c            )       óð  ‡ — e Zd ZdZdgZddej                  ddddddddddfded	ee	e
f   d
edede
dedee
ef   dedeeeee   f      deeeee   f      dedee
   deddfˆ fd„Zddej                  ddfdej"                  d	ee	e
f   dede
d
edeee	ef      deee	ef      dej"                  fd„Z	 	 d,dej(                  de
deee	ef      deee	ef      fd„Zdedej"                  fd„Z	 	 	 	 	 	 	 	 	 	 	 	 	 	 d-dedee   dee   d	ee	e
f   d
edee   dee
   d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e	ef      fd„Z	 	 	 	 	 	 	 	 	 	 	 	 	 	 d-dedee   d	ee	e
f   d
edee   dee
   d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e	ef      deee	ef      dej"                  f d„Z	 	 	 	 	 	 	 d.d edee   d	ee	e
f   d
edee   dee
   dee   deee	ef      fd!„Zd/ˆ fd"„	Z e«       dddddddddddddddej:                  dfd#ed$ee   dee   d	ee
   dee   dee
   d
ed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   d%eee	ef      dedeee	ef      dej@                  j@                  f&d&„«       Z!d/d'ee"   fd(„Z#	 d/d)d*d'eeeee"e
e
f      df      deee	ef      fd+„Z$ˆ xZ%S )0ÚDPTImageProcessora¡  
    Constructs a DPT image processor.

    Args:
        do_resize (`bool`, *optional*, defaults to `True`):
            Whether to resize the image's (height, width) dimensions. Can be overidden by `do_resize` in `preprocess`.
        size (`Dict[str, int]` *optional*, defaults to `{"height": 384, "width": 384}`):
            Size of the image after resizing. Can be overidden by `size` in `preprocess`.
        resample (`PILImageResampling`, *optional*, defaults to `Resampling.BICUBIC`):
            Defines the resampling filter to use if resizing the image. Can be overidden by `resample` in `preprocess`.
        keep_aspect_ratio (`bool`, *optional*, defaults to `False`):
            If `True`, the image is resized to the largest possible size such that the aspect ratio is preserved. Can
            be overidden by `keep_aspect_ratio` in `preprocess`.
        ensure_multiple_of (`int`, *optional*, defaults to 1):
            If `do_resize` is `True`, the image is resized to a size that is a multiple of this value. Can be overidden
            by `ensure_multiple_of` in `preprocess`.
        do_rescale (`bool`, *optional*, defaults to `True`):
            Whether to rescale the image by the specified scale `rescale_factor`. Can be overidden by `do_rescale` in
            `preprocess`.
        rescale_factor (`int` or `float`, *optional*, defaults to `1/255`):
            Scale factor to use if rescaling the image. Can be overidden by `rescale_factor` in `preprocess`.
        do_normalize (`bool`, *optional*, defaults to `True`):
            Whether to normalize the image. Can be overridden by the `do_normalize` parameter in the `preprocess`
            method.
        image_mean (`float` or `List[float]`, *optional*, defaults to `IMAGENET_STANDARD_MEAN`):
            Mean to use if normalizing the image. This is a float or list of floats the length of the number of
            channels in the image. Can be overridden by the `image_mean` parameter in the `preprocess` method.
        image_std (`float` or `List[float]`, *optional*, defaults to `IMAGENET_STANDARD_STD`):
            Standard deviation to use if normalizing the image. This is a float or list of floats the length of the
            number of channels in the image. Can be overridden by the `image_std` parameter in the `preprocess` method.
        do_pad (`bool`, *optional*, defaults to `False`):
            Whether to apply center padding. This was introduced in the DINOv2 paper, which uses the model in
            combination with DPT.
        size_divisor (`int`, *optional*):
            If `do_pad` is `True`, pads the image dimensions to be divisible by this value. This was introduced in the
            DINOv2 paper, which uses the model in combination with DPT.
        do_reduce_labels (`bool`, *optional*, defaults to `False`):
            Whether or not to reduce all label values of segmentation maps by 1. Usually used for datasets where 0 is
            used for background, and background itself is not included in all classes of a dataset (e.g. ADE20k). The
            background label will be replaced by 255. Can be overridden by the `do_reduce_labels` parameter in the
            `preprocess` method.
    Úpixel_valuesTNFr9   gp?Ú	do_resizeÚsizeÚresampler'   Úensure_multiple_ofÚ
do_rescaleÚrescale_factorÚdo_normalizeÚ
image_meanÚ	image_stdÚdo_padÚsize_divisorÚdo_reduce_labelsr*   c                 ó"  •— t        ‰| �  di |¤Ž |�|ndddœ}t        |«      }|| _        || _        || _        || _        || _        || _        || _	        || _
        |	�|	nt        | _        |
�|
nt        | _        || _        || _        || _        y )Ni€  )ÚheightÚwidth© )ÚsuperÚ__init__r   rI   rJ   r'   rL   rK   rM   rN   rO   r   rP   r   rQ   rR   rS   rT   )ÚselfrI   rJ   rK   r'   rL   rM   rN   rO   rP   rQ   rR   rS   rT   ÚkwargsÚ	__class__s                  €r6   rZ   zDPTImageProcessor.__init__—   s¡   ø€ ô" 	‰ÑÑ"˜6Ò"ØÐ'‰t¸ÀcÑ-JˆÜ˜TÓ"ˆØ"ˆŒØˆŒ	Ø!2ˆÔØ"4ˆÔØ ˆŒØ$ˆŒØ,ˆÔØ(ˆÔØ(2Ð(>™*ÔDZˆŒØ&/Ð&;™ÔAVˆŒØˆŒØ(ˆÔØ 0ˆÕr8   ÚimageÚdata_formatr)   c                 ó²   — t        |«      }d|vsd|vrt        d|j                  «       › �«      ‚t        ||d   |d   f|||¬«      }	t	        |f|	|||dœ|¤ŽS )aE  
        Resize an image to target size `(size["height"], size["width"])`. If `keep_aspect_ratio` is `True`, the image
        is resized to the largest possible size such that the aspect ratio is preserved. If `ensure_multiple_of` is
        set, the image is resized to a size that is a multiple of this value.

        Args:
            image (`np.ndarray`):
                Image to resize.
            size (`Dict[str, int]`):
                Target size of the output image.
            keep_aspect_ratio (`bool`, *optional*, defaults to `False`):
                If `True`, the image is resized to the largest possible size such that the aspect ratio is preserved.
            ensure_multiple_of (`int`, *optional*, defaults to 1):
                The image is resized to a size that is a multiple of this value.
            resample (`PILImageResampling`, *optional*, defaults to `PILImageResampling.BICUBIC`):
                Defines the resampling filter to use if resizing the image. Otherwise, the image is resized to size
                specified in `size`.
            resample (`PILImageResampling`, *optional*, defaults to `PILImageResampling.BICUBIC`):
                Resampling filter to use when resiizing the image.
            data_format (`str` or `ChannelDimension`, *optional*):
                The channel dimension format of the image. If not provided, it will be the same as the input image.
            input_data_format (`str` or `ChannelDimension`, *optional*):
                The channel dimension format of the input image. If not provided, it will be inferred.
        rV   rW   zDThe size dictionary must contain the keys 'height' and 'width'. Got )r&   r'   r(   r)   )rJ   rK   r_   r)   )r   Ú
ValueErrorÚkeysrE   r   )
r[   r^   rJ   r'   rL   rK   r_   r)   r\   r&   s
             r6   r   zDPTImageProcessor.resize¹   s�   € ôF ˜TÓ"ˆØ˜4Ñ 7°$Ñ#6ÜÐcÐdh×dmÑdmÓdoÐcpÐqÓrÐrä2ØØ˜h™¨¨g©Ð7Ø/Ø'Ø/ô
ˆô Øð
àØØ#Ø/ñ
ð ñ
ð 	
r8   c                 ó˜   — d„ }|€t        |«      }t        ||«      \  }} |||«      \  }}	 |||«      \  }
}t        |||	f|
|ff|¬«      S )a)  
        Center pad an image to be a multiple of `multiple`.

        Args:
            image (`np.ndarray`):
                Image to pad.
            size_divisor (`int`):
                The width and height of the image will be padded to a multiple of this number.
            data_format (`ChannelDimension` or `str`, *optional*, defaults to `ChannelDimension.FIRST`):
                The channel dimension format for the output image. Can be one of:
                - `"channels_first"` or `ChannelDimension.FIRST`: image in (num_channels, height, width) format.
                - `"channels_last"` or `ChannelDimension.LAST`: image in (height, width, num_channels) format.
                - Unset: Use the channel dimension format of the input image.
            input_data_format (`ChannelDimension` or `str`, *optional*):
                The channel dimension format for the input image. If unset, the channel dimension format is inferred
                from the input image. Can be one of:
                - `"channels_first"` or `ChannelDimension.FIRST`: image in (num_channels, height, width) format.
                - `"channels_last"` or `ChannelDimension.LAST`: image in (height, width, num_channels) format.
                - `"none"` or `ChannelDimension.NONE`: image in (height, width) format.
        c                 ó^   — t        j                  | |z  «      |z  }|| z
  }|dz  }||z
  }||fS )Né   )r/   r1   )rJ   rS   Únew_sizeÚpad_sizeÚpad_size_leftÚpad_size_rights         r6   Ú_get_padz-DPTImageProcessor.pad_image.<locals>._get_pad  sA   € Ü—y‘y ¨Ñ!4Ó5¸ÑDˆHØ $‘ˆHØ$¨™MˆMØ%¨Ñ5ˆNØ  .Ð0Ð0r8   )r_   )r   r   r   )r[   r^   rS   r_   r)   rj   rV   rW   rh   ri   Úpad_size_topÚpad_size_bottoms               r6   Ú	pad_imagezDPTImageProcessor.pad_imageð   sl   € ò8	1ð Ð$Ü >¸uÓ EÐä& uÐ.?Ó@‰ˆ�á(0°¸Ó(FÑ%ˆ�~Ù(0°¸Ó(EÑ%ˆ�oä�5˜M¨>Ð:¸\È?Ð<[Ð\ÐjuÔvÐvr8   Úlabelc                 óF   — t        |«      }d||dk(  <   |dz
  }d||dk(  <   |S )Néÿ   r   r9   éþ   )r   )r[   rn   s     r6   Úreduce_labelzDPTImageProcessor.reduce_label  s6   € Ü˜uÓ%ˆàˆˆe�q‰jÑØ˜‘	ˆØ!ˆˆe�s‰lÑØˆr8   c                 óä   — |r| j                  |«      }|r| j                  ||||||¬«      }|r| j                  ||	|¬«      }|
r| j                  ||||¬«      }|r| j	                  |||¬«      }|S )N)r^   rJ   rK   r'   rL   r)   )r^   Úscaler)   )r^   ÚmeanÚstdr)   )r^   rS   r)   )rr   r   ÚrescaleÚ	normalizerm   )r[   r^   rT   rI   rJ   rK   r'   rL   rM   rN   rO   rP   rQ   rR   rS   r)   s                   r6   Ú_preprocesszDPTImageProcessor._preprocess&  s�   € ñ$ Ø×%Ñ% eÓ,ˆEáØ—K‘KØØØ!Ø"3Ø#5Ø"3ð  ó ˆEñ Ø—L‘L u°NÐVg�LÓhˆEáØ—N‘N¨°ZÀYÐbs�NÓtˆEáØ—N‘N¨¸\Ð]n�NÓoˆEàˆr8   c                 óÚ   — t        |«      }|r t        |«      rt        j                  d«       |€t	        |«      }| j                  |d||||||||	|
||||¬«      }|�t        |||¬«      }|S )zPreprocesses a single image.z­It looks like you are trying to rescale already rescaled images. If the input images have pixel values between 0 and 1, set `do_rescale=False` to avoid rescaling them again.F)rT   rI   rJ   rK   r'   rL   rM   rN   rO   rP   rQ   rR   rS   r)   )Úinput_channel_dim)r   r   ÚloggerÚwarning_oncer   ry   r   )r[   r^   rI   rJ   rK   r'   rL   rM   rN   rO   rP   rQ   rR   rS   r_   r)   s                   r6   Ú_preprocess_imagez#DPTImageProcessor._preprocess_imageP  s�   € ô( ˜uÓ%ˆÙœ/¨%Ô0Ü×Ñðsôð Ð$ä >¸uÓ EÐà× Ñ ØØ"ØØØØ/Ø1Ø!Ø)Ø%Ø!ØØØ%Ø/ð !ó 
ˆð" Ð"Ü/°°{ÐVgÔhˆEØˆr8   Úsegmentation_mapc	                 ó2  — t        |«      }|j                  dk(  r|d   }d}	t        j                  }nd}	|€t	        |d¬«      }| j                  |||||||dd|¬«
      }|	rt        j                  |d¬	«      }|j                  t        j                  «      }|S )
z'Preprocesses a single segmentation map.re   )N.TFr9   )Únum_channels)
r^   rT   rI   rJ   rK   r'   rL   rO   rM   r)   r   )Úaxis)
r   Úndimr   ÚFIRSTr   ry   ÚnpÚsqueezeÚastypeÚint64)
r[   r   rI   rJ   rK   r'   rL   rT   r)   Úadded_dimensions
             r6   Ú_preprocess_segmentation_mapz.DPTImageProcessor._preprocess_segmentation_mapƒ  sº   € ô *Ð*:Ó;Ðà× Ñ  AÒ%Ø/°	Ñ:ÐØ"ˆOÜ 0× 6Ñ 6Ñà#ˆOØ Ð(Ü$BÐCSÐbcÔ$dÐ!Ø×+Ñ+Ø"Ø-ØØØØ/Ø1ØØØ/ð ,ó 
Ðñ Ü!Ÿz™zÐ*:ÀÔCÐØ+×2Ñ2´2·8±8Ó<ÐØÐr8   c                 ó(   •— t        ‰| �  |fd|i|¤ŽS )NÚsegmentation_maps)rY   Ú__call__)r[   ÚimagesrŒ   r\   r]   s       €r6   r�   zDPTImageProcessor.__call__­  s    ø€ ô ‰wÑ ÑVÐ:KÐVÈvÑVÐVr8   rŽ   rŒ   Úreturn_tensorsc                 ó,  — |�|n| j                   }|�|n| j                  }t        |«      }|�|n| j                  }|�|n| j                  }|�|n| j
                  }|�|n| j                  }|	�|	n| j                  }	|
�|
n| j                  }
|�|n| j                  }|�|n| j                  }|�|n| j                  }|�|n| j                  }|�|n| j                  }t        |«      }|�t        |d¬«      }t        |«      st!        d«      ‚t#        ||	|
|||||||¬«
       |D �cg c]"  }| j%                  ||||
||||||	|||||¬«      ‘Œ$ }}d|i}|�+|D �cg c]  }| j'                  ||||||||¬«      ‘Œ }}||d<   t)        ||¬	«      S c c}w c c}w )
a�  
        Preprocess an image or batch of images.

        Args:
            images (`ImageInput`):
                Image to preprocess. Expects a single or batch of images with pixel values ranging from 0 to 255. If
                passing in images with pixel values between 0 and 1, set `do_rescale=False`.
            segmentation_maps (`ImageInput`, *optional*):
                Segmentation map to preprocess.
            do_resize (`bool`, *optional*, defaults to `self.do_resize`):
                Whether to resize the image.
            size (`Dict[str, int]`, *optional*, defaults to `self.size`):
                Size of the image after reszing. If `keep_aspect_ratio` is `True`, the image is resized to the largest
                possible size such that the aspect ratio is preserved. If `ensure_multiple_of` is set, the image is
                resized to a size that is a multiple of this value.
            keep_aspect_ratio (`bool`, *optional*, defaults to `self.keep_aspect_ratio`):
                Whether to keep the aspect ratio of the image. If False, the image will be resized to (size, size). If
                True, the image will be resized to keep the aspect ratio and the size will be the maximum possible.
            ensure_multiple_of (`int`, *optional*, defaults to `self.ensure_multiple_of`):
                Ensure that the image size is a multiple of this value.
            resample (`int`, *optional*, defaults to `self.resample`):
                Resampling filter to use if resizing the image. This can be one of the enum `PILImageResampling`, Only
                has an effect if `do_resize` is set to `True`.
            do_rescale (`bool`, *optional*, defaults to `self.do_rescale`):
                Whether to rescale the image values between [0 - 1].
            rescale_factor (`float`, *optional*, defaults to `self.rescale_factor`):
                Rescale factor to rescale the image by if `do_rescale` is set to `True`.
            do_normalize (`bool`, *optional*, defaults to `self.do_normalize`):
                Whether to normalize the image.
            image_mean (`float` or `List[float]`, *optional*, defaults to `self.image_mean`):
                Image mean.
            image_std (`float` or `List[float]`, *optional*, defaults to `self.image_std`):
                Image standard deviation.
            do_reduce_labels (`bool`, *optional*, defaults to `self.do_reduce_labels`):
                Whether or not to reduce all label values of segmentation maps by 1. Usually used for datasets where 0
                is used for background, and background itself is not included in all classes of a dataset (e.g.
                ADE20k). The background label will be replaced by 255.
            return_tensors (`str` or `TensorType`, *optional*):
                The type of tensors to return. Can be one of:
                    - Unset: Return a list of `np.ndarray`.
                    - `TensorType.TENSORFLOW` or `'tf'`: Return a batch of type `tf.Tensor`.
                    - `TensorType.PYTORCH` or `'pt'`: Return a batch of type `torch.Tensor`.
                    - `TensorType.NUMPY` or `'np'`: Return a batch of type `np.ndarray`.
                    - `TensorType.JAX` or `'jax'`: Return a batch of type `jax.numpy.ndarray`.
            data_format (`ChannelDimension` or `str`, *optional*, defaults to `ChannelDimension.FIRST`):
                The channel dimension format for the output image. Can be one of:
                    - `ChannelDimension.FIRST`: image in (num_channels, height, width) format.
                    - `ChannelDimension.LAST`: image in (height, width, num_channels) format.
            input_data_format (`ChannelDimension` or `str`, *optional*):
                The channel dimension format for the input image. If unset, the channel dimension format is inferred
                from the input image. Can be one of:
                - `"channels_first"` or `ChannelDimension.FIRST`: image in (num_channels, height, width) format.
                - `"channels_last"` or `ChannelDimension.LAST`: image in (height, width, num_channels) format.
                - `"none"` or `ChannelDimension.NONE`: image in (height, width) format.
        re   )Úexpected_ndimszkInvalid image type. Must be of type PIL.Image.Image, numpy.ndarray, torch.Tensor, tf.Tensor or jax.ndarray.)
rM   rN   rO   rP   rQ   rR   Úsize_divisibilityrI   rJ   rK   )r^   rI   rM   rO   rR   rJ   rK   r'   rL   rN   rP   rQ   rS   r_   r)   rH   )r   rT   rI   rJ   rK   r'   rL   r)   Úlabels)ÚdataÚtensor_type)rI   rJ   r   r'   rL   rK   rM   rN   rO   rP   rQ   rR   rS   rT   r   r   ra   r   r~   rŠ   r   )r[   rŽ   rŒ   rI   rJ   r'   rL   rK   rM   rN   rO   rP   rQ   rR   rS   rT   r�   r_   r)   Úimgr”   r   s                         r6   Ú
preprocesszDPTImageProcessor.preprocess²  s2  € ðZ "+Ð!6‘I¸D¿N¹Nˆ	ØÐ'‰t¨T¯Y©YˆÜ˜TÓ"ˆØ1BÐ1NÑ-ÐTX×TjÑTjÐØ3EÐ3QÑ/ÐW[×WnÑWnÐØ'Ð3‘8¸¿¹ˆØ#-Ð#9‘Z¸t¿¹ˆ
Ø+9Ð+E™È4×K^ÑK^ˆØ'3Ð'?‘|ÀT×EVÑEVˆØ#-Ð#9‘Z¸t¿¹ˆ
Ø!*Ð!6‘I¸D¿N¹Nˆ	Ø!Ð-‘°4·;±;ˆØ'3Ð'?‘|ÀT×EVÑEVˆØ/?Ð/KÑ+ÐQU×QfÑQfÐä$ VÓ,ˆàÐ(Ü 3Ð4EÐVWÔ XÐä˜FÔ#Üð:óð ô 	&Ø!Ø)Ø%Ø!ØØØ*ØØØõ	
ð> ö%
ð$ ð# ×"Ñ"ØØ#Ø%Ø)ØØØ!Ø"3Ø#5Ø-Ø%Ø#Ø)Ø'Ø"3ð #õ ð
ˆð 
ð*  Ð'ˆàÐ(ð ):ö!ð %ð ×1Ñ1Ø%5Ø%5Ø'ØØ%Ø&7Ø'9Ø&7ð 2õ 	ð!Ðð !ð /ˆD�‰Nä °>ÔBÐBùòQ
ùò0!s   Ä%'FÅ FÚtarget_sizesc                 ó&  — |j                   }|�Ãt        |«      t        |«      k7  rt        d«      ‚t        |«      r|j	                  «       }g }t        t        |«      «      D ]k  }t        j                  j                  j                  ||   j                  d¬«      ||   dd¬«      }|d   j                  d¬«      }|j                  |«       Œm |S |j                  d¬«      }t        |j                  d   «      D �cg c]  }||   ‘Œ	 }}|S c c}w )a4  
        Converts the output of [`DPTForSemanticSegmentation`] into semantic segmentation maps. Only supports PyTorch.

        Args:
            outputs ([`DPTForSemanticSegmentation`]):
                Raw outputs of the model.
            target_sizes (`List[Tuple]` of length `batch_size`, *optional*):
                List of tuples corresponding to the requested final size (height, width) of each prediction. If unset,
                predictions will not be resized.

        Returns:
            semantic_segmentation: `List[torch.Tensor]` of length `batch_size`, where each item is a semantic
            segmentation map of shape (height, width) corresponding to the target_sizes entry (if `target_sizes` is
            specified). Each entry of each `torch.Tensor` correspond to a semantic class id.
        zTMake sure that you pass in as many target sizes as the batch dimension of the logitsr   )ÚdimÚbilinearF©rJ   ÚmodeÚalign_cornersr9   )ÚlogitsÚlenra   r   ÚnumpyÚrangeÚtorchÚnnÚ
functionalÚinterpolateÚ	unsqueezeÚargmaxÚappendÚshape)	r[   Úoutputsr˜   rŸ   Úsemantic_segmentationÚidxÚresized_logitsÚsemantic_mapÚis	            r6   Ú"post_process_semantic_segmentationz4DPTImageProcessor.post_process_semantic_segmentationP  s(  € ð" —‘ˆð Ð#Ü�6‹{œc ,Ó/Ò/Ü Øjóð ô ˜|Ô,Ø+×1Ñ1Ó3�à$&Ð!äœS ›[Ó)ò ;�Ü!&§¡×!4Ñ!4×!@Ñ!@Ø˜3‘K×)Ñ)¨aÐ)Ó0°|ÀCÑ7HÈzÐinð "Aó "�ð  .¨aÑ0×7Ñ7¸AÐ7Ó>�Ø%×,Ñ,¨\Õ:ð;ð %Ð$ð %+§M¡M°a MÓ$8Ð!ÜGLÐMb×MhÑMhÐijÑMkÓGlÖ$mÀ!Ð%:¸1Ó%=Ð$mÐ!Ð$mà$Ð$ùò %ns   Ã>Dr«   r   c                 ó¬  — t        | d«       |j                  }|�"t        |«      t        |«      k7  rt        d«      ‚g }|€dgt        |«      z  n|}t	        ||«      D ]s  \  }}|�Yt
        j                  j                  j                  |j                  d«      j                  d«      |dd¬«      j                  «       }|j                  d	|i«       Œu |S )
aÊ  
        Converts the raw output of [`DepthEstimatorOutput`] into final depth predictions and depth PIL images.
        Only supports PyTorch.

        Args:
            outputs ([`DepthEstimatorOutput`]):
                Raw outputs of the model.
            target_sizes (`TensorType` or `List[Tuple[int, int]]`, *optional*):
                Tensor of shape `(batch_size, 2)` or list of tuples (`Tuple[int, int]`) containing the target size
                (height, width) of each image in the batch. If left to None, predictions will not be resized.

        Returns:
            `List[Dict[str, TensorType]]`: A list of dictionaries of tensors representing the processed depth
            predictions.
        r£   Nz]Make sure that you pass in as many target sizes as the batch dimension of the predicted depthr   r9   ÚbicubicFrœ   Úpredicted_depth)r$   r´   r    ra   Úzipr£   r¤   r¥   r¦   r§   r†   r©   )r[   r«   r˜   r´   ÚresultsÚdepthÚtarget_sizes          r6   Úpost_process_depth_estimationz/DPTImageProcessor.post_process_depth_estimation{  sã   € ô( 	˜$ Ô(à!×1Ñ1ˆàÐ$¬3¨Ó+?Ä3À|ÓCTÒ+TÜØoóð ð ˆØ8DÐ8L˜�v¤ OÓ 4Ò4ÐR^ˆÜ"% o°|Ó"Dò 	7ÑˆE�;ØÐ&ÜŸ™×+Ñ+×7Ñ7Ø—O‘O AÓ&×0Ñ0°Ó3¸+ÈIÐejð 8ó ç‘'“)ð ð �N‰NÐ-¨uÐ5Õ6ð	7ð ˆr8   )NN)NNNNNNNNNNNNNN)NNNNNNNr-   )&Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úmodel_input_namesr   ÚBICUBICÚboolr   Ústrr;   r	   Úfloatr   r   rZ   r…   Úndarrayr   r   Úarrayrm   r   rr   ry   r~   rŠ   r�   r!   r„   r    ÚPILÚImager—   r   r±   r¹   Ú__classcell__)r]   s   @r6   rG   rG   i   s8  ø„ ñ)ðV (Ð(Ðð Ø#Ø'9×'AÑ'AØ"'Ø"#ØØ,3Ø!Ø:>Ø9=ØØ&*Ø!&ñ 1àð 1ð �3˜�8‰nð 1ð %ð	 1ð
  ð 1ð  ð 1ð ð 1ð ˜c 5˜jÑ)ð 1ð ð 1ð ˜U 5¨$¨u©+Ð#5Ñ6Ñ7ð 1ð ˜E %¨¨e©Ð"4Ñ5Ñ6ð 1ð ð 1ð ˜s‘mð 1ð ð 1ð  
õ! 1ðL #(Ø"#Ø'9×'AÑ'AØ>BØDHñ5
à�z‰zð5
ð �3˜�8‰nð5
ð  ð	5
ð
  ð5
ð %ð5
ð ˜e CÐ)9Ð$9Ñ:Ñ;ð5
ð $ E¨#Ð/?Ð*?Ñ$@ÑAð5
ð 
�‰ó5
ðv ?CØDHñ+wà�x‰xð+wð ð+wð ˜e CÐ)9Ð$9Ñ:Ñ;ð	+wð
 $ E¨#Ð/?Ð*?Ñ$@ÑAó+wð\ *ð °·±ó ð ,0Ø$(Ø#Ø'+Ø,0Ø,0Ø%)Ø*.Ø'+Ø:>Ø9=Ø!%Ø&*ØDHñ!(àð(ð # 4™.ð(ð ˜D‘>ð	(ð
 �3˜�8‰nð(ð %ð(ð $ D™>ð(ð % S™Mð(ð ˜T‘Nð(ð ! ™ð(ð ˜t‘nð(ð ˜U 5¨$¨u©+Ð#5Ñ6Ñ7ð(ð ˜E %¨¨e©Ð"4Ñ5Ñ6ð(ð ˜‘ð(ð ˜s‘mð(ð  $ E¨#Ð/?Ð*?Ñ$@ÑAó!(ðZ %)Ø#Ø'+Ø,0Ø,0Ø%)Ø*.Ø'+Ø:>Ø9=Ø!%Ø&*Ø>BØDHñ!1àð1ð ˜D‘>ð1ð �3˜�8‰nð	1ð
 %ð1ð $ D™>ð1ð % S™Mð1ð ˜T‘Nð1ð ! ™ð1ð ˜t‘nð1ð ˜U 5¨$¨u©+Ð#5Ñ6Ñ7ð1ð ˜E %¨¨e©Ð"4Ñ5Ñ6ð1ð ˜‘ð1ð ˜s‘mð1ð ˜e CÐ)9Ð$9Ñ:Ñ;ð1ð  $ E¨#Ð/?Ð*?Ñ$@ÑAð!1ð" 
�‰ó#1ðl %)Ø#Ø'+Ø,0Ø,0Ø+/ØDHñ' à$ð' ð ˜D‘>ð' ð �3˜�8‰nð	' ð
 %ð' ð $ D™>ð' ð % S™Mð' ð # 4™.ð' ð $ E¨#Ð/?Ð*?Ñ$@ÑAó' õTWñ
 %Ó&ð 37Ø$(Ø"Ø,0Ø,0Ø'+Ø%)Ø*.Ø'+Ø:>Ø9=Ø!%Ø&*Ø+/Ø;?Ø(8×(>Ñ(>ØDHñ'ZCàðZCð $ JÑ/ðZCð ˜D‘>ð	ZCð
 �s‰mðZCð $ D™>ðZCð % S™MðZCð %ðZCð ˜T‘NðZCð ! ™ðZCð ˜t‘nðZCð ˜U 5¨$¨u©+Ð#5Ñ6Ñ7ðZCð ˜E %¨¨e©Ð"4Ñ5Ñ6ðZCð ˜‘ðZCð ˜s‘mðZCð  # 4™.ð!ZCð" !  s¨J Ñ!7Ñ8ð#ZCð$ &ð%ZCð& $ E¨#Ð/?Ð*?Ñ$@ÑAð'ZCð( 
�‰�‰ò)ZCó 'ðZCñz)%ÈÈUÉó )%ð\ RVñ'à'ð'ð ˜u Z°°e¸CÀ¸H±oÑ1FÈÐ%LÑMÑNð'ð 
ˆd�3˜
�?Ñ#Ñ	$÷	'r8   rG   r-   )7r½   r/   Útypingr   r   r   r   r   r   r	   Úmodeling_outputsr   r¡   r…   Úimage_processing_utilsr   r   r   Úimage_transformsr   r   r   Úimage_utilsr   r   r   r   r   r   r   r   r   r   r   r   r   r   Úutilsr    r!   r"   r#   r$   r£   rÅ   Ú
get_loggerrº   r|   rÃ   r;   rÀ   rÁ   rE   rG   Ú__all__rX   r8   r6   ú<module>rÐ      sü   ðñ %ã ß N× NÑ Nñ Ý8ã ç UÑ Uß HÑ H÷÷ ÷ ÷ ÷ õ ñ ÔÛáÔÛð 
ˆ×	Ñ	˜HÓ	%€ð AEñ'#Ø—‘ð'#à�s˜H S™MÐ)Ñ*ð'#ð ð'#ð ð	'#ð
    cÐ+;Ð&;Ñ <Ñ=ð'#ð ˆ3�ˆ8�_ó'#ôTyÐ*ô yðx Ð
�r8   