


"""simple docstring"""

import numpy as np
from cva import destroyAllWindows, imread, imshow, waitKey





class    lowerCamelCase__						:
      def __init__(		self	:	Tuple      ,       A_	:	List[str]      ,       A_	:	int      ,       A_	:	int							):






       '''simple docstring'''


       if dst_width < 0 or dst_height < 0:
        raise ValueError("""Destination width/height should be > 0"""							)

       __lowercase									=	img
       __lowercase									=	img.shape[1]
       __lowercase									=	img.shape[0]
       __lowercase									=	dst_width
       __lowercase									=	dst_height

       __lowercase									=	self.src_w / self.dst_w
       __lowercase									=	self.src_h / self.dst_h

       __lowercase									=	__lowercase									=	(
           np.ones((self.dst_h, self.dst_w, 3)      ,       np.uinta							) * 2_5_5
       )
      def SCREAMING_SNAKE_CASE_	(		self	:	Optional[Any]							):






       '''simple docstring'''


       for i in range(self.dst_h							):
        for j in range(self.dst_w							):
         __lowercase									=	self.img[self.get_y(A_							)][self.get_x(A_							)]
      def SCREAMING_SNAKE_CASE_	(		self	:	Tuple      ,       A_	:	int							):






       '''simple docstring'''


       return int(self.ratio_x * x							)






      def SCREAMING_SNAKE_CASE_	(		self	:	Dict      ,       A_	:	int							):






       '''simple docstring'''


       return int(self.ratio_y * y							)


if __name__ == "__main__":
       UpperCAmelCase__							,      UpperCAmelCase__  							=800, 600
       UpperCAmelCase__  							=imread("image_data/lena.jpg", 1)
       UpperCAmelCase__  							=NearestNeighbour(im, dst_w, dst_h)
       n.process()

       imshow(
           f"""Image resized from: {im.shape[1]}x{im.shape[0]} to {dst_w}x{dst_h}""", n.output
       )
       waitKey(0)
       destroyAllWindows()




"""simple docstring"""

import warnings
from collections import OrderedDict
from typing import Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


UpperCAmelCase__  							=logging.get_logger(__name__)

UpperCAmelCase__  							={
    "nvidia/segformer-b0-finetuned-ade-512-512": (
        "https://huggingface.co/nvidia/segformer-b0-finetuned-ade-512-512/resolve/main/config.json"
    ),
    # See all SegFormer models at https://huggingface.co/models?filter=segformer
}





class    lowerCamelCase__						(		_a    ):
      a :     Optional[int]											=		"""segformer"""
      def __init__(		self	:	str      ,       A_	:	Optional[int]=3      ,       A_	:	Any=4      ,       A_	:	Optional[int]=[2, 2, 2, 2]      ,       A_	:	str=[8, 4, 2, 1]      ,       A_	:	Any=[3_2, 6_4, 1_6_0, 2_5_6]      ,       A_	:	Union[str, Any]=[7, 3, 3, 3]      ,       A_	:	Any=[4, 2, 2, 2]      ,       A_	:	int=[1, 2, 5, 8]      ,       A_	:	Union[str, Any]=[4, 4, 4, 4]      ,       A_	:	Optional[Any]="gelu"      ,       A_	:	List[str]=0.0      ,       A_	:	Any=0.0      ,       A_	:	Optional[Any]=0.1      ,       A_	:	List[str]=0.02      ,       A_	:	Tuple=0.1      ,       A_	:	Optional[Any]=1e-6      ,       A_	:	Optional[int]=2_5_6      ,       A_	:	Optional[Any]=2_5_5      ,       **A_	:	Union[str, Any]      ,       ):






       '''simple docstring'''


       super().__init__(**A_							)

       if "reshape_last_stage" in kwargs and kwargs["reshape_last_stage"] is False:
        warnings.warn(
            """Reshape_last_stage is set to False in this config. This argument is deprecated and will soon be"""
            """ removed, as the behaviour will default to that of reshape_last_stage = True."""      ,       A_      ,       )

       __lowercase									=	num_channels
       __lowercase									=	num_encoder_blocks
       __lowercase									=	depths
       __lowercase									=	sr_ratios
       __lowercase									=	hidden_sizes
       __lowercase									=	patch_sizes
       __lowercase									=	strides
       __lowercase									=	mlp_ratios
       __lowercase									=	num_attention_heads
       __lowercase									=	hidden_act
       __lowercase									=	hidden_dropout_prob
       __lowercase									=	attention_probs_dropout_prob
       __lowercase									=	classifier_dropout_prob
       __lowercase									=	initializer_range
       __lowercase									=	drop_path_rate
       __lowercase									=	layer_norm_eps
       __lowercase									=	decoder_hidden_size
       __lowercase									=	kwargs.get("""reshape_last_stage"""      ,       A_							)
       __lowercase									=	semantic_loss_ignore_index






class    lowerCamelCase__						(		_a    ):
      a :     List[str]											=		version.parse("""1.11"""    )
      @property
      def SCREAMING_SNAKE_CASE_	(		self	:	Any							):






       '''simple docstring'''


       return OrderedDict(
           [
               ("""pixel_values""", {0: """batch""", 1: """num_channels""", 2: """height""", 3: """width"""}),
           ]							)
      @property
      def SCREAMING_SNAKE_CASE_	(		self	:	int							):






       '''simple docstring'''


       return 1e-4






      @property
      def SCREAMING_SNAKE_CASE_	(		self	:	int							):






       '''simple docstring'''


       return 1_2
