+
    QV-j˜&  ã                   ó4  € ^ RI HtHtHt ^ RIt^RIHt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 tR	 t ! R
 R]4      t]! ]! RR7      R4       ! R R]4      4       tR# )é    )ÚAnyÚUnionÚoverloadN)ÚExplicitEnumÚadd_end_docstringsÚis_torch_availableÚis_vision_availableÚloggingÚrequires_backends)ÚPipelineÚbuild_pipeline_init_args)ÚImage)Ú
load_image)Ú,MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMESc                 óL   € R R \         P                  ! V ) 4      ,           ,          # )g      ð?)ÚnpÚexp)Ú_outputss   &Ú|/Volumes/fast/ai/experiments/ui-tars-smoke/.venv/lib/python3.14/site-packages/transformers/pipelines/image_classification.pyÚsigmoidr   +   s   € Ø�#œŸš ˜yÓ)Õ)Õ*Ð*ó    c                 óž   € \         P                  ! V RRR7      p\         P                  ! W,
          4      pW"P                  RRR7      ,          # )é   T)ÚaxisÚkeepdimséÿÿÿÿ)r   Úmaxr   Úsum)r   ÚmaxesÚshifted_exps   &  r   Úsoftmaxr!   0   s;   € Ü�FŠF�8 "¨tÔ4€EÜ—&’&˜Õ)Ó*€KØŸ™¨b¸4˜Ó@Õ@Ð@r   c                   ó"   € ] tR t^7tRtRtRtRtR# )ÚClassificationFunctionr   r!   Únone© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__ÚSIGMOIDÚSOFTMAXÚNONEÚ__static_attributes__r%   r   r   r#   r#   7   s   † Ø€GØ€GØ„Dr   r#   T)Úhas_image_processoraZ  
        function_to_apply (`str`, *optional*, defaults to `"default"`):
            The function to apply to the model outputs in order to retrieve the scores. Accepts four different values:

            - `"default"`: if the model has a single label, will apply the sigmoid function on the output. If the model
              has several labels, will apply the softmax function on the output.
            - `"sigmoid"`: Applies the sigmoid function on the output.
            - `"softmax"`: Applies the softmax function on the output.
            - `"none"`: Does not apply any function on the output.c                   óÞ   a a€ ] tR t^=t oRt]P                  tRtRt	Rt
RtV 3R ltR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 tRR ltV3R ltRtVtV ;t# )ÚImageClassificationPipelineaž  
Image classification pipeline using any `AutoModelForImageClassification`. This pipeline predicts the class of an
image.

Example:

```python
>>> from transformers import pipeline

>>> classifier = pipeline(model="microsoft/beit-base-patch16-224-pt22k-ft22k")
>>> classifier("https://huggingface.co/datasets/Narsil/image_dummy/raw/main/parrots.png")
[{'score': 0.442, 'label': 'macaw'}, {'score': 0.088, 'label': 'popinjay'}, {'score': 0.075, 'label': 'parrot'}, {'score': 0.073, 'label': 'parodist, lampooner'}, {'score': 0.046, 'label': 'poll, poll_parrot'}]
```

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:
`"image-classification"`.

See the list of available models on
[huggingface.co/models](https://huggingface.co/models?filter=image-classification).
FTc                ój   <€ \         SV `  ! V/ VB  \        V R 4       V P                  \        4       R# )ÚvisionN)ÚsuperÚ__init__r   Úcheck_model_typer   )ÚselfÚargsÚkwargsÚ	__class__s   &*,€r   r4   Ú$ImageClassificationPipeline.__init__g   s.   ø€ Ü‰Ò˜$Ð) &Ò)Ü˜$ Ô)Ø×ÑÔJÖKr   c                ó¢   € / pVe   W4R&   / pVe   WR&   \        V\        4      '       d   \        VP                  4       4      pVe   W%R&   V/ V3# )NÚtimeoutÚtop_kÚfunction_to_apply)Ú
isinstanceÚstrr#   Úlower)r6   r=   r>   r<   Úpreprocess_paramsÚpostprocess_paramss   &&&&  r   Ú_sanitize_parametersÚ0ImageClassificationPipeline._sanitize_parametersl   sj   € ØÐØÒØ+2˜iÑ(ØÐØÒØ*/˜wÑ'ÜÐ'¬×-Ò-Ü 6Ð7H×7NÑ7NÓ7PÓ QÐØÒ(Ø6GÐ2Ñ3Ø  "Ð&8Ð8Ð8r   c          	      óf   <€ V ^8„  d   QhRS[ S[R3,          RS[RS[S[S[S[3,          ,          /# ©é   ÚinputszImage.Imager8   Úreturn)r   r@   r   ÚlistÚdict)ÚformatÚ__classdict__s   "€r   Ú__annotate__Ú(ImageClassificationPipeline.__annotate__z   s4   ø€ ×eÑe™u¡S¨-Ð%7Õ8ÐeÁCÐeÉDÑQUÑVYÑ[^ÐV^ÕQ_ÕL`Ñer   c                ó   € R # ©Nr%   ©r6   rI   r8   s   &&,r   Ú__call__Ú$ImageClassificationPipeline.__call__y   s   € Ùber   c          
      ó�   <€ V ^8„  d   QhRS[ S[,          S[ R,          ,          RS[RS[ S[ S[S[S[3,          ,          ,          /# rG   )rK   r@   r   rL   )rM   rN   s   "€r   rO   rP   }   s?   ø€ ×qÑq™t¡C�y©4°Õ+>Õ>ÐqÉ#ÐqÑRVÑW[Ñ\`ÑadÑfiÐaiÕ\jÕWkÕRlÑqr   c                ó   € R # rR   r%   rS   s   &&,r   rT   rU   |   s   € Ùnqr   c                óÒ   <€ V ^8„  d   QhRS[ S[S[S[,          RS[R,          3,          RS[RS[S[S[S[3,          ,          S[S[S[S[S[3,          ,          ,          ,          /# rG   )r   r@   rK   r   rL   )rM   rN   s   "€r   rO   rP      s`   ø€ ÷ 62ñ 62Ù™C¡¡c¥¨M¹4ÀÕ;NÐNÕOð62Ù[^ð62á	‰d‘3™�8�nÕ	¡¡T©$©s±C¨x­.Õ%9Õ :Õ	:ñ62r   c                ót   <€ RV9   d   VP                  R4      pVf   \        R4      h\        SV `  ! V3/ VB # )a™  
Assign labels to the image(s) passed as inputs.

Args:
    inputs (`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.
    function_to_apply (`str`, *optional*, defaults to `"default"`):
        The function to apply to the model outputs in order to retrieve the scores. Accepts four different
        values:

        If this argument is not specified, then it will apply the following functions according to the number
        of labels:

        - If the model has a single label, will apply the sigmoid function on the output.
        - If the model has several labels, will apply the softmax function on the output.

        Possible values are:

        - `"sigmoid"`: Applies the sigmoid function on the output.
        - `"softmax"`: Applies the softmax function on the output.
        - `"none"`: Does not apply any function on the output.
    top_k (`int`, *optional*, defaults to 5):
        The number of top labels that will be returned by the pipeline. If the provided number is higher than
        the number of labels available in the model configuration, it will default to the number of labels.
    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 dictionary or a list of dictionaries containing result. If the input is a single image, will return a
    dictionary, if the input is a list of several images, will return a list of dictionaries corresponding to
    the images.

    The dictionaries contain the following keys:

    - **label** (`str`) -- The label identified by the model.
    - **score** (`int`) -- The score attributed by the model for that label.
ÚimageszICannot call the image-classification pipeline without an inputs argument!)ÚpopÚ
ValueErrorr3   rT   )r6   rI   r8   r9   s   &&,€r   rT   rU      sB   ø€ ðd �vÔØ—Z‘Z Ó)ˆFØŠ>ÜÐhÓiÐiÜ‰wÒ Ñ1¨&Ñ1Ð1r   c                óz   € \        WR 7      pV P                  VRR7      pVP                  V P                  4      pV# ))r<   Úpt)rZ   Úreturn_tensors)r   Úimage_processorÚtoÚdtype)r6   Úimager<   Úmodel_inputss   &&& r   Ú
preprocessÚ&ImageClassificationPipeline.preprocess·   s9   € Ü˜5Ô2ˆØ×+Ñ+°5ÈÐ+ÓNˆØ#—‘ t§z¡zÓ2ˆØÐr   c                ó*   € V P                   ! R/ VB pV# )Nr%   )Úmodel)r6   rd   Úmodel_outputss   && r   Ú_forwardÚ$ImageClassificationPipeline._forward½   s   € ØŸ
š
Ñ2 \Ñ2ˆØÐr   c           	     ót  € VEf   V P                   P                  P                  R8X  g&   V P                   P                  P                  ^8X  d   \        P
                  pM¶V P                   P                  P                  R8X  g&   V P                   P                  P                  ^8”  d   \        P                  pM[\        V P                   P                  R4      '       d&   Vf"   V P                   P                  P                  pM\        P                  pW0P                   P                  P                  8”  d!   V P                   P                  P                  pVR,          ^ ,          pVP                  \        P                  \        P                  39   d/   VP                  \        P                  4      P!                  4       pMVP!                  4       pV\        P
                  8X  d   \#        V4      pMGV\        P                  8X  d   \%        V4      pM&V\        P                  8X  d   TpM\'        RV 24      h\)        V4       UUu. uF>  w  rgRV P                   P                  P*                  V,          RVP-                  4       /NK@  	  pppVP/                  R R	R
7       Ve   VR V pV# u uppi )NÚmulti_label_classificationÚsingle_label_classificationr>   Úlogitsz+Unrecognized `function_to_apply` argument: ÚlabelÚscorec                 ó   € V R ,          # )rq   r%   )Úxs   &r   Ú<lambda>Ú9ImageClassificationPipeline.postprocess.<locals>.<lambda>á   s   €  q¨¦zr   T)ÚkeyÚreverse)rh   ÚconfigÚproblem_typeÚ
num_labelsr#   r*   r+   Úhasattrr>   r,   rb   ÚtorchÚbfloat16Úfloat16ra   Úfloat32Únumpyr   r!   r\   Ú	enumerateÚid2labelÚitemÚsort)	r6   ri   r>   r=   ÚoutputsÚscoresÚirq   Údict_scoress	   &&&&     r   ÚpostprocessÚ'ImageClassificationPipeline.postprocessÁ   s  € ØÓ$Ø�z‰z× Ñ ×-Ñ-Ð1MÔMÐQU×Q[ÑQ[×QbÑQb×QmÑQmÐqrÔQrÜ$:×$BÑ$BÑ!Ø—‘×"Ñ"×/Ñ/Ð3PÔPÐTX×T^ÑT^×TeÑTe×TpÑTpÐstÔTtÜ$:×$BÑ$BÑ!Ü˜Ÿ™×*Ñ*Ð,?×@Ò@ÐEVÒE^Ø$(§J¡J×$5Ñ$5×$GÑ$GÑ!ä$:×$?Ñ$?Ð!à—:‘:×$Ñ$×/Ñ/Ô/Ø—J‘J×%Ñ%×0Ñ0ˆEà Õ)¨!Õ,ˆØ�=‰=œUŸ^™^¬U¯]©]Ð;Ô;Ø—j‘j¤§¡Ó/×5Ñ5Ó7‰Gà—m‘m“oˆGàÔ 6× >Ñ >Ô>Ü˜WÓ%‰FØÔ"8×"@Ñ"@Ô@Ü˜WÓ%‰FØÔ"8×"=Ñ"=Ô=Ø‰FäÐJÐK\ÐJ]Ð^Ó_Ð_ô ]fÐflÔ\mô
Ù\mÑPXÐPQˆW�d—j‘j×'Ñ'×0Ñ0°Õ3°W¸e¿j¹j»lÓKÑ\mð 	ñ 
ð 	×ÑÑ1¸4ÐÔ@ØÒØ% f uÐ-ˆKàÐùó
s   ÉAJ4c                ó&   <€ V ^8„  d   Qh/ S[ ;R&   # )rH   r>   )r#   )rM   rN   s   "€r   rO   rP   =   s   ø‡ ‚ ñH .ÑKòI r   r%   )NNNrR   )Né   )r&   r'   r(   r)   Ú__doc__r#   r,   r>   Ú_load_processorÚ_load_image_processorÚ_load_feature_extractorÚ_load_tokenizerr4   rD   r   rT   re   rj   r‰   Ú__annotate_func__r-   Ú__classdictcell__Ú__classcell__)r9   rN   s   @@r   r0   r0   =   sz   ù‡ € ñð. 1G×0KÑ0KÐØ€OØ ÐØ#ÐØ€OõLô
9ð ßeó Øeàßqó Øq÷62ó 62ôpòô$÷I … r   r0   )Útypingr   r   r   r€   r   Úutilsr   r   r   r	   r
   r   Úbaser   r   ÚPILr   Úimage_utilsr   r|   Úmodels.auto.modeling_autor   Ú
get_loggerr&   Úloggerr   r!   r#   r0   r%   r   r   Ú<module>r�      s—   ð÷ (Ñ 'ã ÷÷ ÷ 5ñ ×ÒÝå(á×ÒÛåXà	×	Ò	˜HÓ	%€ò+ò
Aô˜\ô ñ Ù°Ô6ðFóô\ (ó \óò\r   