o
    *j                     @   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__Z
model_pathloggerinfotorchr   Zis_availabledevice)selfr   kwargs	__class__r   x/var/www/html/Deteccion_Ine/venv/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 )NZsource_img_pathZtarget_pose_path)r   Zinferr   r   r   Z
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   Zmodelscope.metainfor   Z+modelscope.models.cv.human_image_generationr   Zmodelscope.outputsr   Zmodelscope.pipelines.baser   r   Zmodelscope.pipelines.builderr	   Zmodelscope.preprocessorsr
   Zmodelscope.utils.constantr   Zmodelscope.utils.loggerr   r   Zregister_moduler&   r   r   r   r   r   <module>   s    