o
    ॵi                     @   s   d dl mZmZ d dl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mZ d dlmZ d dlmZ d d	l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DictN)	Pipelines)human_image_generation_infer)
OutputKeys)InputPipeline)	PIPELINES)	LoadImage)Tasks)
get_logger)module_namec                       s   e Zd 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 )&FreqHPTForHumanImageGenerationPipelinea   Human Image Generation Pipeline.
    Examples:
    >>> human_image_generation = pipeline(Tasks.human_image_generation, model='damo/cv_FreqHPT_human-image-generation')
    >>> input_images = {'source_img_path': '/your_path/source_img.jpg',
    >>>                 'target_pose_path': '/your_path/target_pose.txt'}
    >>> result = human_image_generation(input_images)
    >>> result[OutputKeys.OUTPUT_IMG]
    modelc                    sX   t  jdd|i| || _td tj r"d| _td dS d| _td dS )	z
            use `model` to create human image generation pipeline for prediction
            Args:
                model: model id on modelscope hub.
            r   zload model donecudazUse GPUcpuzUse CPUN )	super__init__
model_pathloggerinfotorchr   is_availabledevice)selfr   kwargs	__class__r   k/home/ubuntu/.local/lib/python3.10/site-packages/modelscope/pipelines/cv/human_image_generation_pipeline.pyr   !   s   

z/FreqHPTForHumanImageGenerationPipeline.__init__inputreturnc                 C      |S Nr   )r   r    r   r   r   
preprocess2      z1FreqHPTForHumanImageGenerationPipeline.preprocessinputsc                 C   r"   r#   r   )r   r&   r   r   r   postprocess5   r%   z2FreqHPTForHumanImageGenerationPipeline.postprocessc                 C   s&   t | j|d |d | j}tj|iS )Nsource_img_pathtarget_pose_path)r   inferr   r   r   
OUTPUT_IMG)r   r    human_image_generationr   r   r   forward8   s
   
z.FreqHPTForHumanImageGenerationPipeline.forward)__name__
__module____qualname____doc__strr   r   r   r   r$   r'   r-   __classcell__r   r   r   r   r      s    	"*r   )typingr   r   numpynpr   modelscope.metainfor   +modelscope.models.cv.human_image_generationr   modelscope.outputsr   modelscope.pipelines.baser   r   modelscope.pipelines.builderr	   modelscope.preprocessorsr
   modelscope.utils.constantr   modelscope.utils.loggerr   r   register_moduler,   r   r   r   r   r   <module>   s    