

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







 __UpperCAmelCase     : str       		=     "Salesforce/blip-image-captioning-base"
 __UpperCAmelCase     : 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."
 )
 __UpperCAmelCase     : Any       		=     "image_captioner"
 __UpperCAmelCase     : Optional[Any]       		=     AutoModelForVisionaSeq

 __UpperCAmelCase     : Tuple       		=     ["image"]
 __UpperCAmelCase     : int       		=     ["text"]


 def __init__(      self							:      Tuple, *UpperCAmelCase__							:      Optional[int], **UpperCAmelCase__							:      Dict     ):
    requires_backends(self, ["vision"]     )
    super().__init__(*UpperCAmelCase__, **UpperCAmelCase__     )


 def  _lowercase			(      self							:      str, UpperCAmelCase__							:      "Image"     ):
    return self.pre_processor(images=UpperCAmelCase__, return_tensors="pt"     )


 def  _lowercase			(      self							:      str, UpperCAmelCase__							:      Optional[int]     ):
    return self.model.generate(**UpperCAmelCase__     )



 def  _lowercase			(      self							:      Dict, UpperCAmelCase__							:      List[Any]     ):
    return self.pre_processor.batch_decode(UpperCAmelCase__, skip_special_tokens=UpperCAmelCase__     )[0].strip()







"""simple docstring"""





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


_a							=							logging.get_logger(__name__)

_a							=							{
    'caidas/swin2sr-classicalsr-x2-64': (
        'https://huggingface.co/caidas/swin2sr-classicalsr-x2-64/resolve/main/config.json'
    ),
}




class  _lowerCAmelCase  (     lowercase       ):







 """simple docstring"""







 __UpperCAmelCase     : List[Any]       		=     "swin2sr"

 __UpperCAmelCase     : List[Any]       		=     {
     "hidden_size": "embed_dim",
     "num_attention_heads": "num_heads",
     "num_hidden_layers": "num_layers",
 }


 def __init__(      self							:      Any, UpperCAmelCase__							:      Dict=6_4, UpperCAmelCase__							:      List[Any]=1, UpperCAmelCase__							:      Dict=3, UpperCAmelCase__							:      Optional[Any]=1_8_0, UpperCAmelCase__							:      Any=[6, 6, 6, 6, 6, 6], UpperCAmelCase__							:      Dict=[6, 6, 6, 6, 6, 6], UpperCAmelCase__							:      Tuple=8, UpperCAmelCase__							:      Optional[int]=2.0, UpperCAmelCase__							:      List[str]=True, UpperCAmelCase__							:      Tuple=0.0, UpperCAmelCase__							:      Optional[Any]=0.0, UpperCAmelCase__							:      List[str]=0.1, UpperCAmelCase__							:      Dict="gelu", UpperCAmelCase__							:      Dict=False, UpperCAmelCase__							:      Dict=0.02, UpperCAmelCase__							:      Tuple=1E-5, UpperCAmelCase__							:      str=2, UpperCAmelCase__							:      str=1.0, UpperCAmelCase__							:      Optional[int]="1conv", UpperCAmelCase__							:      Dict="pixelshuffle", **UpperCAmelCase__							:      List[Any], ):
    super().__init__(**UpperCAmelCase__     )

    __lowercase								=						image_size
    __lowercase								=						patch_size
    __lowercase								=						num_channels
    __lowercase								=						embed_dim
    __lowercase								=						depths
    __lowercase								=						len(UpperCAmelCase__     )
    __lowercase								=						num_heads
    __lowercase								=						window_size
    __lowercase								=						mlp_ratio
    __lowercase								=						qkv_bias
    __lowercase								=						hidden_dropout_prob
    __lowercase								=						attention_probs_dropout_prob
    __lowercase								=						drop_path_rate
    __lowercase								=						hidden_act
    __lowercase								=						use_absolute_embeddings
    __lowercase								=						layer_norm_eps
    __lowercase								=						initializer_range
    __lowercase								=						upscale
    __lowercase								=						img_range
    __lowercase								=						resi_connection
    __lowercase								=						upsampler




