o
    GÆÏiî  ã                   @   sŠ   d dl mZ ddlmZ ddlmZ ddlmZmZm	Z	 ddl
mZ ddlmZ dd	lmZ e e¡ZG d
d„ deƒZG dd„ deƒZdS )é   )Úloggingé   )ÚSequentialPipelineBlocks)ÚOutputParamé   )ÚWanPrepareLatentsStepÚWanSetTimestepsStepÚWanTextInputStep)ÚWanVaeDecoderStep)ÚWan22DenoiseStep)ÚWanTextEncoderStepc                   @   s@   e Zd ZdZdZeeeegZ	g d¢Z
edd„ ƒZedd„ ƒZdS )	ÚWan22CoreDenoiseStepa‘  
    denoise block that takes encoded conditions and runs the denoising process.

      Components:
          transformer (`WanTransformer3DModel`) scheduler (`UniPCMultistepScheduler`) guider (`ClassifierFreeGuidance`)
          guider_2 (`ClassifierFreeGuidance`) transformer_2 (`WanTransformer3DModel`)

      Configs:
          boundary_ratio (default: 0.875): The boundary ratio to divide the denoising loop into high noise and low
          noise stages.

      Inputs:
          num_videos_per_prompt (`None`, *optional*, defaults to 1):
              TODO: Add description.
          prompt_embeds (`Tensor`):
              Pre-generated text embeddings. Can be generated from text_encoder step.
          negative_prompt_embeds (`Tensor`, *optional*):
              Pre-generated negative text embeddings. Can be generated from text_encoder step.
          num_inference_steps (`None`, *optional*, defaults to 50):
              TODO: Add description.
          timesteps (`None`, *optional*):
              TODO: Add description.
          sigmas (`None`, *optional*):
              TODO: Add description.
          height (`int`, *optional*):
              TODO: Add description.
          width (`int`, *optional*):
              TODO: Add description.
          num_frames (`int`, *optional*):
              TODO: Add description.
          latents (`Tensor | NoneType`, *optional*):
              TODO: Add description.
          generator (`None`, *optional*):
              TODO: Add description.
          attention_kwargs (`None`, *optional*):
              TODO: Add description.

      Outputs:
          latents (`Tensor`):
              Denoised latents.
    Úwan)ÚinputÚset_timestepsÚprepare_latentsÚdenoisec                 C   ó   dS )NzKdenoise block that takes encoded conditions and runs the denoising process.© ©Úselfr   r   úh/home/ubuntu/.local/lib/python3.10/site-packages/diffusers/modular_pipelines/wan/modular_blocks_wan22.pyÚdescription_   ó   z Wan22CoreDenoiseStep.descriptionc                 C   ó   t  d¡gS )NÚlatents©r   Útemplater   r   r   r   Úoutputsc   ó   zWan22CoreDenoiseStep.outputsN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú
model_namer	   r   r   r   Úblock_classesÚblock_namesÚpropertyr   r   r   r   r   r   r   +   s    *ü
r   c                   @   s>   e Zd ZdZdZeeegZg d¢Z	e
dd„ ƒZe
dd„ ƒZdS )	ÚWan22Blocksac  
    Modular pipeline for text-to-video using Wan2.2.

      Components:
          text_encoder (`UMT5EncoderModel`) tokenizer (`AutoTokenizer`) guider (`ClassifierFreeGuidance`) transformer
          (`WanTransformer3DModel`) scheduler (`UniPCMultistepScheduler`) guider_2 (`ClassifierFreeGuidance`)
          transformer_2 (`WanTransformer3DModel`) vae (`AutoencoderKLWan`) video_processor (`VideoProcessor`)

      Configs:
          boundary_ratio (default: 0.875): The boundary ratio to divide the denoising loop into high noise and low
          noise stages.

      Inputs:
          prompt (`None`, *optional*):
              TODO: Add description.
          negative_prompt (`None`, *optional*):
              TODO: Add description.
          max_sequence_length (`None`, *optional*, defaults to 512):
              TODO: Add description.
          num_videos_per_prompt (`None`, *optional*, defaults to 1):
              TODO: Add description.
          num_inference_steps (`None`, *optional*, defaults to 50):
              TODO: Add description.
          timesteps (`None`, *optional*):
              TODO: Add description.
          sigmas (`None`, *optional*):
              TODO: Add description.
          height (`int`, *optional*):
              TODO: Add description.
          width (`int`, *optional*):
              TODO: Add description.
          num_frames (`int`, *optional*):
              TODO: Add description.
          latents (`Tensor | NoneType`, *optional*):
              TODO: Add description.
          generator (`None`, *optional*):
              TODO: Add description.
          attention_kwargs (`None`, *optional*):
              TODO: Add description.
          output_type (`str`, *optional*, defaults to np):
              The output type of the decoded videos

      Outputs:
          videos (`list`):
              The generated videos.
    r   )Útext_encoderr   Údecodec                 C   r   )Nz0Modular pipeline for text-to-video using Wan2.2.r   r   r   r   r   r   ª   r   zWan22Blocks.descriptionc                 C   r   )NÚvideosr   r   r   r   r   r   ®   r   zWan22Blocks.outputsN)r    r!   r"   r#   r$   r   r   r
   r%   r&   r'   r   r   r   r   r   r   r(   n   s    /ý
r(   N)Úutilsr   Úmodular_pipeliner   Úmodular_pipeline_utilsr   Úbefore_denoiser   r   r	   Údecodersr
   r   r   Úencodersr   Ú
get_loggerr    Úloggerr   r(   r   r   r   r   Ú<module>   s   
C