





import copy

from ...configuration_utils import PretrainedConfig
from ...utils import logging


__UpperCamelCase:  Union[str, Any]   =   logging.get_logger(__name__)

__UpperCamelCase:  Dict   =   {
    '''facebook/sam-vit-huge''': '''https://huggingface.co/facebook/sam-vit-huge/resolve/main/config.json''',
    '''facebook/sam-vit-large''': '''https://huggingface.co/facebook/sam-vit-large/resolve/main/config.json''',
    '''facebook/sam-vit-base''': '''https://huggingface.co/facebook/sam-vit-base/resolve/main/config.json''',
}


class 			__lowerCAmelCase				(					UpperCamelCase_			):


	'''simple docstring'''





	def __init__(	self:	str,				lowerCamelCase_:	List[Any]=256,				lowerCamelCase_:	List[str]=1024,				lowerCamelCase_:	int=16,				lowerCamelCase_:	Tuple=16,				lowerCamelCase_:	Any=4,				lowerCamelCase_:	Dict="gelu",				lowerCamelCase_:	Dict=1E-6,				**lowerCamelCase_:	int,				):
								super().__init__(**__SCREAMING_SNAKE_CASE )
								lowercase__				:			List[str]            =		hidden_size
								lowercase__				:			List[Any]            =		image_size
								lowercase__				:			Optional[Any]            =		patch_size
								lowercase__				:			Tuple            =		image_size // patch_size
								lowercase__				:			int            =		mask_input_channels
								lowercase__				:			Any            =		num_point_embeddings
								lowercase__				:			Dict            =		hidden_act
								lowercase__				:			Tuple            =		layer_norm_eps


class 			__lowerCAmelCase				(					UpperCamelCase_			):


	'''simple docstring'''





	def __init__(	self:	List[str],				lowerCamelCase_:	Optional[int]=256,				lowerCamelCase_:	int="relu",				lowerCamelCase_:	Optional[Any]=2048,				lowerCamelCase_:	str=2,				lowerCamelCase_:	List[str]=8,				lowerCamelCase_:	Union[str, Any]=2,				lowerCamelCase_:	Tuple=3,				lowerCamelCase_:	Tuple=3,				lowerCamelCase_:	Optional[int]=256,				lowerCamelCase_:	Dict=1E-6,				**lowerCamelCase_:	Union[str, Any],				):
								super().__init__(**__SCREAMING_SNAKE_CASE )
								lowercase__				:			int            =		hidden_size
								lowercase__				:			int            =		hidden_act
								lowercase__				:			List[Any]            =		mlp_dim
								lowercase__				:			Union[str, Any]            =		num_hidden_layers
								lowercase__				:			Tuple            =		num_attention_heads
								lowercase__				:			int            =		attention_downsample_rate
								lowercase__				:			Optional[Any]            =		num_multimask_outputs
								lowercase__				:			Optional[Any]            =		iou_head_depth
								lowercase__				:			Optional[int]            =		iou_head_hidden_dim
								lowercase__				:			Optional[int]            =		layer_norm_eps


class 			__lowerCAmelCase				(					UpperCamelCase_			):


	'''simple docstring'''





	def __init__(	self:	Any,				lowerCamelCase_:	Tuple=768,				lowerCamelCase_:	Any=256,				lowerCamelCase_:	Union[str, Any]=12,				lowerCamelCase_:	Optional[Any]=12,				lowerCamelCase_:	Optional[int]=3,				lowerCamelCase_:	Union[str, Any]=1024,				lowerCamelCase_:	Dict=16,				lowerCamelCase_:	str="gelu",				lowerCamelCase_:	Tuple=1E-06,				lowerCamelCase_:	Optional[int]=0.0,				lowerCamelCase_:	Union[str, Any]=1E-10,				lowerCamelCase_:	Any=True,				lowerCamelCase_:	Union[str, Any]=4.0,				lowerCamelCase_:	str=True,				lowerCamelCase_:	Dict=True,				lowerCamelCase_:	str=14,				lowerCamelCase_:	Optional[int]=[2, 5, 8, 11],				lowerCamelCase_:	int=128,				lowerCamelCase_:	Union[str, Any]=None,				**lowerCamelCase_:	str,				):
								super().__init__(**__SCREAMING_SNAKE_CASE )

								lowercase__				:			List[Any]            =		hidden_size
								lowercase__				:			Union[str, Any]            =		output_channels
								lowercase__				:			str            =		num_hidden_layers
								lowercase__				:			Any            =		num_attention_heads
								lowercase__				:			Dict            =		num_channels
								lowercase__				:			str            =		image_size
								lowercase__				:			Optional[int]            =		patch_size
								lowercase__				:			Union[str, Any]            =		hidden_act
								lowercase__				:			Any            =		layer_norm_eps
								lowercase__				:			Optional[int]            =		attention_dropout
								lowercase__				:			Union[str, Any]            =		initializer_range
								lowercase__				:			Dict            =		qkv_bias
								lowercase__				:			int            =		mlp_ratio
								lowercase__				:			str            =		use_abs_pos
								lowercase__				:			List[str]            =		use_rel_pos
								lowercase__				:			Any            =		window_size
								lowercase__				:			List[str]            =		global_attn_indexes
								lowercase__				:			Dict            =		num_pos_feats
								lowercase__				:			List[Any]            =		int(hidden_size * mlp_ratio ) if mlp_dim is None else mlp_dim


class 			__lowerCAmelCase				(					UpperCamelCase_			):


	'''simple docstring'''





	_A       	=							"""sam"""
	_A       	=							True

	def __init__(	self:	List[str],				lowerCamelCase_:	Tuple=None,				lowerCamelCase_:	int=None,				lowerCamelCase_:	Union[str, Any]=None,				lowerCamelCase_:	Union[str, Any]=0.0_2,				**lowerCamelCase_:	List[Any],				):
								super().__init__(**__SCREAMING_SNAKE_CASE )
								lowercase__				:			int            =		vision_config if vision_config is not None else {}
								lowercase__				:			Any            =		prompt_encoder_config if prompt_encoder_config is not None else {}
								lowercase__				:			Optional[int]            =		mask_decoder_config if mask_decoder_config is not None else {}

								if isinstance(__SCREAMING_SNAKE_CASE,				__SCREAMING_SNAKE_CASE ):
															lowercase__				:			Any            =		vision_config.to_dict()
								if isinstance(__SCREAMING_SNAKE_CASE,				__SCREAMING_SNAKE_CASE ):
															lowercase__				:			Union[str, Any]            =		prompt_encoder_config.to_dict()
								if isinstance(__SCREAMING_SNAKE_CASE,				__SCREAMING_SNAKE_CASE ):
															lowercase__				:			List[Any]            =		mask_decoder_config.to_dict()

								lowercase__				:			Optional[int]            =		SamVisionConfig(**__SCREAMING_SNAKE_CASE )
								lowercase__				:			Optional[Any]            =		SamPromptEncoderConfig(**__SCREAMING_SNAKE_CASE )
								lowercase__				:			Union[str, Any]            =		SamMaskDecoderConfig(**__SCREAMING_SNAKE_CASE )
								lowercase__				:			Dict            =		initializer_range





	def       snake_case__(	self:	Dict ):
								lowercase__				:			List[Any]            =		copy.deepcopy(self.__dict__ )
								lowercase__				:			int            =		self.vision_config.to_dict()
								lowercase__				:			int            =		self.prompt_encoder_config.to_dict()
								lowercase__				:			Any            =		self.mask_decoder_config.to_dict()
								lowercase__				:			Union[str, Any]            =		self.__class__.model_type
								return output









from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


__UpperCamelCase:  Any   =   {
    """configuration_deta""": ["""DETA_PRETRAINED_CONFIG_ARCHIVE_MAP""", """DetaConfig"""],
}

try:
			if not is_vision_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			__UpperCamelCase:  Tuple   =   ["""DetaImageProcessor"""]

try:
			if not is_torch_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			__UpperCamelCase:  List[str]   =   [
			    """DETA_PRETRAINED_MODEL_ARCHIVE_LIST""",
			    """DetaForObjectDetection""",
			    """DetaModel""",
			    """DetaPreTrainedModel""",
			]


if TYPE_CHECKING:
			from .configuration_deta import DETA_PRETRAINED_CONFIG_ARCHIVE_MAP, DetaConfig

			try:
						if not is_vision_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .image_processing_deta import DetaImageProcessor

			try:
						if not is_torch_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .modeling_deta import (
						    DETA_PRETRAINED_MODEL_ARCHIVE_LIST,
						    DetaForObjectDetection,
						    DetaModel,
						    DetaPreTrainedModel,
						)

else:
			import sys

			__UpperCamelCase:  int   =   _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)


