
    
3j                         S SK rS SKrS SKrSSKJr  SSKJr  SSKJ	r	  SSK
Jr  SSKJrJr  SS	KJrJrJr  \	R&                  " \5      r " S
 S\5      rg)    N   )
FrozenDict)AutoencoderKLWan)logging)VideoProcessor   )ModularPipelineBlocksPipelineState)ComponentSpec
InputParamOutputParamc                       \ rS rSrSrSr\S\4S j5       r\S\	\
   4S j5       r\S\	\   4S j5       r\S\	\   4S j5       r\R"                  " 5       S	\S\4S
 j5       rSrg)HeliosDecodeStep   zXDecode all chunk latents with VAE, trim frames, and postprocess into final video output.heliosreturnc                      g)NzDecodes all chunk latents with the VAE, concatenates them, trims to the target frame count, and postprocesses into the final video output. selfs    e/home/wildlama/miniconda3/lib/python3.13/site-packages/diffusers/modular_pipelines/helios/decoders.pydescriptionHeliosDecodeStep.description#   s    ^	
    c           	      X    [        S[        5      [        S[        [        SS05      SS9/$ )Nvaevideo_processorvae_scale_factor   from_config)configdefault_creation_method)r   r   r   r   r   s    r   expected_components$HeliosDecodeStep.expected_components*   s8     %!12!!#5q"9:(5	
 	
r   c                 j    [        SS[        SS9[        SS[        SS9[         R                  " SSS	9/$ )
Nlatent_chunksTz)List of per-chunk denoised latent tensors)required	type_hintr   
num_framesz"The target number of output framesoutput_typenp)default)r   listinttemplater   s    r   inputsHeliosDecodeStep.inputs6   sA     $$Lw |dcOstt<
 	
r   c                     [        S[        [        [        R                  R                        [        [        R
                     -  [        [        R                     -  SS9/$ )NvideoszMThe generated videos, can be a PIL.Image.Image, torch.Tensor or a numpy array)r(   r   )r   r-   PILImagetorchTensorr+   ndarrayr   s    r   intermediate_outputs%HeliosDecodeStep.intermediate_outputs@   sP     tCIIOO45U\\8JJTRTR\R\M]]k
 	
r   statec                    U R                  U5      nUR                  n[        R                  " UR                  R
                  5      R                  SUR                  R                  SSS5      R                  UR                  UR                  5      nS[        R                  " UR                  R                  5      R                  SUR                  R                  SSS5      R                  UR                  UR                  5      -  nS nUR                   HT  nUR                  UR                  5      U-  U-   n	UR                  U	SS9S   n
Uc  U
nM>  [        R                  " Xz/SS9nMV     UR                  S5      nUS-
  UR                   -  UR                   -  S-   nUS S 2S S 2S U24   nUR"                  R%                  XsR&                  S9Ul        U R+                  X#5        X4$ )	N   g      ?F)return_dictr   r   )dim)r*   )get_block_stater   r6   tensorr!   latents_meanviewz_dimtodevicedtypelatents_stdr&   decodecatsizevae_scale_factor_temporalr   postprocess_videor*   r3   set_block_state)r   
componentsr;   block_stater   rB   rH   history_videochunk_latentscurrent_latentscurrent_videogenerated_framess               r   __call__HeliosDecodeStep.__call__J   s   **51nn LL00166q#**:J:JAqRSTWWX[XbXbdgdmdmn 	 ELL)?)?@EEaIYIY[\^_abcffJJ		
 
 (66M+..syy9KG,VOJJEJJ1MM$ - %		=*Ha P 7 )--a0q 1124>4X4XY[\] &a,=-=,=&=>'77II'>'> J 
 	U0  r   r   N)__name__
__module____qualname____firstlineno____doc__
model_namepropertystrr   r-   r   r#   r   r0   r   r9   r6   no_gradr
   rV   __static_attributes__r   r   r   r   r      s    bJ
S 
 
 	
T-%8 	
 	
 
Z( 
 
 
d;&7 
 
 ]]_#!- #!M #! #!r   r   )numpyr+   r4   r6   configuration_utilsr   modelsr   utilsr   r   r   modular_pipeliner	   r
   modular_pipeline_utilsr   r   r   
get_loggerrX   loggerr   r   r   r   <module>rj      sF     
  - &  - C K K 
		H	%P!, P!r   