


from collections import OrderedDict
from typing import Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


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

lowerCAmelCase				:List[Any]        =      {
    '''google/mobilenet_v2_1.4_224''': '''https://huggingface.co/google/mobilenet_v2_1.4_224/resolve/main/config.json''',
    '''google/mobilenet_v2_1.0_224''': '''https://huggingface.co/google/mobilenet_v2_1.0_224/resolve/main/config.json''',
    '''google/mobilenet_v2_0.75_160''': '''https://huggingface.co/google/mobilenet_v2_0.75_160/resolve/main/config.json''',
    '''google/mobilenet_v2_0.35_96''': '''https://huggingface.co/google/mobilenet_v2_0.35_96/resolve/main/config.json''',
    # See all MobileNetV2 models at https://huggingface.co/models?filter=mobilenet_v2
}
class _lowerCamelCase	(						__snake_case							):



		'''simple docstring'''







		A_     :      Optional[Any]				   =    'mobilenet_v2'







		def __init__( self		:						List[Any]  ,					_A		:						Any=3  ,					_A		:						Optional[Any]=224  ,					_A		:						List[str]=1.0  ,					_A		:						List[Any]=8  ,					_A		:						Optional[Any]=8  ,					_A		:						str=6  ,					_A		:						int=32  ,					_A		:						List[Any]=True  ,					_A		:						Optional[int]=True  ,					_A		:						Dict="relu6"  ,					_A		:						Optional[int]=True  ,					_A		:						Dict=0.8  ,					_A		:						Tuple=0.02  ,					_A		:						Dict=0.001  ,					_A		:						List[str]=255  ,					**_A		:						Optional[Any]  ,					)  ->			Union[str, Any]:
			super().__init__(**_A      )

			if depth_multiplier <= 0:
				raise ValueError('depth_multiplier must be greater than zero.'      )

			__magic_name__	:   Tuple					     =					num_channels
			__magic_name__	:   int					     =					image_size
			__magic_name__	:   Union[str, Any]					     =					depth_multiplier
			__magic_name__	:   Tuple					     =					depth_divisible_by
			__magic_name__	:   int					     =					min_depth
			__magic_name__	:   Optional[int]					     =					expand_ratio
			__magic_name__	:   Dict					     =					output_stride
			__magic_name__	:   str					     =					first_layer_is_expansion
			__magic_name__	:   Any					     =					finegrained_output
			__magic_name__	:   List[Any]					     =					hidden_act
			__magic_name__	:   Any					     =					tf_padding
			__magic_name__	:   Optional[int]					     =					classifier_dropout_prob
			__magic_name__	:   Tuple					     =					initializer_range
			__magic_name__	:   List[Any]					     =					layer_norm_eps
			__magic_name__	:   Dict					     =					semantic_loss_ignore_index







class _lowerCamelCase	(						__snake_case							):



		'''simple docstring'''







		A_     :      Dict				   =    version.parse("""1.11"""							)







		@property
		def        __lowerCAmelCase		( self		:						Tuple      )  ->			Mapping[str, Mapping[int, str]]:
			return OrderedDict([('pixel_values', {0: 'batch'})]      )







		@property
		def        __lowerCAmelCase		( self		:						Union[str, Any]      )  ->			Mapping[str, Mapping[int, str]]:
			if self.task == "image-classification":
				return OrderedDict([('logits', {0: 'batch'})]      )
			else:
				return OrderedDict([('last_hidden_state', {0: 'batch'}), ('pooler_output', {0: 'batch'})]      )







		@property
		def        __lowerCAmelCase		( self		:						Dict      )  ->			float:
			return 1E-4



'''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 _lowerCamelCase	(						lowercase__							):



		'''simple docstring'''







		A_     :      Any				   =    """Salesforce/blip-image-captioning-base"""
		A_     :      Any				   =    (
		    """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_     :      List[str]				   =    """image_captioner"""
		A_     :      Optional[Any]				   =    AutoModelForVisionaSeq

		A_     :      Any				   =    ["""image"""]
		A_     :      Union[str, Any]				   =    ["""text"""]







		def __init__( self		:						Dict  ,					*_A		:						Dict  ,					**_A		:						Any      )  ->			Dict:
			requires_backends(self  ,					['vision']      )
			super().__init__(*_A  ,					**_A      )







		def        __lowerCAmelCase		( self		:						Tuple  ,					_A		:						"Image"      )  ->			Union[str, Any]:
			return self.pre_processor(images=_A  ,					return_tensors='pt'      )







		def        __lowerCAmelCase		( self		:						Optional[Any]  ,					_A		:						str      )  ->			List[Any]:
			return self.model.generate(**_A      )







		def        __lowerCAmelCase		( self		:						int  ,					_A		:						Optional[int]      )  ->			Union[str, Any]:
			return self.pre_processor.batch_decode(_A  ,					skip_special_tokens=_A      )[0].strip()