
"""simple docstring"""





import numpy as np
from cva import COLOR_BGR2GRAY, cvtColor, imread
from numpy import array, uinta
from PIL import Image

from digital_image_processing import change_contrast as cc
from digital_image_processing import convert_to_negative as cn
from digital_image_processing import sepia as sp
from digital_image_processing.dithering import burkes as bs
from digital_image_processing.edge_detection import canny
from digital_image_processing.filters import convolve as conv
from digital_image_processing.filters import gaussian_filter as gg
from digital_image_processing.filters import local_binary_pattern as lbp
from digital_image_processing.filters import median_filter as med
from digital_image_processing.filters import sobel_filter as sob
from digital_image_processing.resize import resize as rs

UpperCamelCase_					:						str				= imread(R'''digital_image_processing/image_data/lena_small.jpg''')
UpperCamelCase_					:						Any				= cvtColor(img, COLOR_BGR2GRAY)
def 							A_     ():

     '''simple docstring'''





     A_				 =						cn.convert_to_negative(__a				)
     # assert negative_img array for at least one True
     assert negative_img.any()
def 							A_     ():

     '''simple docstring'''





     with Image.open("digital_image_processing/image_data/lena_small.jpg"				) as img:
          # Work around assertion for response
          assert str(cc.change_contrast(__a				,   110				)				).startswith(
              "<PIL.Image.Image image mode=RGB size=100x100 at"				)
def 							A_     ():

     '''simple docstring'''





     A_				 =						canny.gen_gaussian_kernel(9				,   sigma=1.4				)
     # Assert ambiguous array
     assert resp.all()
def 							A_     ():

     '''simple docstring'''





     A_				 =						imread("digital_image_processing/image_data/lena_small.jpg"				,   0				)
     # assert ambiguous array for all == True
     assert canny_img.all()
     A_				 =						canny.canny(__a				)
     # assert canny array for at least one True
     assert canny_array.any()
def 							A_     ():

     '''simple docstring'''





     assert gg.gaussian_filter(__a				,   5				,   sigma=0.9				).all()
def 							A_     ():

     '''simple docstring'''





     A_				 =						array([[0.25, 0.5, 0.25], [0.5, -3, 0.5], [0.25, 0.5, 0.25]]				)
     A_				 =						conv.img_convolve(__a				,   __a				).astype(__a				)
     assert res.any()
def 							A_     ():

     '''simple docstring'''





     assert med.median_filter(__a				,   3				).any()
def 							A_     ():

     '''simple docstring'''





     A_ ,    A_				 =						sob.sobel_filter(__a				)
     assert grad.any() and theta.any()
def 							A_     ():

     '''simple docstring'''





     A_				 =						sp.make_sepia(__a				,   20				)
     assert sepia.all()
def 							A_     (__a = "digital_image_processing/image_data/lena_small.jpg"				):

     '''simple docstring'''





     A_				 =						bs.Burkes(imread(__a				,   1				)				,   120				)
     burkes.process()
     assert burkes.output_img.any()
def 							A_     (__a = "digital_image_processing/image_data/lena_small.jpg"				,   ):

     '''simple docstring'''





     A_				 =						rs.NearestNeighbour(imread(__a				,   1				)				,   400				,   200				)
     nn.process()
     assert nn.output.any()




def 							A_     ():

     '''simple docstring'''





     A_				 =						"digital_image_processing/image_data/lena.jpg"

     # Reading the image and converting it to grayscale.
     A_				 =						imread(__a				,   0				)

     # Test for get_neighbors_pixel function() return not None
     A_				 =						0
     A_				 =						0
     A_				 =						image[x_coordinate][y_coordinate]

     A_				 =						lbp.get_neighbors_pixel(
         __a				,   __a				,   __a				,   __a				)

     assert neighbors_pixels is not None

     # Test for local_binary_pattern function()
     # Create a numpy array as the same height and width of read image
     A_				 =						np.zeros((image.shape[0], image.shape[1])				)

     # Iterating through the image and calculating the local binary pattern value
     # for each pixel.
     for i in range(0				,   image.shape[0]				):
          for j in range(0				,   image.shape[1]				):
               A_				 =						lbp.local_binary_value(__a				,   __a				,   __a				)

     assert lbp_image.any()






"""simple docstring"""





from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices


UpperCamelCase_					:						Optional[int]				= logging.get_logger(__name__)

UpperCamelCase_					:						Dict				= {
    '''microsoft/focalnet-tiny''': '''https://huggingface.co/microsoft/focalnet-tiny/resolve/main/config.json''',
}



class __lowerCAmelCase				(					_lowercase     ,				_lowercase      ):




			"""simple docstring"""







			snake_case	      =				"focalnet"




			def __init__(				self						:					Any       ,   _snake_case						:					Optional[int]=224       ,   _snake_case						:					List[str]=4       ,   _snake_case						:					Any=3       ,   _snake_case						:					List[Any]=96       ,   _snake_case						:					Union[str, Any]=False       ,   _snake_case						:					Optional[Any]=[192, 384, 768, 768]       ,   _snake_case						:					List[str]=[2, 2, 6, 2]       ,   _snake_case						:					Any=[2, 2, 2, 2]       ,   _snake_case						:					List[Any]=[3, 3, 3, 3]       ,   _snake_case						:					Optional[Any]="gelu"       ,   _snake_case						:					Dict=4.0       ,   _snake_case						:					List[Any]=0.0       ,   _snake_case						:					List[str]=0.1       ,   _snake_case						:					Optional[Any]=False       ,   _snake_case						:					Any=1e-4       ,   _snake_case						:					str=False       ,   _snake_case						:					Optional[int]=False       ,   _snake_case						:					Tuple=False       ,   _snake_case						:					Any=0.0_2       ,   _snake_case						:					List[Any]=1e-5       ,   _snake_case						:					Union[str, Any]=32       ,   _snake_case						:					Tuple=None       ,   _snake_case						:					Any=None       ,   **_snake_case						:					Tuple       ,   )      -> str:







								"""simple docstring"""
								super().__init__(**_snake_case	)

								A_				 =						image_size
								A_				 =						patch_size
								A_				 =						num_channels
								A_				 =						embed_dim
								A_				 =						use_conv_embed
								A_				 =						hidden_sizes
								A_				 =						depths
								A_				 =						focal_levels
								A_				 =						focal_windows
								A_				 =						hidden_act
								A_				 =						mlp_ratio
								A_				 =						hidden_dropout_prob
								A_				 =						drop_path_rate
								A_				 =						use_layerscale
								A_				 =						layerscale_value
								A_				 =						use_post_layernorm
								A_				 =						use_post_layernorm_in_modulation
								A_				 =						normalize_modulator
								A_				 =						initializer_range
								A_				 =						layer_norm_eps
								A_				 =						encoder_stride
								A_				 =						["stem"] + [F'stage{idx}' for idx in range(1       ,   len(self.depths	) + 1	)]
								A_ ,    A_				 =						get_aligned_output_features_output_indices(
								    out_features=_snake_case       ,   out_indices=_snake_case       ,   stage_names=self.stage_names	)




