




# 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 						__lowerCAmelCase      (      __magic_name__					):
							UpperCamelCase__   	=    '''Salesforce/blip-image-captioning-base'''
							UpperCamelCase__   	=    (
							    '''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.'''
							)
							UpperCamelCase__   	=    '''image_captioner'''
							UpperCamelCase__   	=    AutoModelForVisionaSeq

							UpperCamelCase__   	=    ['''image''']
							UpperCamelCase__   	=    ['''text''']
							def __init__(		self		:Union[str, Any]						, *__magic_name__		:Tuple						, **__magic_name__		:Any							):







								'''simple docstring'''







								requires_backends(self						, ["""vision"""]							)
								super().__init__(*__magic_name__						, **__magic_name__							)
							def  lowerCamelCase__				(		self		:Any						, __magic_name__		:"Image"							):







								'''simple docstring'''







								return self.pre_processor(images=__magic_name__						, return_tensors="""pt"""							)
							def  lowerCamelCase__				(		self		:List[str]						, __magic_name__		:Union[str, Any]							):







								'''simple docstring'''







								return self.model.generate(**__magic_name__							)





							def  lowerCamelCase__				(		self		:Dict						, __magic_name__		:List[Any]							):







								'''simple docstring'''







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







import inspect
import warnings
from typing import Any, Dict, Optional, Union

from packaging import version





def 						__A						(      *__lowerCamelCase				,     __lowerCamelCase = None				,     __lowerCamelCase=True				,     __lowerCamelCase=2       ) ->			Dict:
	from .. import __version__

	a									=				take_from
	a									=				()
	if not isinstance(args[0]				,     __lowerCamelCase       ):
		a									=				(args,)

	for attribute, version_name, message in args:
		if version.parse(version.parse(__lowerCamelCase       ).base_version       ) >= version.parse(__lowerCamelCase       ):
			raise ValueError(
			    f'The deprecation tuple {(attribute, version_name, message)} should be removed since diffusers\''
			    f' version {__version__} is >= {version_name}'       )

		a									=				None
		if isinstance(__lowerCamelCase				,     __lowerCamelCase       ) and attribute in deprecated_kwargs:
			values += (deprecated_kwargs.pop(__lowerCamelCase       ),)
			a									=				f'The `{attribute}` argument is deprecated and will be removed in version {version_name}.'
		elif hasattr(__lowerCamelCase				,     __lowerCamelCase       ):
			values += (getattr(__lowerCamelCase				,     __lowerCamelCase       ),)
			a									=				f'The `{attribute}` attribute is deprecated and will be removed in version {version_name}.'
		elif deprecated_kwargs is None:
			a									=				f'`{attribute}` is deprecated and will be removed in version {version_name}.'

		if warning is not None:
			a									=				warning + """ """ if standard_warn else """"""
			warnings.warn(warning + message				,     __lowerCamelCase				,     stacklevel=__lowerCamelCase       )

	if isinstance(__lowerCamelCase				,     __lowerCamelCase       ) and len(__lowerCamelCase       ) > 0:
		a									=				inspect.getouterframes(inspect.currentframe()       )[1]
		a									=				call_frame.filename
		a									=				call_frame.lineno
		a									=				call_frame.function
		a							,					a									=				next(iter(deprecated_kwargs.items()       )       )
		raise TypeError(f'{function} in {filename} line {line_number-1} got an unexpected keyword argument `{key}`'       )

	if len(__lowerCamelCase       ) == 0:
		return
	elif len(__lowerCamelCase       ) == 1:
		return values[0]
	return values

