





'''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

_A:					Dict							=				logging.get_logger(__name__)






@add_end_docstrings(UpperCAmelCase_							)
class UpperCAmelCase							(		UpperCAmelCase_							):



    def __init__(  self     ,			*__A     ,			**__A					):
     super().__init__(*__A     ,			**__A					)
     requires_backends(self     ,			'vision'					)
     self.check_model_type(__A					)



    def __call__(  self     ,			__A     ,			**__A					):
     return super().__call__(__A     ,			**__A					)



    def 					__lowerCamelCase						(  self     ,			**__A					):
     return {}, {}, {}



    def 					__lowerCamelCase						(  self     ,			__A					):
     __UpperCAmelCase					=   load_image(__A					)
     __UpperCAmelCase					=   image.size
     __UpperCAmelCase					=   self.image_processor(images=__A     ,			return_tensors=self.framework					)
     return model_inputs



    def 					__lowerCamelCase						(  self     ,			__A					):
     __UpperCAmelCase					=   self.model(**__A					)
     return model_outputs




    def 					__lowerCamelCase						(  self     ,			__A					):
     __UpperCAmelCase					=   model_outputs.predicted_depth
     __UpperCAmelCase					=   torch.nn.functional.interpolate(
         predicted_depth.unsqueeze(1					)     ,			size=self.image_size[::-1]     ,			mode='bicubic'     ,			align_corners=__A					)
     __UpperCAmelCase					=   prediction.squeeze().cpu().numpy()
     __UpperCAmelCase					=   (output * 255 / np.max(__A					)).astype('uint8'					)
     __UpperCAmelCase					=   Image.fromarray(__A					)
     __UpperCAmelCase					=   {}
     __UpperCAmelCase					=   predicted_depth
     __UpperCAmelCase					=   depth
     return output_dict












'''simple docstring'''




from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


_A:					str							=				{
    """configuration_whisper""": ["""WHISPER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """WhisperConfig""", """WhisperOnnxConfig"""],
    """feature_extraction_whisper""": ["""WhisperFeatureExtractor"""],
    """processing_whisper""": ["""WhisperProcessor"""],
    """tokenization_whisper""": ["""WhisperTokenizer"""],
}

try:
    if not is_tokenizers_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    _A:					Union[str, Any]							=				["""WhisperTokenizerFast"""]

try:
    if not is_torch_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    _A:					Optional[Any]							=				[
        """WHISPER_PRETRAINED_MODEL_ARCHIVE_LIST""",
        """WhisperForConditionalGeneration""",
        """WhisperModel""",
        """WhisperPreTrainedModel""",
        """WhisperForAudioClassification""",
    ]

try:
    if not is_tf_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    _A:					Dict							=				[
        """TF_WHISPER_PRETRAINED_MODEL_ARCHIVE_LIST""",
        """TFWhisperForConditionalGeneration""",
        """TFWhisperModel""",
        """TFWhisperPreTrainedModel""",
    ]

try:
    if not is_flax_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    _A:					Union[str, Any]							=				[
        """FlaxWhisperForConditionalGeneration""",
        """FlaxWhisperModel""",
        """FlaxWhisperPreTrainedModel""",
        """FlaxWhisperForAudioClassification""",
    ]


if TYPE_CHECKING:
    from .configuration_whisper import WHISPER_PRETRAINED_CONFIG_ARCHIVE_MAP, WhisperConfig, WhisperOnnxConfig
    from .feature_extraction_whisper import WhisperFeatureExtractor
    from .processing_whisper import WhisperProcessor
    from .tokenization_whisper import WhisperTokenizer

    try:
        if not is_tokenizers_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .tokenization_whisper_fast import WhisperTokenizerFast

    try:
        if not is_torch_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_whisper import (
            WHISPER_PRETRAINED_MODEL_ARCHIVE_LIST,
            WhisperForAudioClassification,
            WhisperForConditionalGeneration,
            WhisperModel,
            WhisperPreTrainedModel,
        )

    try:
        if not is_tf_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_tf_whisper import (
            TF_WHISPER_PRETRAINED_MODEL_ARCHIVE_LIST,
            TFWhisperForConditionalGeneration,
            TFWhisperModel,
            TFWhisperPreTrainedModel,
        )

    try:
        if not is_flax_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_flax_whisper import (
            FlaxWhisperForAudioClassification,
            FlaxWhisperForConditionalGeneration,
            FlaxWhisperModel,
            FlaxWhisperPreTrainedModel,
        )

else:
    import sys

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





