§
    ‚Štjº  ã                   óº   — d dl mZmZ ddlmZmZ ddlmZmZm	Z	  e¦   «         rd dl
mZ ddlmZ  e e	d¬	¦  «        d
¦  «         G d„ de¦  «        ¦   «         ZdS )é    )ÚAnyÚUnioné   )Úadd_end_docstringsÚis_vision_availableé   )ÚGenericTensorÚPipelineÚbuild_pipeline_init_args)ÚImage)Ú
load_imageT)Úhas_image_processora  
        image_processor_kwargs (`dict`, *optional*):
                Additional dictionary of keyword arguments passed along to the image processor e.g.
                {"size": {"height": 100, "width": 100}}
        pool (`bool`, *optional*, defaults to `False`):
            Whether or not to return the pooled output. If `False`, the model will return the raw hidden states.
    c                   ó¬   ‡ — e Zd ZdZdZdZdZdZdd„Zdde	e
ef         fd„Zd„ Zdd	„Zd
ee
ded         ee
         f         dedee         fˆ fd„Zˆ xZS )ÚImageFeatureExtractionPipelinea,  
    Image feature extraction pipeline uses no model head. This pipeline extracts the hidden states from the base
    transformer, which can be used as features in downstream tasks.

    Example:

    ```python
    >>> from transformers import pipeline

    >>> extractor = pipeline(model="google/vit-base-patch16-224", task="image-feature-extraction")
    >>> result = extractor("https://huggingface.co/datasets/Narsil/image_dummy/raw/main/parrots.png", return_tensors=True)
    >>> result.shape  # This is a tensor of shape [1, sequence_length, hidden_dimension] representing the input image.
    torch.Size([1, 197, 768])
    ```

    Learn more about the basics of using a pipeline in the [pipeline tutorial](../pipeline_tutorial)

    This image feature extraction pipeline can currently be loaded from [`pipeline`] using the task identifier:
    `"image-feature-extraction"`.

    All vision models may be used for this pipeline. See a list of all models, including community-contributed models on
    [huggingface.co/models](https://huggingface.co/models).
    FTNc                 óV   — |€i n|}i }|�||d<   |�||d<   d|v r|d         |d<   |i |fS )NÚpoolÚreturn_tensorsÚtimeout© )ÚselfÚimage_processor_kwargsr   r   ÚkwargsÚpreprocess_paramsÚpostprocess_paramss          úm/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/transformers/pipelines/image_feature_extraction.pyÚ_sanitize_parametersz3ImageFeatureExtractionPipeline._sanitize_parameters5   sd   € Ø"8Ð"@˜B˜BÐF\ÐàÐØÐØ)-Ð˜vÑ&ØÐ%Ø3AÐÐ/Ñ0à˜ÐÐØ+1°)Ô+<Ð˜iÑ(à  "Ð&8Ð8Ð8ó    Úreturnc                 ó|   — t          ||¬¦  «        } | j        |fddi|¤Ž}|                     | j        ¦  «        }|S )N)r   r   Úpt)r   Úimage_processorÚtoÚdtype)r   Úimager   r   Úmodel_inputss        r   Ú
preprocessz)ImageFeatureExtractionPipeline.preprocessC   sM   € Ý˜5¨'Ð2Ñ2Ô2ˆØ+�tÔ+¨EÐaÐaÀ$ÐaÐJ`ÐaÐaˆØ#—’ t¤zÑ2Ô2ˆØÐr   c                 ó    —  | j         di |¤Ž}|S )Nr   )Úmodel)r   r%   Úmodel_outputss      r   Ú_forwardz'ImageFeatureExtractionPipeline._forwardI   s   € Ø"˜œ
Ð2Ð2 \Ð2Ð2ˆØÐr   c                 óŠ   — |�|nd}|rd|vrt          d¦  «        ‚|d         }n|d         }|r|S |                     ¦   «         S )NFÚpooler_outputzeNo pooled output was returned. Make sure the model has a `pooler` layer when using the `pool` option.r   )Ú
ValueErrorÚtolist)r   r)   r   r   Úoutputss        r   Úpostprocessz*ImageFeatureExtractionPipeline.postprocessM   so   € ØÐ'ˆtˆt¨Uˆàð 	'Ø mÐ3Ð3Ý Ø{ñô ð ð $ OÔ4ˆGˆGð $ AÔ&ˆGàð 	ØˆNØ�~Š~ÑÔÐr   ÚargszImage.Imager   c                 ó6   •—  t          ¦   «         j        |i |¤ŽS )aÇ  
        Extract the features of the input(s).

        Args:
            images (`str`, `list[str]`, `PIL.Image` or `list[PIL.Image]`):
                The pipeline handles three types of images:

                - A string containing a http link pointing to an image
                - A string containing a local path to an image
                - An image loaded in PIL directly

                The pipeline accepts either a single image or a batch of images, which must then be passed as a string.
                Images in a batch must all be in the same format: all as http links, all as local paths, or all as PIL
                images.
            timeout (`float`, *optional*, defaults to None):
                The maximum time in seconds to wait for fetching images from the web. If None, no timeout is used and
                the call may block forever.
        Return:
            A nested list of `float`: The features computed by the model.
        )ÚsuperÚ__call__)r   r1   r   Ú	__class__s      €r   r4   z'ImageFeatureExtractionPipeline.__call__^   s!   ø€ ð*  �u‰wŒwÔ Ð0¨Ð0Ð0Ð0r   )NNN)N)NF)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú_load_processorÚ_load_image_processorÚ_load_feature_extractorÚ_load_tokenizerr   ÚdictÚstrr	   r&   r*   r0   r   Úlistr   r4   Ú__classcell__)r5   s   @r   r   r      s÷   ø€ € € € € ðð ð0 €OØ ÐØ#ÐØ€Oð9ð 9ð 9ð 9ðð È4ÐPSÐUbÐPbÔKcð ð ð ð ðð ð ð ð  ð  ð  ð"1˜e C¨¸¸]Ô8KÈTÐRUÌYÐ$VÔWð 1Ðcfð 1ÐkoÐpsÔktð 1ð 1ð 1ð 1ð 1ð 1ð 1ð 1ð 1ð 1r   r   N)Útypingr   r   Úutilsr   r   Úbaser	   r
   r   ÚPILr   Úimage_utilsr   r   r   r   r   ú<module>rG      sú   ðØ Ð Ð Ð Ð Ð Ð Ð à ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ø CÐ CÐ CÐ CÐ CÐ CÐ CÐ CÐ CÐ Cð ÐÑÔð )ØÐÐÐÐÐà(Ð(Ð(Ð(Ð(Ð(ð ÐØÐ°Ð6Ñ6Ô6ðñ	ô 	ð\1ð \1ð \1ð \1ð \1 Xñ \1ô \1ñ	ô 	ð\1ð \1ð \1r   