o
    *jO	                     @   s   d dl mZmZmZmZ d dlZd dlmZ d dlm	Z	 d dl
mZ d dlmZ d dlmZ d dlmZmZ d	gZejejejd
ejejejd
G dd	 d	eZdS )    )AnyDictOptionalUnionN)	Pipelines)Model)Pipeline)	PIPELINES)Preprocessor)	ModelFileTasksInformationExtractionPipeline)module_namec                	       s   e Zd Z					ddeeef dee dedef fd	d
Zde	ee
f de	ee
f fddZde	ee
f de	eef fddZ  ZS )r   NgpuT   modelpreprocessorconfig_filedevicec                    sf   t  j|||||d t| jtsJ dtj | jdu r,tj	| jj
fd|i|| _| j  dS )a  

        Args:
            model (str or Model): Supply either a local model dir which supported information extraction task, or a
            model id from the model hub, or a torch model instance.
            preprocessor (Preprocessor): An optional preprocessor instance, please make sure the preprocessor fits for
            the model if supplied.
            kwargs (dict, `optional`):
                Extra kwargs passed into the preprocessor's constructor.
        )r   r   r   r   auto_collatez,please check whether model config exists in Nsequence_length)super__init__
isinstancer   r   r   ZCONFIGURATIONr   r
   Zfrom_pretrainedZ	model_direval)selfr   r   r   r   r   r   kwargs	__class__ y/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/modelscope/pipelines/nlp/information_extraction_pipeline.pyr      s&   

z&InformationExtractionPipeline.__init__inputsreturnc                 K   s@   t   | jdi ||W  d    S 1 sw   Y  d S )Nr   )torchZno_gradr   )r   r!   Zforward_paramsr   r   r    forward:   s   
$z%InformationExtractionPipeline.forwardc                 K   s   |S )Nr   )r   r!   Zpostprocess_paramsr   r   r    postprocess?   s   z)InformationExtractionPipeline.postprocess)NNr   Tr   )__name__
__module____qualname__r   r   strr   r
   r   r   r   r$   r%   __classcell__r   r   r   r    r      s*    
#


)typingr   r   r   r   r#   Zmodelscope.metainfor   Zmodelscope.modelsr   Zmodelscope.pipelines.baser   Zmodelscope.pipelines.builderr	   Zmodelscope.preprocessorsr
   Zmodelscope.utils.constantr   r   __all__Zregister_moduleZinformation_extractionZrelation_extractionr   r   r   r   r    <module>   s    