






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


UpperCamelCase							       =    logging.get_logger(__name__)

UpperCamelCase							       =    {
    """google/canine-s""": """https://huggingface.co/google/canine-s/resolve/main/config.json""",
    # See all CANINE models at https://huggingface.co/models?filter=canine
}




class    lowercase_    (_UpperCAmelCase     ):
      A__	:		Dict       			=				'''canine'''






      def __init__(    self     ,     a_=7_6_8     ,     a_=1_2     ,     a_=1_2     ,     a_=3_0_7_2     ,     a_="gelu"     ,     a_=0.1     ,     a_=0.1     ,     a_=1_6_3_8_4     ,     a_=1_6     ,     a_=0.02     ,     a_=1E-12     ,     a_=0     ,     a_=0xE000     ,     a_=0xE001     ,     a_=4     ,     a_=4     ,     a_=8     ,     a_=1_6_3_8_4     ,     a_=1_2_8     ,     **a_     ,     )	->Optional[Any]:







        '''simple docstring'''


        super().__init__(pad_token_id=a_     ,     bos_token_id=a_     ,     eos_token_id=a_     ,     **a_	)

        _a							=	max_position_embeddings
        _a							=	hidden_size
        _a							=	num_hidden_layers
        _a							=	num_attention_heads
        _a							=	intermediate_size
        _a							=	hidden_act
        _a							=	hidden_dropout_prob
        _a							=	attention_probs_dropout_prob
        _a							=	initializer_range
        _a							=	type_vocab_size
        _a							=	layer_norm_eps

        # Character config:
        _a							=	downsampling_rate
        _a							=	upsampling_kernel_size
        _a							=	num_hash_functions
        _a							=	num_hash_buckets
        _a							=	local_transformer_stride










"""simple docstring"""




# Copyright 2023 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import TYPE_CHECKING

from ..models.auto import AutoModelForVisionaSeq
from ..utils import requires_backends
from .base import PipelineTool


if TYPE_CHECKING:
     from PIL import Image




class    lowercase_    (_UpperCAmelCase     ):
      A__	:		str       			=				'''Salesforce/blip-image-captioning-base'''
      A__	:		Optional[int]       			=				(
          '''This is a tool that generates a description of an image. It takes an input named `image` which should be the '''
          '''image to caption, and returns a text that contains the description in English.'''
      )
      A__	:		str       			=				'''image_captioner'''
      A__	:		Tuple       			=				AutoModelForVisionaSeq

      A__	:		Tuple       			=				['''image''']
      A__	:		List[Any]       			=				['''text''']






      def __init__(    self     ,     *a_     ,     **a_	)	->Union[str, Any]:







        '''simple docstring'''


        requires_backends(self     ,     ["vision"]	)
        super().__init__(*a_     ,     **a_	)






      def 			lowerCamelCase__    (    self     ,     a_	)	->Union[str, Any]:







        '''simple docstring'''


        return self.pre_processor(images=a_     ,     return_tensors="pt"	)






      def 			lowerCamelCase__    (    self     ,     a_	)	->List[Any]:







        '''simple docstring'''


        return self.model.generate(**a_	)






      def 			lowerCamelCase__    (    self     ,     a_	)	->Tuple:







        '''simple docstring'''


        return self.pre_processor.batch_decode(a_     ,     skip_special_tokens=a_	)[0].strip()


