o
    ॵi                      @   s   d dl 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 d	gZejejejd
G dd	 d	eZdS )    )AnyDictN)	Pipelines)Model)
OutputKeys)Pipeline)	PIPELINES)TasksPipelineTemplate)module_namec                	       s   e Zd ZdZdef fddZ		ddeded	ed
efddZ			ddeded	ed
efddZ
	ddeded
eeef fddZ  ZS )r
   a:  A pipeline template explain how to define parameters and input and
       output information. As a rule, the first parameter is the input,
       followed by the request parameters. The parameter must add type
       hint information, and set the default value if necessary,
       for the convenience of use.
    modelc                    s   t  jdd|i| dS )zA pipeline template to describe input and
        output and parameter processing

        Args:
            model: A Model instance.
        r   N )super__init__)selfr   kwargs	__class__r   Z/home/ubuntu/.local/lib/python3.10/site-packages/modelscope/pipelines/pipeline_template.pyr      s   zPipelineTemplate.__init__   皙?input
max_lengthtop_preturnc                 C      dS )al  Pipeline preprocess interface.

        Args:
            input (Any): The pipeline input, ref Tasks.task_template TASK_INPUTS.
            max_length (int, optional): The max_length parameter. Defaults to 1024.
            top_p (float, optional): The top_p parameter. Defaults to 0.8.

        Returns:
            Any: Return result process by forward.
        Nr   r   r   r   r   r   r   r   
preprocess%      zPipelineTemplate.preprocessc                 C   r   )a1  The forward interface.

        Args:
            input (Any): The output of the preprocess.
            max_length (int, optional): max_length. Defaults to 1024.
            top_p (float, optional): top_p. Defaults to 0.8.

        Returns:
            Any: Return result process by postprocess.
        Nr   r   r   r   r   forward5   r   zPipelineTemplate.forwardNinputspostprocess_param1c              	   C   s0   t jtdt jtddt jtddi}|S )a2  The postprocess interface.

        Args:
            input (Any): The output of the forward.
            max_length (int, optional): max_length. Defaults to 1024.
            top_p (float, optional): top_p. Defaults to 0.8.

        Returns:
            Any: Return result process by postprocess.
           
      i  )r   BOXESnpzeros
OUTPUT_IMGTEXT_EMBEDDING)r   r    r!   resultr   r   r   postprocessE   s
   zPipelineTemplate.postprocess)r   r   )N)__name__
__module____qualname____doc__r   r   r   intfloatr   r   strr   r+   __classcell__r   r   r   r   r
      sB    


)typingr   r   numpyr&   modelscope.metainfor   !modelscope.models.base.base_modelr   modelscope.outputs.outputsr   modelscope.pipelines.baser   modelscope.pipelines.builderr   modelscope.utils.constantr	   __all__register_moduletask_templatepipeline_templater
   r   r   r   r   <module>   s   