Ë
    S^(hÉ  ã                   óV   — d dl Z d dlmZ ddlmZmZ ddlmZ ddlm	Z	  G d„ d	e	«      Z
y)
é    N)ÚImageé   )Ú#AutoModelForVisualQuestionAnsweringÚAutoProcessor)Úrequires_backendsé   )ÚPipelineToolc                   óh   ‡ — e Zd ZdZdZdZeZeZ	dddœdddœd	œZ
dZˆ fd
„Zdddefd„Zd„ Zd„ Zˆ xZS )ÚImageQuestionAnsweringToolzdandelin/vilt-b32-finetuned-vqazlThis is a tool that answers a question about an image. It returns a text that is the answer to the question.Úimage_qaÚimagezWThe image containing the information. Can be a PIL Image or a string path to the image.)ÚtypeÚdescriptionÚstringzThe question in English)r   Úquestionc                 ó>   •— t        | dg«       t        ‰| �  |i |¤Ž y )NÚvision)r   ÚsuperÚ__init__)ÚselfÚargsÚkwargsÚ	__class__s      €új/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/transformers/agents/image_question_answering.pyr   z#ImageQuestionAnsweringTool.__init__,   s!   ø€ Ü˜$  
Ô+Ü‰Ñ˜$Ð) &Ó)ó    r   r   c                 ó*   — | j                  ||d¬«      S )NÚpt)Úreturn_tensors)Úpre_processor)r   r   r   s      r   Úencodez!ImageQuestionAnsweringTool.encode0   s   € Ø×!Ñ! %¨À$Ð!ÓGÐGr   c                 óŽ   — t        j                  «       5   | j                  di |¤Žj                  cd d d «       S # 1 sw Y   y xY w)N© )ÚtorchÚno_gradÚmodelÚlogits)r   Úinputss     r   Úforwardz"ImageQuestionAnsweringTool.forward3   s7   € Ü�]‰]‹_ñ 	/Ø�4—:‘:Ñ' Ñ'×.Ñ.÷	/÷ 	/ò 	/ús	   •;»Ac                 ó†   — |j                  d«      j                  «       }| j                  j                  j                  |   S )Néÿÿÿÿ)ÚargmaxÚitemr%   ÚconfigÚid2label)r   ÚoutputsÚidxs      r   Údecodez!ImageQuestionAnsweringTool.decode7   s4   € Ø�n‰n˜RÓ ×%Ñ%Ó'ˆØ�z‰z× Ñ ×)Ñ)¨#Ñ.Ð.r   )Ú__name__Ú
__module__Ú__qualname__Údefault_checkpointr   Únamer   Úpre_processor_classr   Úmodel_classr'   Úoutput_typer   Ústrr    r(   r1   Ú__classcell__)r   s   @r   r   r      sn   ø„ Ø:Ðàvð ð €DØ'ÐØ5€Kð Øtñ
ð &Ð6OÑPñ€Fð €Kô*ðH˜Gð H¨só Hò/ö/r   r   )r#   ÚPILr   Úmodels.autor   r   Úutilsr   Útoolsr	   r   r"   r   r   ú<module>r@      s"   ðó$ Ý ç LÝ %Ý ô/ õ /r   