ó
    ‰Ž¡jº  ã                   óž   • S SK JrJr  SSKJrJr  SSKJrJrJ	r	  \" 5       (       a  S SK
Jr  SSKJr  \" \	" SS	9S
5       " S S\5      5       rg)é    )Ú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                   ó¢   ^ • \ rS rSrSrSrSrSrSrSS jr	SS\
\\4   4S jjrS rSS	 jrS
\\S\S   \\   4   S\S\\   4U 4S jjrSrU =r$ )ÚImageFeatureExtractionPipelineé   aì  
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).
FTc                 óV   • Uc  0 OUn0 nUb  X6S'   Ub  X&S'   SU;   a  US   US'   U0 U4$ )NÚpoolÚreturn_tensorsÚtimeout© )ÚselfÚimage_processor_kwargsr   r   ÚkwargsÚpreprocess_paramsÚpostprocess_paramss          Ú½C:\Users\johnn\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\transformers/pipelines/image_feature_extraction.pyÚ_sanitize_parametersÚ3ImageFeatureExtractionPipeline._sanitize_parameters5   sY   € Ø"8Ñ"@™BÐF\ÐàÐØÑØ)-˜vÑ&ØÑ%Ø3AÐ/Ñ0à˜ÓØ+1°)Ñ+<Ð˜iÑ(à  "Ð&8Ð8Ð8ó    Úreturnc                 óx   • [        XS9nU R                  " U4SS0UD6nUR                  U R                  5      nU$ )N)r   r   Úpt)r   Úimage_processorÚtoÚdtype)r   Úimager   r   Úmodel_inputss        r   Ú
preprocessÚ)ImageFeatureExtractionPipeline.preprocessC   s?   € Ü˜5Ñ2ˆØ×+Ò+¨EÑaÀ$ÐaÐJ`ÑaˆØ#—‘ t§z¡zÓ2ˆØÐr   c                 ó*   • U R                   " S0 UD6nU$ )Nr   )Úmodel)r   r'   Úmodel_outputss      r   Ú_forwardÚ'ImageFeatureExtractionPipeline._forwardI   s   € ØŸ
š
Ñ2 \Ñ2ˆØÐr   c                 óˆ   • Ub  UOSnU(       a  SU;  a  [        S5      eUS   nOUS   nU(       a  U$ UR                  5       $ )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   ÚpostprocessÚ*ImageFeatureExtractionPipeline.postprocessM   sV   € ØÑ'‰t¨UˆæØ mÓ3Ü Ø{óð ð $ OÑ4‰Gð $ AÑ&ˆGæØˆNØ�~‰~ÓÐr   ÚargszImage.Imager   c                 ó$   >• [         TU ]  " U0 UD6$ )aG  
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   r6   r   Ú	__class__s      €r   r9   Ú'ImageFeatureExtractionPipeline.__call__^   s   ø€ ô* ‰wÒ Ð0¨Ñ0Ð0r   r   )NNN)N)NF)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú_load_processorÚ_load_image_processorÚ_load_feature_extractorÚ_load_tokenizerr   ÚdictÚstrr	   r(   r-   r4   r   Úlistr   r9   Ú__static_attributes__Ú__classcell__)r:   s   @r   r   r      s†   ø† ñð0 €OØ ÐØ#ÐØ€Oô9ñÈ4ÐPSÐUbÐPbÑKcõ òô ð"1˜e C¨¸¸]Ñ8KÈTÐRUÉYÐ$VÑWð 1Ðcfð 1ÐkoÐpsÑkt÷ 1õ 1r   r   N)Útypingr   r   Úutilsr   r   Úbaser	   r
   r   ÚPILr   Úimage_utilsr   r   r   r   r   Ú<module>rO      sR   ðß ç ;ß CÑ Cñ ×ÑÝå(ñ Ù°Ñ6ðó	ô\1 Xó \1ó	ñ\1r   