





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


snake_case_				=			logging.get_logger(__name__)

snake_case_				=			{
    'unc-nlp/lxmert-base-uncased': 'https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/config.json',
}

class 		SCREAMING_SNAKE_CASE__				(       _UpperCAmelCase  ):
      A_						:				Any							=    'lxmert'
      A_						:				List[Any]							=    {}


      def __init__(self       :      int				,			a__       :      Any=3_0522				,			a__       :      Optional[int]=768				,			a__       :      Dict=12				,			a__       :      int=9500				,			a__       :      Dict=1600				,			a__       :      Any=400				,			a__       :      List[str]=3072				,			a__       :      List[str]="gelu"				,			a__       :      int=0.1				,			a__       :      Dict=0.1				,			a__       :      str=512				,			a__       :      Any=2				,			a__       :      Any=0.0_2				,			a__       :      Union[str, Any]=1E-12				,			a__       :      str=9				,			a__       :      Optional[Any]=5				,			a__       :      int=5				,			a__       :      Optional[int]=2048				,			a__       :      Union[str, Any]=4				,			a__       :      Any=6.6_7				,			a__       :      List[Any]=True				,			a__       :      str=True				,			a__       :      Optional[Any]=True				,			a__       :      Dict=True				,			a__       :      Dict=True				,			a__       :      int=True				,			a__       :      Union[str, Any]=True				,			**a__       :      List[Any]				,			):





         """simple docstring"""



         __snake_case							       =   vocab_size
         __snake_case							       =   hidden_size
         __snake_case							       =   num_attention_heads
         __snake_case							       =   hidden_act
         __snake_case							       =   intermediate_size
         __snake_case							       =   hidden_dropout_prob
         __snake_case							       =   attention_probs_dropout_prob
         __snake_case							       =   max_position_embeddings
         __snake_case							       =   type_vocab_size
         __snake_case							       =   initializer_range
         __snake_case							       =   layer_norm_eps
         __snake_case							       =   num_qa_labels
         __snake_case							       =   num_object_labels
         __snake_case							       =   num_attr_labels
         __snake_case							       =   l_layers
         __snake_case							       =   x_layers
         __snake_case							       =   r_layers
         __snake_case							       =   visual_feat_dim
         __snake_case							       =   visual_pos_dim
         __snake_case							       =   visual_loss_normalizer
         __snake_case							       =   task_matched
         __snake_case							       =   task_mask_lm
         __snake_case							       =   task_obj_predict
         __snake_case							       =   task_qa
         __snake_case							       =   visual_obj_loss
         __snake_case							       =   visual_attr_loss
         __snake_case							       =   visual_feat_loss
         __snake_case							       =   {'''vision''': r_layers, '''cross_encoder''': x_layers, '''language''': l_layers}
         super().__init__(**a__      )








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

snake_case_				=			logging.get_logger(__name__)

@add_end_docstrings(_UpperCAmelCase  )
class 		SCREAMING_SNAKE_CASE__				(       _UpperCAmelCase  ):


      def __init__(self       :      Optional[int]				,			*a__       :      Any				,			**a__       :      Dict      ):





         """simple docstring"""



         super().__init__(*a__				,			**a__      )
         requires_backends(self				,			'''vision'''      )
         self.check_model_type(a__      )


      def __call__(self       :      Optional[int]				,			a__       :      Union[str, List[str], "Image.Image", List["Image.Image"]]				,			**a__       :      Tuple      ):





         """simple docstring"""



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


      def    a (self       :      Dict				,			**a__       :      Any      ):





         """simple docstring"""



         return {}, {}, {}


      def    a (self       :      List[str]				,			a__       :      Any      ):





         """simple docstring"""



         __snake_case							       =   load_image(a__      )
         __snake_case							       =   image.size
         __snake_case							       =   self.image_processor(images=a__				,			return_tensors=self.framework      )
         return model_inputs


      def    a (self       :      int				,			a__       :      List[Any]      ):





         """simple docstring"""



         __snake_case							       =   self.model(**a__      )
         return model_outputs


      def    a (self       :      int				,			a__       :      str      ):





         """simple docstring"""



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

