






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


a		:       Optional[Any]			     = logging.get_logger(__name__)

a		:       Dict			     = {
    'MIT/ast-finetuned-audioset-10-10-0.4593': (
        'https://huggingface.co/MIT/ast-finetuned-audioset-10-10-0.4593/resolve/main/config.json'
    ),
}
class     a    ( a__   ):



      """simple docstring"""


      a  : Optional[int]							       =	'''audio-spectrogram-transformer'''
      def __init__(      self					:			Optional[int]		,      __lowercase					:			int=768		,      __lowercase					:			Union[str, Any]=12		,      __lowercase					:			Dict=12		,      __lowercase					:			str=3072		,      __lowercase					:			Optional[int]="gelu"		,      __lowercase					:			Tuple=0.0		,      __lowercase					:			Any=0.0		,      __lowercase					:			Union[str, Any]=0.02		,      __lowercase					:			Dict=1e-1_2		,      __lowercase					:			Optional[Any]=16		,      __lowercase					:			Any=True		,      __lowercase					:			Tuple=10		,      __lowercase					:			Union[str, Any]=10		,      __lowercase					:			str=1024		,      __lowercase					:			Tuple=128		,      **__lowercase					:			int		,      )							->      Tuple:
        super().__init__(**SCREAMING_SNAKE_CASE__					)

        __UpperCAmelCase							:	Optional[Any]           =  hidden_size
        __UpperCAmelCase							:	str           =  num_hidden_layers
        __UpperCAmelCase							:	int           =  num_attention_heads
        __UpperCAmelCase							:	Tuple           =  intermediate_size
        __UpperCAmelCase							:	Optional[int]           =  hidden_act
        __UpperCAmelCase							:	Any           =  hidden_dropout_prob
        __UpperCAmelCase							:	List[Any]           =  attention_probs_dropout_prob
        __UpperCAmelCase							:	int           =  initializer_range
        __UpperCAmelCase							:	int           =  layer_norm_eps
        __UpperCAmelCase							:	Dict           =  patch_size
        __UpperCAmelCase							:	Optional[int]           =  qkv_bias
        __UpperCAmelCase							:	Optional[int]           =  frequency_stride
        __UpperCAmelCase							:	Any           =  time_stride
        __UpperCAmelCase							:	Optional[int]           =  max_length
        __UpperCAmelCase							:	Any           =  num_mel_bins




"""simple docstring"""




from typing import List, Union

import numpy as np

from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends
from .base import PIPELINE_INIT_ARGS, Pipeline


if is_vision_available():
					from PIL import Image

					from ..image_utils import load_image

if is_torch_available():
					import torch

					from ..models.auto.modeling_auto import MODEL_FOR_DEPTH_ESTIMATION_MAPPING

UpperCAmelCase__      :    List[str]    							= logging.get_logger(__name__)



@add_end_docstrings(a__  )
class 	lowerCAmelCase_						(a__  ):


				"""simple docstring"""



				def __init__(self   ,       *SCREAMING_SNAKE_CASE__   ,       **SCREAMING_SNAKE_CASE__    )					->		Tuple:



											"""simple docstring"""




											super().__init__(*SCREAMING_SNAKE_CASE__   ,       **SCREAMING_SNAKE_CASE__    )
											requires_backends(self   ,       """vision"""    )
											self.check_model_type(SCREAMING_SNAKE_CASE__    )



				def __call__(self   ,       SCREAMING_SNAKE_CASE__   ,       **SCREAMING_SNAKE_CASE__    )					->		List[str]:



											"""simple docstring"""




											return super().__call__(SCREAMING_SNAKE_CASE__   ,       **SCREAMING_SNAKE_CASE__    )



				def 	__magic_name__    (self   ,       **SCREAMING_SNAKE_CASE__    )					->		Any:



											"""simple docstring"""




											return {}, {}, {}



				def 	__magic_name__    (self   ,       SCREAMING_SNAKE_CASE__    )					->		Union[str, Any]:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:       List[Any]           =   load_image(SCREAMING_SNAKE_CASE__    )
											SCREAMING_SNAKE_CASE__						:       Any           =   image.size
											SCREAMING_SNAKE_CASE__						:       Optional[Any]           =   self.image_processor(images=SCREAMING_SNAKE_CASE__   ,       return_tensors=self.framework    )
											return model_inputs



				def 	__magic_name__    (self   ,       SCREAMING_SNAKE_CASE__    )					->		int:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:       Tuple           =   self.model(**SCREAMING_SNAKE_CASE__    )
											return model_outputs



				def 	__magic_name__    (self   ,       SCREAMING_SNAKE_CASE__    )					->		Optional[int]:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:       List[Any]           =   model_outputs.predicted_depth
											SCREAMING_SNAKE_CASE__						:       Optional[int]           =   torch.nn.functional.interpolate(
											    predicted_depth.unsqueeze(1    )   ,       size=self.image_size[::-1]   ,       mode="""bicubic"""   ,       align_corners=SCREAMING_SNAKE_CASE__    )
											SCREAMING_SNAKE_CASE__						:       Optional[Any]           =   prediction.squeeze().cpu().numpy()
											SCREAMING_SNAKE_CASE__						:       Any           =   (output * 2_55 / np.max(SCREAMING_SNAKE_CASE__    )).astype("""uint8"""    )
											SCREAMING_SNAKE_CASE__						:       List[str]           =   Image.fromarray(SCREAMING_SNAKE_CASE__    )
											SCREAMING_SNAKE_CASE__						:       str           =   {}
											SCREAMING_SNAKE_CASE__						:       Any           =   predicted_depth
											SCREAMING_SNAKE_CASE__						:       Dict           =   depth
											return output_dict




