


"""simple docstring"""


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


_snake_case        =				logging.get_logger(__name__)

_snake_case        =				{
    "microsoft/focalnet-tiny": "https://huggingface.co/microsoft/focalnet-tiny/resolve/main/config.json",
}



class 	_a   (   _a		,		_a			):
    a_     :					Optional[int]   							=     """focalnet"""
    def __init__(			self				:       List[Any]				,       SCREAMING_SNAKE_CASE__				:       List[Any]=2_24				,       SCREAMING_SNAKE_CASE__				:       Any=4				,       SCREAMING_SNAKE_CASE__				:       str=3				,       SCREAMING_SNAKE_CASE__				:       Dict=96				,       SCREAMING_SNAKE_CASE__				:       Dict=False				,       SCREAMING_SNAKE_CASE__				:       int=[1_92, 3_84, 7_68, 7_68]				,       SCREAMING_SNAKE_CASE__				:       Optional[int]=[2, 2, 6, 2]				,       SCREAMING_SNAKE_CASE__				:       Tuple=[2, 2, 2, 2]				,       SCREAMING_SNAKE_CASE__				:       str=[3, 3, 3, 3]				,       SCREAMING_SNAKE_CASE__				:       str="gelu"				,       SCREAMING_SNAKE_CASE__				:       List[Any]=4.0				,       SCREAMING_SNAKE_CASE__				:       Optional[Any]=0.0				,       SCREAMING_SNAKE_CASE__				:       str=0.1				,       SCREAMING_SNAKE_CASE__				:       Union[str, Any]=False				,       SCREAMING_SNAKE_CASE__				:       List[Any]=1e-4				,       SCREAMING_SNAKE_CASE__				:       str=False				,       SCREAMING_SNAKE_CASE__				:       Tuple=False				,       SCREAMING_SNAKE_CASE__				:       Tuple=False				,       SCREAMING_SNAKE_CASE__				:       Tuple=0.02				,       SCREAMING_SNAKE_CASE__				:       List[Any]=1e-5				,       SCREAMING_SNAKE_CASE__				:       Any=32				,       SCREAMING_SNAKE_CASE__				:       Optional[Any]=None				,       SCREAMING_SNAKE_CASE__				:       Union[str, Any]=None				,       **SCREAMING_SNAKE_CASE__				:       Union[str, Any]				,       ):
          super().__init__(**A_					)

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







"""simple docstring"""

from pathlib import Path

import cva
import numpy as np
from matplotlib import pyplot as plt


def lowerCAmelCase_   (					UpperCamelCase__						:			np.ndarray					, UpperCamelCase__						:			np.ndarray					, UpperCamelCase__						:			np.ndarray					, UpperCamelCase__						:			int					, UpperCamelCase__						:			int			):






 """simple docstring"""







 __lowercase						=						cva.getAffineTransform(UpperCamelCase__					, UpperCamelCase__			)
 return cva.warpAffine(UpperCamelCase__					, UpperCamelCase__					, (rows, cols)			)


if __name__ == "__main__":
       # read original image
       UpperCAmelCase__					=cva.imread(
           str(Path(__file__).resolve().parent.parent / "image_data" / "lena.jpg")
       )
       # turn image in gray scale value
       UpperCAmelCase__					=cva.cvtColor(image, cva.COLOR_BGR2GRAY)
       # get image shape
       UpperCAmelCase__				,   UpperCAmelCase__					=gray_img.shape

       # set different points to rotate image
       UpperCAmelCase__					=np.array([[50, 50], [200, 50], [50, 200]], np.floataa)
       UpperCAmelCase__					=np.array([[10, 100], [200, 50], [100, 250]], np.floataa)
       UpperCAmelCase__					=np.array([[50, 50], [150, 50], [120, 200]], np.floataa)
       UpperCAmelCase__					=np.array([[10, 100], [80, 50], [180, 250]], np.floataa)

       # add all rotated images in a list
       UpperCAmelCase__					=[
           gray_img,
           get_rotation(gray_img, ptsa, ptsa, img_rows, img_cols),
           get_rotation(gray_img, ptsa, ptsa, img_rows, img_cols),
           get_rotation(gray_img, ptsa, ptsa, img_rows, img_cols),
       ]

       # plot different image rotations
       UpperCAmelCase__					=plt.figure(1)
       UpperCAmelCase__					=["Original", "Rotation 1", "Rotation 2", "Rotation 3"]
       for i, image in enumerate(images):
              plt.subplot(2, 2, i + 1), plt.imshow(image, "gray")
              plt.title(titles[i])
              plt.axis("off")
              plt.subplots_adjust(left=0.0, bottom=0.05, right=1.0, top=0.95)
       plt.show()
