o
    ॵiw                     @   s   d dl mZmZ d dlmZ d dlmZ d dlmZm	Z	 d dl
mZ d dlmZ d dlmZmZ d dlmZ e Zejejejd	G d
d de	ZdS )    )AnyDict)	Pipelines)
OutputKeys)InputPipeline)	PIPELINES)	LoadImage)	ModelFileTasks)
get_logger)module_namec                       s   e Zd Zdef fddZdedee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 )ImageBodyReshapingPipelinemodelc                    s$   t  jdd|i| td dS )z
        use `model` to create a image body reshaping pipeline for prediction
        Args:
            model: model id on modelscope hub.
        r   zbody reshaping model init doneN )super__init__loggerinfo)selfr   kwargs	__class__r   i/home/ubuntu/.local/lib/python3.10/site-packages/modelscope/pipelines/cv/image_body_reshaping_pipeline.pyr      s   z#ImageBodyReshapingPipeline.__init__inputreturnc                 C   s   t |}d|i}|S )Nimg)r	   convert_to_ndarray)r   r   r   resultr   r   r   
preprocess   s   
z%ImageBodyReshapingPipeline.preprocessc                 C   s   | j |d }d|i}|S )Nr   outputs)r   	inference)r   r   outputr   r   r   r   forward!   s   z"ImageBodyReshapingPipeline.forwardinputsc                 C   s   |d }t j|iS )Nr    )r   
OUTPUT_IMG)r   r$   
output_imgr   r   r   postprocess&   s   
z&ImageBodyReshapingPipeline.postprocess)__name__
__module____qualname__strr   r   r   r   r   r#   r'   __classcell__r   r   r   r   r      s
    	"*r   N)typingr   r   modelscope.metainfor   modelscope.outputsr   modelscope.pipelines.baser   r   modelscope.pipelines.builderr   modelscope.preprocessorsr	   modelscope.utils.constantr
   r   modelscope.utils.loggerr   r   register_moduleimage_body_reshapingr   r   r   r   r   <module>   s   