+
    œ°³jÜ  ã                   ó  € ^ RI Ht ^ RIHtHtHt ^RIHtHtH	t	H
t
Ht ^RIHtHt ]	! 4       '       d   ^ RIHt ^RIHt ]! 4       '       d   ^ RIt^RIHt ]
P,                  ! ]4      t]! ]! R	R
7      4       ! R R]4      4       tR# )é    )ÚUserDict)ÚAnyÚUnionÚoverload)Úadd_end_docstringsÚis_torch_availableÚis_vision_availableÚloggingÚrequires_backends)ÚPipelineÚbuild_pipeline_init_args)ÚImage)Ú
load_imageN)Ú6MODEL_FOR_ZERO_SHOT_IMAGE_CLASSIFICATION_MAPPING_NAMEST)Úhas_image_processorc                   ó¶   a a€ ] tR t^t oRtRtRtRtRtV 3R lt	]
V3R lR l4       t]
V3R lR l4       tV3R	 lV 3R
 lltRR ltRR ltR tR tRtVtV ;t# )Ú#ZeroShotImageClassificationPipelineað  
Zero shot image classification pipeline using `CLIPModel`. This pipeline predicts the class of an image when you
provide an image and a set of `candidate_labels`.

Example:

```python
>>> from transformers import pipeline

>>> classifier = pipeline(model="google/siglip-so400m-patch14-384")
>>> classifier(
...     "https://huggingface.co/datasets/Narsil/image_dummy/raw/main/parrots.png",
...     candidate_labels=["animals", "humans", "landscape"],
... )
[{'score': 0.965, 'label': 'animals'}, {'score': 0.03, 'label': 'humans'}, {'score': 0.005, 'label': 'landscape'}]

>>> classifier(
...     "https://huggingface.co/datasets/Narsil/image_dummy/raw/main/parrots.png",
...     candidate_labels=["black and white", "photorealist", "painting"],
... )
[{'score': 0.996, 'label': 'black and white'}, {'score': 0.003, 'label': 'photorealist'}, {'score': 0.0, 'label': 'painting'}]
```

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

This image classification pipeline can currently be loaded from [`pipeline`] using the following task identifier:
`"zero-shot-image-classification"`.

See the list of available models on
[huggingface.co/models](https://huggingface.co/models?filter=zero-shot-image-classification).
FTc                ój   <€ \         SV `  ! R/ VB  \        V R 4       V P                  \        4       R# )ÚvisionN© )ÚsuperÚ__init__r   Úcheck_model_typer   )ÚselfÚkwargsÚ	__class__s   &,€Úv/home/luca/screen-checking/.venv/lib/python3.14/site-packages/transformers/pipelines/zero_shot_image_classification.pyr   Ú,ZeroShotImageClassificationPipeline.__init__C   s,   ø€ Ü‰ÒÑ"˜6Ò"ä˜$ Ô)Ø×ÑÔTÖUó    c                ó|   <€ V ^8„  d   QhRS[ S[R3,          RS[S[,          RS[RS[S[S[S[3,          ,          /# ©é   ÚimagezImage.ImageÚcandidate_labelsr   Úreturn©r   ÚstrÚlistr   Údict)ÚformatÚ__classdict__s   "€r   Ú__annotate__Ú0ZeroShotImageClassificationPipeline.__annotate__J   sH   ø€ ÷ #ñ #Ù™3 Ð-Õ.ð#ÙBFÁsÅ)ð#ÙWZð#á	‰d‘3™�8�nÕ	ñ#r   c                ó   € R # ©Nr   ©r   r#   r$   r   s   &&&,r   Ú__call__Ú,ZeroShotImageClassificationPipeline.__call__I   s   € ñ  #r   c                ó¦   <€ V ^8„  d   QhRS[ S[,          S[ R,          ,          RS[ S[,          RS[RS[ S[ S[S[S[3,          ,          ,          /# r!   )r(   r'   r   r)   )r*   r+   s   "€r   r,   r-   O   sQ   ø€ ÷ )ñ )Ù™#•Y¡ mÕ!4Õ4ð)ÙHLÉSÍ	ð)Ù]`ð)á	‰d‘4™™S˜•>Õ"Õ	#ñ)r   c                ó   € R # r/   r   r0   s   &&&,r   r1   r2   N   s   € ñ &)r   c                óè   <€ V ^8„  d   QhRS[ S[S[S[,          RS[R,          3,          RS[S[,          RS[RS[S[S[S[3,          ,          S[S[S[S[S[3,          ,          ,          ,          /# r!   r&   )r*   r+   s   "€r   r,   r-   S   sx   ø€ ÷ )Tñ )Tá‘S™$™s�) ]±D¸Õ4GÐGÕHð)Tñ ™s�)ð)Tñ ð	)Tñ
 
‰d‘3™�8�nÕ	¡¡T©$©s±C¨x­.Õ%9Õ :Õ	:ñ)Tr   c                óx   <€ RV9   d   VP                  R4      pVf   \        R4      h\        SV `  ! V3RV/VB # )a;  
Assign labels to the image(s) passed as inputs.

Args:
    image (`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

    candidate_labels (`list[str]`):
        The candidate labels for this image. They will be formatted using *hypothesis_template*.

    hypothesis_template (`str`, *optional*, defaults to `"This is a photo of {}"`):
        The format used in conjunction with *candidate_labels* to attempt the image classification by
        replacing the placeholder with the candidate_labels. Pass "{}" if *candidate_labels* are
        already formatted.

    timeout (`float`, *optional*, defaults to None):
        The maximum time in seconds to wait for fetching images from the web. If None, no timeout is set and
        the call may block forever.

Return:
    A list of dictionaries containing one entry per proposed label. Each dictionary contains the
    following keys:
    - **label** (`str`) -- One of the suggested *candidate_labels*.
    - **score** (`float`) -- The score attributed by the model to that label. It is a value between
        0 and 1, computed as the `softmax` of `logits_per_image`.
ÚimageszSCannot call the zero-shot-image-classification pipeline without an images argument!r$   )ÚpopÚ
ValueErrorr   r1   )r   r#   r$   r   r   s   &&&,€r   r1   r2   S   sH   ø€ ðJ �vÔØ—J‘J˜xÓ(ˆEØŠ=ÜÐrÓsÐsÜ‰wÒ ÑSÐ8HÐSÈFÑSÐSr   c                ó‚   € / pR V9   d   VR ,          VR &   RV9   d   VR,          VR&   RV9   d   VR,          VR&   V/ / 3# )r$   ÚtimeoutÚhypothesis_templater   )r   Útokenizer_kwargsr   Úpreprocess_paramss   &&, r   Ú_sanitize_parametersÚ8ZeroShotImageClassificationPipeline._sanitize_parameters~   sa   € ØÐØ Ô'Ø4:Ð;MÕ4NÐÐ0Ñ1Ø˜ÔØ+1°)Õ+<Ð˜iÑ(Ø  FÔ*Ø7=Ð>SÕ7TÐÐ3Ñ4à  " bÐ(Ð(r   c                óª  € Vf   / p\        WR7      pV P                  V.RR7      pVP                  V P                  4      pW&R&   V Uu. uF  qsP	                  V4      NK  	  ppRR/p	RV P
                  P                  P                  9   d   V	P                  R^@RR	7       V	P                  V4       V P                  ! V3R
R/V	B p
V
.VR&   V# u upi )N)r;   Úpt)r7   Úreturn_tensorsr$   ÚpaddingTÚsiglipÚ
max_length)rD   rF   Ú
truncationrC   Útext_inputs)
r   Úimage_processorÚtoÚdtyper*   ÚmodelÚconfigÚ
model_typeÚupdateÚ	tokenizer)r   r#   r$   r<   r;   r=   ÚinputsÚxÚ	sequencesÚtokenizer_default_kwargsrH   s   &&&&&&     r   Ú
preprocessÚ.ZeroShotImageClassificationPipeline.preprocess‰   sã   € ð Ò#Ø!ÐÜ˜5Ô2ˆØ×%Ñ%¨e¨WÀTÐ%ÓJˆØ—‘˜4Ÿ:™:Ó&ˆØ%5Ð!Ñ"Ù<LÓMÑ<L°q×/Ñ/°Ö2Ñ<Lˆ	ÐMØ$-¨tÐ#4Ð Ø�t—z‘z×(Ñ(×3Ñ3Ô3Ø$×+Ñ+°LÈRÐ\`Ð+ÔaØ ×'Ñ'Ð(8Ô9Ø—n’n YÑ`¸tÐ`ÐG_Ñ`ˆØ!, ˆˆ}ÑØˆùò Ns   Á
Cc                ó   € VP                  R 4      pVP                  R4      p\        V^ ,          \        4      '       d   V^ ,          pMV^ ,          ^ ,          pV P                  ! R/ VBVB pR VRVP                  /pV# )r$   rH   Úlogitsr   )r8   Ú
isinstancer   rL   Úlogits_per_image)r   Úmodel_inputsr$   rH   ÚoutputsÚmodel_outputss   &&    r   Ú_forwardÚ,ZeroShotImageClassificationPipeline._forward    s†   € Ø'×+Ñ+Ð,>Ó?ÐØ"×&Ñ& }Ó5ˆÜ�k !•n¤h×/Ò/Ø% a�.‰Kð & a�.¨Õ+ˆKà—*’*Ñ;˜{Ð;¨lÑ;ˆð Ð 0Ø�g×.Ñ.ð
ˆð Ðr   c                ó,  € VP                  R 4      pVR,          ^ ,          pRV P                  P                  P                  9   dP   \        P
                  ! V4      P                  R4      pVP                  4       p\        V\        4      '       g   V.pMJVP                  RR7      P                  R4      pVP                  4       p\        V\        4      '       g   V.p\        \        WR4      R R7       UUu. uF  w  rgRVRV/NK  	  pppV# u uppi )	r$   rX   rE   )Údimc                 ó   € V ^ ,          ) # )r   r   )rR   s   &r   Ú<lambda>ÚAZeroShotImageClassificationPipeline.postprocess.<locals>.<lambda>Á   s   € Ð_`ÐabÕ_cÑ^cr   )ÚkeyÚscoreÚlabeléÿÿÿÿ)r8   rL   rM   rN   ÚtorchÚsigmoidÚsqueezeÚtolistrY   r(   ÚsoftmaxÚsortedÚzip)	r   r]   r$   rX   ÚprobsÚscoresrf   Úcandidate_labelÚresults	   &&       r   ÚpostprocessÚ/ZeroShotImageClassificationPipeline.postprocess±   sõ   € Ø(×,Ñ,Ð-?Ó@ÐØ˜xÕ(¨Õ+ˆØ�t—z‘z×(Ñ(×3Ñ3Ô3Ü—M’M &Ó)×1Ñ1°"Ó5ˆEØ—\‘\“^ˆFÜ˜f¤d×+Ò+Ø ˜�øà—N‘N r�NÓ*×2Ñ2°2Ó6ˆEØ—\‘\“^ˆFÜ˜f¤d×+Ò+Ø ˜�ô +1´°VÓ1NÑTcÕ*dô
á*dÑ&�ð �e˜W oÓ6Ù*dð 	ñ 
ð ˆùó	
s   Ã:Dr   r/   )NzThis is a photo of {}.NN)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú_load_processorÚ_load_image_processorÚ_load_feature_extractorÚ_load_tokenizerr   r   r1   r?   rU   r^   rt   Ú__static_attributes__Ú__classdictcell__Ú__classcell__)r   r+   s   @@r   r   r      sw   ù‡ € ñð@ €OØ ÐØ#ÐØ€OõVð ÷#ó ð#ð ÷)ó ð)÷)Tó )TôV	)ôò.÷"ò r   r   )Úcollectionsr   Útypingr   r   r   Úutilsr   r   r	   r
   r   Úbaser   r   ÚPILr   Úimage_utilsr   ri   Úmodels.auto.modeling_autor   Ú
get_loggerrv   Úloggerr   r   r   r   Ú<module>r‹      sy   ðÝ  ß 'Ñ '÷õ ÷ 5ñ ×ÒÝå(á×ÒÛåbð 
×	Ò	˜HÓ	%€ñ Ñ,ÀÔFÓGôf¨(ó fó Hòfr   