
    3ji
                         S SK Jr  S SKJrJr  S SKJr  S SKr " S S\R                  5      r	 " S S\5      r
S	\
4S
 jrg)    )model_management)ComfyExtensionIO)overrideNc                   X    \ rS rSrSr\S 5       r\S\R                  4S j5       r	\	r
Srg)LTXVLatentUpsampler   z,
Upsamples a video latent by a factor of 2.
c           
          [         R                  " SSS[         R                  R                  S5      [         R                  R                  S5      [         R
                  R                  S5      /[         R                  R                  5       /S9$ )Nr   zmodel/latent/ltxvTsamplesupscale_modelvae)node_idcategoryis_experimentalinputsoutputs)r   SchemaLatentInputLatentUpscaleModelVaeOutput)clss    ?/home/wildlama/comfy/ComfyUI/comfy_extras/nodes_lt_upsampler.pydefine_schema!LTXVLatentUpsampler.define_schema   sl    yy)( 			*%%++O<U# 		  "
 	
    returnc                 (   [         R                  " 5       n[         R                  " U5      n[        UR	                  5       5      R
                  nUS   nUR
                  nU[        R                  " UR                  5      S-  -  n[         R                  " XT5         UR                  U5        UR                  XdS9n UR                  R                  R                  U5      nU" U5      n	UR                  5         UR                  R                  R                  U	5      n	U	R                  U[         R                   " 5       S9n	UR#                  5       n
XS'   U
R%                  SS5        [&        R(                  " U
5      $ ! UR                  5         f = f)z
Upsample the input latent using the provided model.

Args:
    samples (dict): Input latent samples
    upscale_model (LatentUpsampler): Loaded upscale model
    vae: VAE model for normalization

Returns:
    tuple: Tuple containing the upsampled latent
r   g     p@)dtypedevice
noise_maskN)r   get_torch_devicemodule_sizenext
parametersr    mathprodshapefree_memorytofirst_stage_modelper_channel_statisticsun_normalizecpu	normalizeintermediate_devicecopypopr   
NodeOutput)r   r   r   r   r!   memory_requiredmodel_dtypelatentsinput_dtypeupsampled_latentsreturn_dicts              r   executeLTXVLatentUpsampler.execute   sT    "224*66}E=3356<<)$mm499W]]3f<<$$_=		 V$jj{jBG2++BBOOPWXG -g 611HHRR
 .00{K[KoKoKq0rlln!2Id+}}[)) s   AE? ?F N)__name__
__module____qualname____firstlineno____doc__classmethodr   r   r4   r;   upsample_latent__static_attributes__r=   r   r   r   r      sB     
 
 (*R]] (* (*T Or   r   c                   L    \ rS rSr\S\\\R                        4S j5       r	Sr
g)LTXVLatentUpsamplerExtensionJ   r   c                    #    [         /$ 7fN)r   )selfs    r   get_node_list*LTXVLatentUpsamplerExtension.get_node_listK   s     #$$s   
r=   N)r>   r?   r@   rA   r   listtyper   	ComfyNoderL   rE   r=   r   r   rG   rG   J   s)    %T$r||*<%= % %r   rG   r   c                     #    [        5       $ 7frJ   )rG   r=   r   r   comfy_entrypointrR   P   s     '))s   )comfyr   comfy_api.latestr   r   typing_extensionsr   r'   rP   r   rG   rR   r=   r   r   <module>rV      s=    " / & @",, @F%> %* < *r   