
    Fg-                    n    S r SSKJr  SSKJr  SSKJrJrJr  \(       a  SSK	r	SSK
r
    SS jrS	S jrg)
zThis module should not be used directly as its API is subject to change. Instead,
please use the `gr.Interface.from_pipeline()` function.    )annotations)TYPE_CHECKING)handle_diffusers_pipelinehandle_transformers_js_pipelinehandle_transformers_pipelineNc                B  ^ ^ [        [        T 5      R                  5      R                  S5      (       a  [	        T 5      mOI[        [        T 5      R                  5      R                  S5      (       a  [        T 5      mO[        S5      eU U4S jnT(       a  TR                  5       O0 nXS'   US	 US	 [        [        T 5      R                  5      R                  S5      (       a   T R                  R                  R                  OT R                  R                  US	'   U$ )
a.  
Gets the appropriate Interface kwargs for a given Hugging Face transformers.Pipeline or diffusers.DiffusionPipeline.
pipeline (transformers.Pipeline): the transformers.Pipeline from which to create an interface
Returns:
(dict): a dictionary of kwargs that can be used to construct an Interface object
ztransformers.pipelines.zdiffusers.pipelines.z>pipeline must be a transformers.pipeline or diffusers.pipelinec                   > T(       GaS  TS   " U 6 n[        [        T5      R                  5      R                  S5      (       a  SSKJn  [        TUR                  R                  UR                  R                  UR                  R                  UR                  R                  45      (       a  T" U6 nOT" S0 UD6n[        TUR                  R                  UR                  R                  45      (       a  TS   " XS   5      nU$ TS   " U5      nU$ [        [        T5      R                  5      R                  S5      (       a  T" S0 UD6nTS   " U5      nU$ g [!        S5      e)	N
preprocesstransformers.pipelinesr   )	pipelinespostprocesszdiffusers.pipelineszpipeline_info can not be None. )strtype
__module__
startswithtransformersr   
isinstancetext_classificationTextClassificationPipelinetext2text_generationText2TextGenerationPipelineTranslationPipelinetoken_classificationTokenClassificationPipelineobject_detectionObjectDetectionPipeline
ValueError)paramsdatar   outputpipelinepipeline_infos       a/Users/admin/workspace/ai/PDFMathTranslate/myenv/lib/python3.13/site-packages/gradio/pipelines.pyfnload_from_pipeline.<locals>.fn&   sa    .7D4>,,-889QRR2 !55PP!66RR!66JJ!66RR	  $T?D#+d+D !22JJ!66RR  +=9$q	JF  +=9$?FT(^../::;PQQ'$'&}5d; R
 =>>    r%   r
   r   r   title)r   r   r   r   r   r   r   copymodelconfigname_or_path	__class____name__r"   r%   interface_infor#   s   `  @r$   load_from_pipeliner1      s     4>$$%001JKK4X>	T(^&&	'	2	23I	J	J1(;L
 	
&?P .;]'')N4|$}%
 tH~(()445MNN 	**(( 7 r'   c                   ^ ^ [        [        T 5      R                  5      R                  S5      (       a  [	        T 5      mO[        S5      eU U4S jnUTS   TS   T R                   ST R                  R                  R                   S3S.nU$ )	Nztransformers_js_py.z0pipeline must be a transformers_js_py's pipelinec                    >#    TS   nTS   nTR                  SS5      nU(       a  U" U 6 OU nT" U6 I S h  vN nU(       a  U" U/U(       a  U OSQ76 nU$ UnU$  N#7f)Nr
   r   postprocess_takes_inputsFr   )get)	r   r
   r   r4   preprocessed_paramspipeline_outputpostprocessed_outputr"   r#   s	          r$   r%   !load_from_js_pipeline.<locals>.fnc   s     "<0
#M2#0#4#45OQV#W 5?j&1V (*= >>  W5M6SUW 	 $# ! 	 $# ?s   3AA$Ainputsoutputsz ())r%   r:   r;   r(   )
r   r   r   r   r   r   taskr*   r+   _name_or_pathr/   s   `  @r$   load_from_js_pipeliner?   ]   s    
4>$$%001FGG7AKLL$  ) +MM?"X^^%:%:%H%H$IK	N r'   )r"   z3transformers.Pipeline | diffusers.DiffusionPipelinereturndict)r@   rA   )__doc__
__future__r   typingr   gradio.pipelines_utilsr   r   r   	diffusersr   r1   r?   r   r'   r$   <module>rG      sE   ; #    GAG	GTr'   