+
    „°ñjÕ°  ã                   óÎ  € ^ RI t ^ RIt^ RIt^ RIt^ RIHtHt ^ RIHtH	t	 ^ RI
HtHtHtHtHt ^ RIHt ^tR)tR tR tR tR	 R
 ltR R ltR R ltR R ltR R ltR R ltR*R R lltR R ltR tR R lt R t! ! R R]	PD                  4      t# ! R R ]	PD                  4      t$ ! R! R"]	PD                  4      t% ! R# R$]	PD                  4      t& ! R% R&]4      t'R' R( lt(R# )+é    N)ÚSymmetricPatchifierÚlatent_to_pixel_coords)ÚComfyExtensionÚio)ÚLTXVAddGuideÚ_append_guide_attention_entryÚconditioning_get_any_valueÚget_keyframe_idxsÚget_noise_mask)Úoverridec                 ó   € \        V R R4      # )Úgenerated_keyframesN)r	   )Úconds   &ÚCC:\Ai_Coding\apps\studio\ComfyUI\comfy_extras\nodes_lt_keyframes.pyÚget_generated_keyframesr      s   € Ü% dÐ,AÀ4ÓHÐHó    c                ón  € \         P                  ! RV P                  4       4       Uu. uF  qw'       g   K  VNK  	  ppV'       g   \        V RV RV R24      h V Uu. uF  p\	        V4      NK  	  p	pTe7   \        T	4      T8w  d'   \        T R	\        T	4       R
T RT RT RT R24      h\        T	 Uu0 uF  q¹P                  T4      ^8”  g   K  TkK  	  up4      pT'       d(   \        T RRP                  R T 4       4       R24      hT	 Uu. uF  q³Tu;8:  d
   T8:  d   K  M TNK  	  ppT'       d.   \        T RT RT RRP                  R T 4       4       R24      hT	# u upi u upi   \         d,    RP                  R T 4       4      p
\        T RT
 R24      Rhi ; iu upi u upi )u   Parse a manual frame index override and validate count, uniqueness and range.

Order is not significant â€” only the set of positions matters â€” so the list
is returned as written rather than sorted. ``expected_count`` may be None
when the list itself defines how many keyframes to add.
z[,\s]+z0 is empty. Provide at least one index, or leave z empty Ú.ú, c              3   óv   "  € T F/  p\         P                  ! R V4      '       d   K"  \        V4      x € K1  	  R# 5i)z-?\d+N)ÚreÚ	fullmatchÚrepr)Ú.0Úparts   & r   Ú	<genexpr>Ú*_parse_frame_index_list.<locals>.<genexpr>(   s&   é € ÐY©u t¼B¿LºLÈÐSW×<Xœ
œ˜TŸ
˜
«uùs   ‚9¦9zA must be a comma-separated list of integers, but could not parse Nz lists z index/indices but z. Provide exactly z, or leave z; must not place two keyframes on the same pixel frame, but c              3   ó8   "  € T F  p\        V4      x € K  	  R # 5i©N©Ústr©r   Úindexs   & r   r   r   7   ó   é € Ð<±¨œ˜UŸ˜³ùó   ‚z appear(s) more than once.z must lie between z and z
, but got c              3   ó8   "  € T F  p\        V4      x € K  	  R # 5ir   r    r"   s   & r   r   r   >   s   é € Ð>±¨œ˜UŸ˜³ùr%   )	r   ÚsplitÚstripÚ
ValueErrorÚintÚjoinÚlenÚsortedÚcount)ÚvalueÚfieldÚexpected_countÚfirstÚlastÚexpected_descÚ
empty_hintr   ÚpartsÚindicesÚbadr#   Ú
duplicatesÚout_of_ranges   &&&&&&&       r   Ú_parse_frame_index_listr;      sõ  € ô !Ÿhšh y°%·+±+³-Ô@ÓIÑ@�dÃD�TˆTÑ@€EÐIßÜØˆgÐEÀeÀWÈGÐT^ÐS_Ð_`Ðaó
ð 	
ðÙ).Ó/© ”3�t–9©ˆÐ/ð Ò!¤c¨'£l°nÔ&DÜØˆg�WœS ›\˜NÐ*=¸m¸_ÐL^ØÐ˜k¨%¨°¸
°|À1ðFó
ð 	
ô
 ©GÓP©G 5·}±}ÀUÓ7KÈaÑ7OŸ˜©GÑPÓQ€JßÜØˆgÐPØ�y‰yÑ<±Ó<Ó<Ð=Ð=WðYó
ð 	
ñ
 (/ÓM¡w˜e¸uÖ6LÈÑ6L”EÑ6L“E¡w€LÐMßÜØˆgÐ'¨ w¨e°D°6¸Ø�y‰yÑ>±Ó>Ó>Ð?¸qðBó
ð 	
ð €NùòA Jùò 0øÜô Ø�i‰iÑY©uÓYÓYˆÜØˆgÐVÐWZÐV[Ð[\Ð]ó
àð	ðüò Qùò Ns@   ¨	E*¶E*ÁE4 ÁE/Á3E4 Â8F-ÃF-ÄF2Ä)F2Å/E4 Å46F*c           	     óô  € . pW3 FÞ  p. pV F$  pV^,          P                  RR4      p	V	f   K"  T	p M	  V\        V4      8¼  d   \        RV R\        V4       R24      h\        V4      p
\	        W¢,          4      pVR,          V,           VR&   \        VR,          4      pV^ ,          V,           V^ &   WËR&   WºV&   VP                  \        P                  ! VRV
/4      4       Kà  	  V^ ,          V^,          3# )zJGrow an existing guide_attention_entry when extending generated keyframes.Úguide_attention_entriesNú-The generated keyframes recorded guide entry ú but the conditioning only has ú5. The conditioning was rebuilt after they were added.Úpre_filter_countÚlatent_shape)Úgetr,   r)   ÚlistÚdictÚappendÚnode_helpersÚconditioning_set_values)ÚpositiveÚnegativer#   Úextra_pre_filter_countÚextra_framesÚresultsr   ÚexistingÚtÚfoundÚentriesÚgrownÚshapes   &&&&&        r   Ú_grow_guide_attention_entryrT   C   s  € à€GØÓ$ˆØˆÛˆAØ�a•D—H‘HÐ6¸Ó=ˆEØÔ Ø �Ùñ	 ð
 ”C˜“MÔ!ÜØ?À¸wÐFeÜ�x“=�/Ð!VðXóð ô �x“.ˆÜ�W•^Ó$ˆØ$)Ð*<Õ$=Ð@VÕ$VˆÐ Ñ!Ü�U˜>Õ*Ó+ˆØ˜•8˜lÕ*ˆˆa‰Ø %ˆnÑØ�‰Ø�‰”|×;Ò;¸DÐC\Ð^eÐBfÓgÖhñ' %ð( �1�:�w˜q•zÐ!Ð!r   c                óR   € V ^8„  d   QhR\         R\         R\        \         ,          /# )é   Únum_keyframesÚ
num_framesÚreturn)r*   rD   )Úformats   "r   Ú__annotate__r[   ]   s%   € ÷ ñ ¬sð Äð ÌÌSÍ	ñ r   c                 óÎ   € \         P                  ! ^ V^,
          V ^,           4      P                  4       P                  \         P                  4      P                  4       R,          # )r   :é   NN)ÚtorchÚlinspaceÚroundÚtoÚint64Útolist)rW   rX   s   &&r   Ú_spaced_positions_keep_lastrd   ]   sB   € ä�Š�q˜* q�.¨-¸!Õ*;Ó<ß	‰‹ß	‰ŒE�K‰K‹ß	‰‹�"õ	ðr   c                óR   € V ^8„  d   QhR\         R\        R\        \         ,          /# )rV   rX   Úinterval_framesrY   )r*   ÚfloatrD   )rZ   s   "r   r[   r[   f   s%   € ÷ ñ ¤Cð ¼%ð ÄDÌÅIñ r   c                ó  € V^ 8:  d   \        RV 24      hV ^8:  d   \        RV  R24      h\        ^\        V ^,
          V,          4      4      p\        W 4       Uu. uF  q3^ 8w  g   K  VNK  	  ppV'       g   \        RV  R24      hV# u upi )zºAbout one detailing keyframe every ``interval_frames`` pixel frames.

Skips frame 0 (already a standalone token) and keeps the last frame.
``interval_frames`` 24 is about 1/s at 24 fps.
z!interval_frames must be > 0, got úA ú8-frame target has no pixel frames to place keyframes on.)r)   Úmaxr`   rd   )rX   rf   r.   r#   Ú	positionss   &&   r   Údetailing_positionsrm   f   s«   € ð ˜!ÔÜÐ<¸_Ð<MÐNÓOÐOØ�Q„ÜØ��ÐTÐUó
ð 	
ô �”5˜* q�.¨OÕ;Ó<Ó=€EÜ$?ÀÔ$RÓaÑ$R˜5Ð_`ÑV`—�Ñ$R€IÐaßÜØ��ÐTÐUó
ð 	
ð Ðùò bs   ÁB
Á)B
c          	      ót   € V ^8„  d   QhR\         R\        R\        \         ,          R\        \         ,          /# )rV   rX   rf   ÚoccupiedrY   )r*   rg   ÚsetrD   )rZ   s   "r   r[   r[   {   s4   € ÷ ñ ¤Sð ¼5ð ÌCÔPSÍHð ÔY]Ô^aÕYbñ r   c                ó�   € \        V4      p\        W4       Uu. uF  pWC9  g   K  VNK  	  ppV'       g   \        R4      hV# u upi )zEDensity candidates that are not already I2V / guides / detailing KFs.zŽEvery candidate detailing-keyframe pixel already has an image keyframe or a guide. Leave at least one unoccupied frame, or pass frame_indices.)rp   rm   r)   )rX   rf   ro   Útakenr#   rl   s   &&&   r   Úfree_detailing_slotsrs   {   s_   € ä�‹M€Eô )¨ÔEóáEˆEØÑ÷ 	ˆÙEð ð ÷
 ÜðVó
ð 	
ð Ðùòs
   ™A¦Ac          	      ót   € V ^8„  d   QhR\         \        ,          R\        R\        R\         \        ,          /# )rV   r7   Úold_num_framesÚnew_num_framesrY   )rD   r*   )rZ   s   "r   r[   r[   ‹   s4   € ÷ ñ ¤¤c¥ð ¼Cð ÔQTð ÔY]Ô^aÕYbñ r   c           	     ó°  € V^8:  d   \        RV R24      hV^8:  d   \        RV R24      hV^,
          V^,
          ,          pV  Uu. uF  p\        \        WC,          4      4      NK  	  pp\        V Uu0 uF  qEP	                  V4      ^8”  g   K  VkK  	  up4      pV'       d&   \        RRP                  R V 4       4       R24      hV# u upi u upi )zIMap pixel indices from one canvas length onto another (e.g. temporal x2).z%Cannot scale keyframe indices from a z-frame canvas.z%Cannot scale keyframe indices onto a z7Scaling keyframe indices onto the new canvas collapsed r   c              3   ó8   "  € T F  p\        V4      x € K  	  R # 5ir   r    r"   s   & r   r   Ú&scale_frame_indices.<locals>.<genexpr>—   r$   r%   z onto the same pixel frame.)r)   r*   r`   r-   r.   r+   )r7   ru   rv   Úscaler#   Úremappedr9   s   &&&    r   Úscale_frame_indicesr|   ‹   sß   € à˜ÔÜÐ@ÀÐ@PÐP^Ð_Ó`Ð`Ø˜ÔÜÐ@ÀÐ@PÐP^Ð_Ó`Ð`Ø˜aÕ N°QÕ$6Õ7€EÙ7>Ó?±w¨e””E˜%�-Ó(Ö)±w€HÐ?Ü©HÓR©H 5¿¹ÀuÓ8MÐPQÑ8QŸ˜©HÑRÓS€JßÜØEØ�y‰yÑ<±Ó<Ó<Ð=Ð=XðZó
ð 	
ð €Oùò @ùÚRs   Á#CÁ6CÂCc                ó:   € V ^8„  d   QhR\         \        ,          /# ©rV   rY   ©rp   r*   )rZ   s   "r   r[   r[   œ   s   € ÷ &ñ &œ#œc�(ñ &r   c                 óª  € V f   \        4       # \        V \        \        34      '       d   \        \	        V 4      4      0# \        V \         \
        34      '       d%   V  Uu0 uF  p\        \	        V4      4      kK  	  up# \        V \        \        34      '       d(   \        4       pV  F  pV\        V4      ,          pK  	  V# \        V R4      '       d   V P                  4       p \        V R4      '       d   V P                  4       p \        V R4      '       d   \        V P                  4       4      # \        \	        \        V 4      4      4      0# u upi )NÚdetachÚcpurc   )rp   Ú
isinstancer*   rg   r`   Ú	frozensetrD   ÚtupleÚ_as_int_setÚhasattrr�   r‚   rc   )r/   ÚitemÚouts   &  r   r†   r†   œ   s  € Ø‚}Ü‹uˆÜ�%œ#œu˜×&Ò&Ü”E˜%“LÓ!Ð"Ð"Ü�%œ#œyÐ)×*Ò*Ù-2Ó3©U T””E˜$“KÖ ©UÑ3Ð3Ü�%œ$¤˜×'Ò'Ü‹eˆÛˆDØ”;˜tÓ$Õ$ŠCñ àˆ
Üˆu�h×ÒØ—‘“ˆÜˆu�e×ÒØ—	‘	“ˆÜˆu�h×ÒÜ˜5Ÿ<™<›>Ó*Ð*Ü””e˜E“lÓ#Ó$Ð%Ð%ùò 4s   Á Ec                ó:   € V ^8„  d   QhR\         \        ,          /# r~   r   )rZ   s   "r   r[   r[   ±   s   € ÷ ñ ´c¼#µhñ r   c                ó|   € V f   \        4       # V P                  ^8¼  d   V R,          pM	V R,          p\        V4      # )u  Unique RoPE *start* pixel times of extra guide / keyframe tokens.

``keyframe_idxs`` is ``(B, 3, tokens, 2)`` (t/h/w Ã— start/end). A keyframe
at pixel 24 spans the half-open interval ``[24, 25)``, so only 24 is
occupied â€” the exclusive end is not a slot.
)ºNNNr   rŒ   r   ©rŒ   r   )rp   Úndimr†   )Úkeyframe_idxsÚstartss   & r   Úpixel_frames_from_keyframe_idxsr‘   ±   s>   € ð ÒÜ‹uˆØ×Ñ˜QÔØ˜zÕ*‰à˜tÕ$ˆÜ�vÓÐr   c                óR   € V ^8„  d   QhR\         R\         R\        \         ,          /# )rV   Útemporal_scalerX   rY   )r*   rp   )rZ   s   "r   r[   r[   Á   s(   € ÷ &ñ &´#ð &Ä3ð &ÔehÔilÕemñ &r   c           	     ó‚  aaa	a
€ V R,          pVP                   ^,          pVf   Vo	M\        \        \        V4      ^ 4      V4      o	\	        4       o
R VV	V
V3R llpV P                  R4      pVe�   \        VR^ 4      ^8¼  do   \        \        VP                   ^,          S	4      4       FB  p\        P                  ! VRRWˆ^,           13,          \        8  4      '       g   K:  V! V4       KD  	  S
# \        S	4       F>  p\        P                  ! VRRWˆ^,           13,          ^ 8g  4      '       g   K6  V! V4       K@  	  S
# )aã  Pixel frames that already hold an in-place image keyframe.

Prefers ``noise_mask`` (0 means frozen / guided). Falls back to
non-zero latent frames when no mask is present. Each occupied latent
index maps to its representative pixel: 0, ``t * scale``, or last frame.

``video_latent_frames`` limits the scan to the video portion of T so
appended guide / detailing-keyframe tokens are not treated as video frames.
Extra-token pixel times come from ``pixel_frames_from_keyframe_idxs``.
Úsamplesc                ó(   € V ^8„  d   QhR\         RR/# )rV   r#   rY   N©r*   )rZ   s   "r   r[   Ú+occupied_pixel_frames.<locals>.__annotate__Ô   s   € ÷ 6ñ 6¤ð 6¨ñ 6r   c                 ó¶   <€ V ^ 8:  d   ^ pM!V S^,
          8¼  d   S^,
          pM	V S,          pSP                  \        \        V^ 4      S^,
          4      4       R# )r   N)ÚaddÚminrk   )r#   ÚpixelrX   Úscan_framesrr   r“   s   & €€€€r   Úadd_latent_indexÚ/occupied_pixel_frames.<locals>.add_latent_indexÔ   sK   ø€ Ø�AŒ:Ø‰EØ�k A•oÔ%Ø •N‰Eà˜NÕ*ˆEØ�	‰	”#”c˜% “m Z°!¥^Ó4Ö5r   Ú
noise_maskrŽ   rŒ   )rS   r›   rk   r*   rp   rC   ÚgetattrÚranger^   ÚanyÚ_OCCUPIED_MASK_MAX)Úlatentr“   rX   Úvideo_latent_framesr•   Úlatent_framesrž   Úmaskr#   r�   rr   s   &ff&     @@r   Úoccupied_pixel_framesr©   Á   s  û€ ð �YÕ€GØ—M‘M !Õ$€MØÒ"Ø#‰äœ#œcÐ"5Ó6¸Ó:¸MÓJˆÜ‹E€E÷6ó 6ð �:‰:�lÓ#€DØÒœG D¨&°!Ó4¸Ô9Üœ3˜tŸz™z¨!�}¨kÓ:Ö;ˆEÜ�yŠy˜˜a  E°A­IÐ$5Ð5Õ6Ô9KÑK×LÔLÙ  Ö'ñ <ð ˆä�{Ö#ˆÜ�9Š9�W˜Q  5°1­9Ð#4Ð4Õ5¸Ñ:×;Ô;Ù˜UÖ#ñ $ð €Lr   c                óH   € V ^8„  d   QhR\         R\         R\         R\         /# )rV   Úpixel_framer“   Únum_latent_framesrY   r—   )rZ   s   "r   r[   r[   ê   s0   € ÷ Sñ S¤cð S¼3ð SÔSVð SÔ[^ñ Sr   c                 óZ   € \        \        \        W,          4      ^ 4      V^,
          4      # )r   )r›   rk   r`   )r«   r“   r¬   s   &&&r   Únearest_latent_indexr®   ê   s%   € ÜŒs”5˜Õ5Ó6¸Ó:Ð<MÐPQÕ<QÓRÐRr   c                ó^   € V'       * ;'       d     VRJ;'       d    V'       * ;'       d    W8„  # )zKTrue when ``keyframes`` is a longer video to sample, not stacked keyframes.N© )Ú
keyframe_tÚrequested_countÚhas_recorded_indicesÚbatched_singless   &&&&r   Ú should_copy_nearest_video_framesrµ   î   sC   € ð !Ô ÷ 	)ð 	)Ø 4Ð'÷	)ð 	)àÔ÷	)ð 	)ð Ñ(ð	r   c                ó$   € V ^8„  d   QhR\         /# )rV   r“   r—   )rZ   s   "r   r[   r[   ø   s   € ÷ $ñ $¼3ñ $r   c           	     ó   € \         P                  ! V 4      '       d   V P                  ^8w  d   \        R4      h\	        V4      pV^8  d   \        RV 24      hV P
                  ^,          pV^8  d   \        R4      h. pV F2  p\        WRV4      pVP                  V RRWf^,           13,          4       K4  	  \         P                  ! V^R7      # )z9Stack the nearest video latent frame at each pixel index.z©Initializing keyframes from a video needs a plain 5D video latent. Split audio with Separate AV Latent first, and peel generated keyframes before copying from the video.z!temporal_scale must be >= 1, got z,The video latent has no frames to copy from.rŒ   ©Údim)	r^   Ú	is_tensorrŽ   r)   r*   rS   r®   rF   Úcat)r•   r7   r“   r¬   Úframesr«   Úidxs   &&&    r   Úkeyframes_from_videor¾   ø   sÆ   € ä�?Š?˜7×#Ò# w§|¡|°qÔ'8Üð7ó
ð 	
ô
 ˜Ó(€NØ˜ÔÜÐ<¸^Ð<LÐMÓNÐNØŸ™ aÕ(ÐØ˜1ÔÜÐGÓHÐHØ€FÛˆÜ" ;Ð@QÓRˆØ�‰�g˜a  C°­' MÐ1Õ2Ö3ñ ô �9Š9�V Ô#Ð#r   c                óî  € VP                   ^ ,          VP                   ^,          VVP                   ^,          VP                   ^,          3pV P                   ^,          pV P                   ^ ,          V^ ,          8w  g?   V P                   ^,          V^,          8w  g    V P                   R,          VR,          8w  d/   \        R\        V4       R\        V P                   4       R24      hWB8”  d   \        RV RV R24      hWB8  dn   \        P                  ! V^ ,          V^,          W$,
          V^,          V^,          3V P
                  V P                  R7      p\        P                  ! W.^R	7      p V # )
zJPad stacked keyframe tokens with zeros up to ``num_slots``; reject extras.ºé   NNzTThe keyframes latent must hold whole latent frames at this latent's shape, expected z	 but got z-. Resize it to this stage's resolution first.zThe keyframes latent holds z frame(s) but only zW free slot(s) are available on this canvas. Pass fewer keyframes, or set frame_indices.©ÚdtypeÚdevicer¸   )rS   r)   rD   r^   ÚzerosrÃ   rÄ   r»   )Úkeyframe_samplesr•   Ú	num_slotsÚexpectedÚhaveÚpads   &&&   r   Ú_fit_keyframe_samplesrË     sc  € ð 	�‰�aÕØ�‰�aÕØØ�‰�aÕØ�‰�aÕð€Hð ×!Ñ! !Õ$€Dà×Ñ˜qÕ! X¨a¥[Ô0Ø×!Ñ! !Õ$¨°­Ô3Ø×!Ñ! "Õ%¨°"­Ô5äØbÜ�H‹~Ð˜i¬Ð-=×-CÑ-CÓ(DÐ'Eð F ð ó
ð 	
ð
 ÔÜØ)¨$¨Ð/BÀ9À+ð NXð Xó
ð 	
ð ÔÜ�kŠkØ�a�[˜( 1�+ yÕ'7¸À!½ÀhÈqÅkÐRØ"×(Ñ(Ø#×*Ñ*ô
ˆô
 !Ÿ9š9Ð&6Ð%<À!ÔDÐØÐr   c                   óˆ   a € ] tR tRt o ]! ^RR7      t]R 4       t]RR l4       t]R 4       t	]RV 3R lR	 ll4       t
R
tV tR# )ÚLTXVAddGeneratedKeyframesi0  T)Ú	start_endc                óÎ  € \         P                  ! R RR. ROR\         P                  P                  RRR7      \         P                  P                  RRR7      \         P                  P                  R	R
R7      \         P
                  P                  RRR7      \         P                  P                  RR^^RRR7      \         P
                  P                  RRRR7      \         P                  P                  RRRRR7      .\         P                  P                  RRR7      \         P                  P                  RRR7      \         P
                  P                  RRR7      .R7      # )rÍ   zLTXV Add Generated Keyframesúmodel/conditioning/ltxvaY  Append detailing keyframes to a video latent. Each keyframe is one latent frame of tokens whose RoPE position spans a single pixel frame; they are denoised with the video and are not part of the decoded output. Placement is one slot every interval_frames pixels, skipping I2V frames, existing guides, and detailing keyframes already on the cond. Connected keyframes are content only and are re-placed on this canvas unless frame_indices is set. Pull them back out with LTXV Separate Generated Keyframes. Requires a checkpoint trained for generated keyframes (one carrying keyframes_abs_pos_embedding).rI   z4Positive conditioning the keyframes are attached to.©ÚtooltiprJ   z4Negative conditioning the keyframes are attached to.Úvaez+Only used to read the latent scale factors.r¥   zXPlain 5D video latent to generate keyframes alongside. Add them before Concat AV Latent.rf   Ti   z�Pixel-frame stride for auto placement. Default 24 is about one keyframe per second at 24 fps. Occupied pixels are skipped. Ignored when frame_indices is set.)ÚoptionalÚdefaultr›   rk   rÒ   Ú	keyframesa�  Optional content to initialize the new keyframes with. Connect keyframes from an earlier Separate (same spatial size), or a plain video latent to copy the nearest frame at each new slot (e.g. after temporal upscale). These are still denoised, not pinned as guides. Recorded indices on a keyframes latent are ignored unless frame_indices is set. Only has an effect when sampling starts below sigma 1.)rÔ   rÒ   Úframe_indicesÚ zýOptional pixel-frame indices. Leave empty to place from interval_frames on the current canvas. When set, this list is the placement (connected keyframes are matched in order). The last frame is allowed; frame 0 is not (it is already a standalone token).©rÔ   rÕ   rÒ   zAPositive conditioning with generated-keyframe attention attached.©Údisplay_namerÒ   zANegative conditioning with generated-keyframe attention attached.z4Video latent with generated keyframes appended on T.©Únode_idrÛ   ÚcategoryÚsearch_aliasesÚdescriptionÚinputsÚoutputs)Ú	detailingÚdfrzgenerated keyframes)	r   ÚSchemaÚConditioningÚInputÚVaeÚLatentÚIntÚStringÚOutput©Úclss   &r   Údefine_schemaÚ'LTXVAddGeneratedKeyframes.define_schema3  s|  € ä�yŠyØ/Ø7Ø.ÚFð0ô —‘×%Ñ%ØØRð &ó ô —‘×%Ñ%ØØRð &ó ô —‘—‘ØÐ#Pð ó ô —	‘	—‘Øð3ð  ó ô —‘—‘Ø%Ø!ØØØð=ð ó ô —	‘	—‘ØØ!ð9ð	  ó ô —	‘	—‘Ø#Ø!Øð-ð  ó ðY8ôt —‘×&Ñ&Ø!+Ø_ð 'ó ô —‘×&Ñ&Ø!+Ø_ð 'ó ô —	‘	× Ñ Ø!)ØRð !ó ðôSW
ð W	
r   Nc           
     ó‚   € ^V^,
          rTWT8  d   \        RV R24      h\        TRTTTVe   V R2RR7      # RRR7      # )z±Pixel frame positions from a manual override.

Frame 0 is excluded (already a standalone token). The terminal frame is
allowed so a DFR segment grid that includes N-1 is legal.
ri   rj   r×   z keyframe(s)zthe list sets the countz"to place them from interval_frames©r4   r5   )r)   r;   )rî   r×   Únum_pixel_framesr1   r2   r3   s   &&&&  r   Úparse_frame_indicesÚ-LTXVAddGeneratedKeyframes.parse_frame_indicesŽ  s|   € ð Ð)¨AÕ-ˆtØŒ<ÜØÐ%Ð&Ð&^Ð_óð ô 'ØØØØØð "Ò-ð "Ð" ,Ð/ð <ô
ð 	
ð /à;ô
ð 	
r   c                ó’   € V P                   P                  VR,          4      w  rE\        WSRR7      pVR;;,          V,          uu&   V# )zIPixel coordinates of one keyframe: the full spatial grid over [t, t + 1).T)Ú
causal_fix)rŒ   rŒ   :Nr]   Nr�   )Ú
PATCHIFIERÚpatchifyr   )rî   r¥   Úframe_indexÚscale_factorsÚ_Úlatent_coordsÚpixel_coordss   &&&&   r   Úkeyframe_coordsÚ)LTXVAddGeneratedKeyframes.keyframe_coords¨  sC   € ð Ÿ>™>×2Ñ2°6¸(Õ3CÓDÑˆÜ-¨mÐW[Ô\ˆØ�T×˜kÕ)ÓØÐr   c                ó4   <€ V ^8„  d   QhRS[ P                  /# r~   ©r   Ú
NodeOutput)rZ   Ú__classdict__s   "€r   r[   Ú&LTXVAddGeneratedKeyframes.__annotate__±  s   ø€ ÷ u6ñ u6ñ 
�‰ñu6r   c                óD  € VR ,          p\         P                  ! V4      '       d   VP                  ^8w  d   \        R4      h\	        V4      p	V	eÍ   V	R,          p
W¨P
                  ^,          VP
                  ^,          ,          8w  d<   \        RV
 RVP
                  ^,          VP
                  ^,          ,           R24      hV	R,          pV	R,          pW¼,           VP
                  ^,          8w  d*   \        R	W¼,            R
VP
                  ^,           R24      hVP                  pV^ ,          p\        WP
                  4      w  ppVP
                  ^,          V,
          pV^,
          V,          ^,           p\        VVVVR7      pV\        V4      ,          pV	e   \        V	R,          4      M. pV\        V4      ,          pV'       d3   \        V4      P                  4       '       d   V P                  VV4      pM\        V\!        V4      V4      p\#        \        V4      V,          4      pV'       d&   \        RRP%                  R V 4       4       R24      h\'        V4      pVEeè   VR ,          pVP                  ^8w  d#   \        R\        VP
                  4       R24      hVP)                  R4      pVP
                  ^,          ^8H  ;'       d(    VP
                  ^ ,          VP
                  ^ ,          8g  pV'       dë   VP
                  ^ ,          VP
                  ^ ,          ,          ^ 8w  d5   \        RVP
                  ^ ,           RVP
                  ^ ,           R24      hVP
                  ^ ,          VP
                  ^ ,          ,          pVP*                  ! VP
                  ^ ,          VVP
                  ^,          .VP
                  R,          O5!  P-                  ^^4      pRp\/        VP
                  ^,          VVRJV4      '       d   \1        VVV4      pM\3        VP5                  V4      VV4      pVP5                  V4      pMv\         P6                  ! VP
                  ^ ,          VP
                  ^,          VVP
                  ^,          VP
                  ^,          3VP8                  VP:                  R7      p\         P<                  ! V Uu. uF  pV P?                  VVV4      NK  	  up^R7      pVe*   \         P<                  ! VVP5                  V4      .^R7      p\A        VRR4      ;'       g    . pRV	'       d
   V	R,          MVP
                  ^,          RV	'       d   V	R,          V,           MTRV\        V4      ,           RTRV	'       d
   V	R,          M
\'        V4      RVP
                  ^,          VP
                  ^,          ,          /pRVR V/p \B        PD                  ! VV 4      p\B        PD                  ! VV 4      pV	eK   \G        VVV	R,          VVP
                  ^,          ,          VP
                  ^,          ,          VR!7      w  rMg\I        VVVVP
                  ^,          ,          VP
                  ^,          ,          VVP
                  ^,          VP
                  ^,          .R"R#7      w  r\K        V4      p!\         PL                  ! V!P
                  ^ ,          ^VV!P
                  ^,          V!P
                  ^,          3V!P8                  V!P:                  R7      p"VPO                  4       p#\         P<                  ! VV.^R7      V#R &   \         P<                  ! V!V".^R7      V#R$&   \P        PR                  ! WV#4      # u upi )%r•   z…Generated keyframes must be added to a plain video latent. Add them before merging the video and audio latents with Concat AV Latent.NÚtokens_per_framez/The existing generated keyframes were added at ú- tokens per latent frame but this latent has z^. The latent was rescaled after they were added, so more keyframes cannot be appended to them.Úfirst_latent_framerW   z5The existing generated keyframes end at latent frame z but the latent has z�. Something was appended after them, so more keyframes would not be contiguous with the existing block. Add all the keyframes before any guides.)r¦   r×   z$frame_indices reuses pixel frame(s) r   c              3   ó8   "  € T F  p\        V4      x € K  	  R # 5ir   r    )r   Úis   & r   r   Ú4LTXVAddGeneratedKeyframes.execute.<locals>.<genexpr>ë  s   é € Ð@YÑQXÈAÄÀQÇÀÓQXùr%   zr, which already hold an image keyframe, a guide, or a generated keyframe. Each keyframe needs its own pixel frame.z0The keyframes latent must be 5 dimensional, got r   Úgenerated_keyframe_indiceszThe keyframes latent batch (z/) is not a multiple of the video latent batch (z5), so it cannot be reshaped into per-video keyframes.rÀ   FrÂ   r¸   r=   ró   Úguide_entry_indexr�   r   )rK   rL   ç      ð?©rA   rB   Ústrengthr    )*r^   rº   rŽ   r)   r   rS   Údownscale_index_formular
   r©   r‘   rD   rp   r!   r(   rô   rs   rg   r-   r+   r,   rC   ÚreshapeÚmovedimrµ   r¾   rË   ra   rÅ   rÃ   rÄ   r»   rÿ   r	   rG   rH   rT   r   r   ÚonesÚcopyr   r  )$rî   rI   rJ   rÓ   r¥   rf   rÖ   r×   r•   Úexisting_recordÚprev_tokens_per_frameÚ
prev_firstÚ
prev_countrû   Útime_scale_factorr�   Únum_guide_framesÚnum_target_framesró   ro   Úprev_indicesr7   ÚclashesrW   rÆ   Úrecorded_positionsr´   Ústackedr#   Úgenerated_coordsÚexisting_entriesr   Úvaluesr    Úkeyframe_noise_maskr‰   s$   &&&&&&&&                            r   ÚexecuteÚ!LTXVAddGeneratedKeyframes.execute°  s$  € ð ˜Õ#ˆÜ�Š˜w×'Ò'¨7¯<©<¸1Ô+<ÜðMóð ô
 2°(Ó;ˆØÒ&Ø$3Ð4FÕ$GÐ!Ø$¯©°aÕ(8¸7¿=¹=ÈÕ;KÕ(KÔKÜ ØEÐF[ÐE\ð ]1Ø18·±¸qÕ1AÀGÇMÁMÐRSÕDTÕ1TÐ0Uð V[ð[óð ð
 )Ð)=Õ>ˆJØ(¨Õ9ˆJØÕ&¨'¯-©-¸Õ*:Ô:Ü ØKÈJÕLcÐKdð e"Ø")§-¡-°Õ"2Ð!3ð 4jðjóð ð ×3Ñ3ˆØ)¨!Õ,ÐÜ*;¸HÇmÁmÓ*TÑ'ˆÐ'Ø#ŸM™M¨!Õ,Ð/?Õ?ÐØ-°Õ1Ð5FÕFÈÕJÐÜ(ØØØØ 1ô	
ˆð 	Ô3°MÓBÕBˆØAPÒA\”t˜O¨OÕ<Ô=ÐbdˆØ”C˜Ó%Õ%ˆçœS Ó/×5Ñ5×7Ò7Ø×-Ñ-¨mÐ=MÓN‰Gä*Ð+;¼UÀ?Ó=SÐU]Ó^ˆGäœ˜W›¨Õ0Ó1ˆßÜØ6°t·y±yÑ@YÑQXÓ@YÓ7YÐ6Zð [pð póð ô
 ˜G›ˆØÓ Ø(¨Õ3ÐØ×$Ñ$¨Ô)Ü ØFÄtÐL\×LbÑLbÓGcÐFdÐdeÐfóð ð "+§¡Ð/KÓ!LÐà ×&Ñ& qÕ)¨QÑ.÷ Bð BØ$×*Ñ*¨1Õ-°·±¸qÕ1AÑAð ÷ Ø#×)Ñ)¨!Õ,¨w¯}©}¸QÕ/?Õ?À1ÔDÜ$Ø6Ð7G×7MÑ7MÈaÕ7PÐ6Qð R?Ø?F¿}¹}ÈQÕ?OÐ>Pð QGðGóð ð
 +×0Ñ0°Õ3°w·}±}ÀQÕ7GÕG�Ø#3×#;Ò#;Ø—M‘M !Õ$ØØ$×*Ñ*¨1Õ-ð$ð &×+Ñ+¨BÕ/ó	$÷
 ‘'˜!˜Q“-ð !ð #(�Ü/Ø ×&Ñ& qÕ)ØØ"¨$Ð.Ø÷	ò ô $8Ø$ØØ%ó$Ñ ô $9Ø$×'Ñ'¨Ó0°'¸=ó$Ð ð  0×2Ñ2°7Ó;Ñä$Ÿ{š{à—M‘M !Õ$Ø—M‘M !Õ$Ø!Ø—M‘M !Õ$Ø—M‘M !Õ$ðð —m‘mØ—~‘~ô
 Ðô !Ÿ9š9ÙMTÓUÉWÀEˆS× Ñ  ¨%°Ö?ÉWÑUØô
Ðð Ò$Ü$Ÿyšy¨-Ð9I×9LÑ9LÈ]Ó9[Ð)\ÐbcÔdÐä5°hÐ@YÐ[_Ó`×fÐfÐdfÐà ß9H�Ð 4Ö5ÈgÏmÉmÐ\]ÕN^àßDS� Õ0°=Ö@ÐYfà˜\¬D°«MÕ9ØÐ 0Øß8G�Ð 3Ö4ÌSÐQaÓMbà §¡¨aÕ 0°7·=±=ÀÕ3CÕ Cð
Ðð  Ð-Ø!Ð#6ð
ˆô  ×7Ò7¸À&ÓIˆÜ×7Ò7¸À&ÓIˆàÒ&Ü!<ØØØÐ 3Õ4Ø'4°w·}±}ÀQÕ7GÕ'GÈ'Ï-É-ÐXYÕJZÕ'ZØ*ô"ÑˆH�hô "?ØØØ!.°·±¸qÕ1AÕ!AÀGÇMÁMÐRSÕDTÕ!TØ+¨W¯]©]¸1Õ-=¸w¿}¹}ÈQÕ?OÐPØô"ÑˆHô $ FÓ+ˆ
Ü#Ÿjšjà× Ñ  Õ#ØØØ× Ñ  Õ#Ø× Ñ  Õ#ðð ×"Ñ"Ø×$Ñ$ô

Ðð �k‰k‹mˆÜŸš GÐ-=Ð#>ÀAÔFˆˆI‰Ü!ŸIšI zÐ3FÐ&GÈQÔOˆˆLÑÜ�}Š}˜X°Ó5Ð5ùò} Vs   Ó^r°   r   )é   NrØ   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r   rø   Úclassmethodrï   rô   rÿ   r&  Ú__static_attributes__Ú__classdictcell__©r  s   @r   rÍ   rÍ   0  sj   ø‡ € Ù$ Q°$Ô7€JàñX
ó ðX
ðt ó
ó ð
ð2 ñó ðð ÷u6ñ u6ó öu6r   rÍ   c                   óp   a € ] tR tRt o ]R 4       t]R 4       t]R 4       t]R	V 3R lR ll4       tRt	V t
R# )
ÚLTXVSeparateGeneratedKeyframesii  c                ó6  € \         P                  ! R RR. ROR\         P                  P                  R4      \         P                  P                  R4      \         P                  P                  R4      \         P
                  P                  RRR	R
7      .\         P                  P                  RRR7      \         P                  P                  RRR7      \         P                  P                  RRR7      \         P                  P                  RRR7      .R7      # )r2  z!LTXV Separate Generated KeyframesrÐ   u,  Split the generated keyframes added by LTXV Add Generated Keyframes back out of a sampled latent, and remove them from the conditioning. Separate them before spatially upscaling the video latent. Do not run LTXV Crop Guides first â€” it treats generated keyframes as disposable guides and drops them.rI   rJ   r¥   Úkeyframes_to_batchFz¸Return the keyframes as a batch of single-frame latents. Leave off to get them as one multi-frame latent, which is what the latent upsampler and a later Add Generated Keyframes expect.)rÕ   rÒ   z?Positive conditioning with generated-keyframe metadata removed.rÚ   z?Negative conditioning with generated-keyframe metadata removed.z3Video latent with the generated keyframes stripped.rÖ   a#  The peeled keyframes, labeled with generated_keyframe_indices and generated_keyframe_num_frames. Feed these to a later Add Generated Keyframes to initialize new slots, or to Generated Keyframes To Guides to pin them as frozen image guides (indices are remapped if the canvas length changed).rÜ   )rã   rä   zpeel keyframes)r   rå   ræ   rç   ré   ÚBooleanrì   rí   s   &r   rï   Ú,LTXVSeparateGeneratedKeyframes.define_schemaj  s  € ä�yŠyØ4Ø<Ø.ÚAð)ô —‘×%Ñ% jÓ1Ü—‘×%Ñ% jÓ1Ü—	‘	—‘ Ó)Ü—
‘
× Ñ Ø(Ø!ðPð	 !ó ð	ô —‘×&Ñ&Ø!+Ø]ð 'ó ô —‘×&Ñ&Ø!+Ø]ð 'ó ô —	‘	× Ñ Ø!)ØQð !ó ô —	‘	× Ñ Ø!,ð9ð !ó 	ðô52
ð 2	
r   c                óÐ   € \        VR R4      pVf   R# \        P                  ! VRRRV13,          VRRW#,           R13,          .^R7      pVP                  ^,          ^ 8”  d   V# R# )r�   NrŒ   r¸   )r	   r^   r»   rS   )rî   r   Úfirst_tokenÚ
num_tokensr�   Ú	remainings   &&&&  r   Ústrip_keyframe_idxsÚ2LTXVSeparateGeneratedKeyframes.strip_keyframe_idxs   sv   € ä2°4¸È$ÓOˆØÒ ÙÜ—I’Ià˜a  L [ LÐ0Õ1Ø˜a  KÕ$<Ñ$>Ð>Õ?ðð ô
ˆ	ð &ŸO™O¨AÕ.°Ô2ˆyÐ<¸Ð<r   c                óÈ   € \        VR R4      pV'       g   R# V\        V4      8¼  d   \        RV R\        V4       R24      hVRV W2^,           R ,           pT;'       g    R# )r=   Nr>   r?   r@   )r	   r,   r)   )rî   r   Úentry_indexrQ   r:  s   &&&  r   Ústrip_guide_entryÚ0LTXVSeparateGeneratedKeyframes.strip_guide_entry®  sw   € ä,¨TÐ3LÈdÓSˆßÙØœ#˜g›,Ô&ÜØ?À¸}ÐLkÜ�w“<�.Ð UðWóð ð ˜L˜[Ð)¨GÀ!µOÐ4EÐ,FÕFˆ	Ø× Ð ˜DÐ r   c                ó4   <€ V ^8„  d   QhRS[ P                  /# r~   r  )rZ   r  s   "€r   r[   Ú+LTXVSeparateGeneratedKeyframes.__annotate__¼  s   ø€ ÷ LIñ LIÉbÏmÉmñ LIr   c                ó  € \        V4      pVf   \        R4      hVR,          p\        P                  ! V4      '       d   VP                  ^8w  d   \        R4      hVP
                  ^,          VP
                  ^,          ,          pVR,          V8w  d   \        RVR,           RV R24      hVR,          pVR	,          p	W‰,           p
W¦P
                  ^,          8”  d'   \        R
V RV
 RVP
                  ^,           R24      hVRRWŠ13,          P                  4       pV'       d<   VP
                  w  rÍrïpVP                  ^^4      P                  WÉ,          V^VV4      p\        P                  ! VRRR V13,          VRRV
R 13,          .^R7      p\        V4      p\        P                  ! VRRR V13,          VRRV
R 13,          .^R7      p\        WP
                  4      w  ppW†P
                  ^,          V,
          ,
          V,          pVR,          p. pW3 FV  pVP                  \        P                  ! VRV P                  VVW—,          4      RV P!                  VV4      RR /4      4       KX  	  VP#                  4       pVVR&   VVR&   VP%                  R4      pVf   V^,
          \&        ,          ^,           pRVR\)        VR,          4      R\+        V4      /p\,        P.                  ! V^ ,          V^,          VV4      # )NzYThis latent has no generated keyframes. Add them with LTXV Add Generated Keyframes first.r•   z�Generated keyframes must be separated from a plain video latent. Split the video and audio latents with Separate AV Latent first.r  z&The generated keyframes were added at r  z. The latent was rescaled after they were added, so the keyframes no longer line up. Separate them before upscaling the latent.r	  rW   z,The generated keyframes span latent frames [r   z) but the latent only has z-. It was recorded against a different latent.rŒ   r¸   r  r�   r=   r   r    ró   r  r×   Úgenerated_keyframe_num_frames)r   r)   r^   rº   rŽ   rS   Úcloner  r  r»   r   r
   rF   rG   rH   r;  r?  r  rC   ÚDEFAULT_TEMPORAL_SCALErD   r*   r   r  )rî   rI   rJ   r¥   r4  r   r•   r  Úfirst_framerW   Ú	end_framerÆ   ÚbatchÚchannelsrü   ÚheightÚwidthÚvideo_samplesr    Úvideo_noise_maskr  r8  r>  râ   r   r‰   ró   Úkeyframes_outs   &&&&&                       r   r&  Ú&LTXVSeparateGeneratedKeyframes.execute»  s:  € ä5°hÓ?ÐØÒ&ÜØkóð ð ˜Õ#ˆÜ�Š˜w×'Ò'¨7¯<©<¸1Ô+<Üð?óð ð
 #Ÿ=™=¨Õ+¨g¯m©m¸AÕ.>Õ>ÐØÐ1Õ2Ð6FÔFÜØ8Ð9LÐM_Õ9`Ð8að b4Ø4DÐ3Eð Fhðhóð ð *Ð*>Õ?ˆØ+¨OÕ<ˆØÕ/ˆ	Ø—}‘} QÕ'Ô'ÜØ>¸{¸mÈ2ÈiÈ[ð YØ#ŸM™M¨!Õ,Ð-Ð-Zð\óð ð
 # 1 a¨Ð)>Ð#>Õ?×EÑEÓGÐßØ0@×0FÑ0FÑ-ˆE˜Q¨Ø/×7Ñ7¸¸1Ó=×EÑEØÕ% x°°F¸Eó Ðô Ÿ	š	Ø�Q˜˜<˜K˜<Ð'Õ(¨'°!°Q¸	¹
Ð2BÕ*CÐDÈ!ô
ˆô $ FÓ+ˆ
Ü Ÿ9š9Ø˜˜1˜l˜{˜lÐ*Õ+¨Z¸¸1¸i¹jÐ8HÕ-IÐJÐPQô
Ðô 0°¿-¹-ÓHÑˆÐØ"§m¡m°AÕ&6Ð9IÕ&IÕJÐN^Õ^ˆØ)Ð*=Õ>ˆàˆØÓ(ˆDØ�N‰NÜ×4Ò4Øà'¨×)@Ñ)@Ø  +¨}Õ/Oó*ð 2°3×3HÑ3HÈÈ{Ó3[Ø-¨tðó	öñ )ð �k‰k‹mˆØ&ˆˆI‰Ø,ˆˆLÑØ.×2Ñ2Ð3EÓFÐØÒ#Ø +¨a¥Ô3IÕIÈAÕMÐàÐ'Ø(¬$Ð/BÀ?Õ/SÓ*TØ+¬SÐ1AÓ-Bð
ˆô
 �}Š}˜W Q�Z¨°­°S¸-ÓHÐHr   r°   N)F)r)  r*  r+  r,  r-  rï   r;  r?  r&  r.  r/  r0  s   @r   r2  r2  i  s_   ø‡ € Øñ3
ó ð3
ðj ñ=ó ð=ð ñ
!ó ð
!ð ÷LIñ LIó öLIr   r2  c                   óp   a € ] tR tRt o ]R 4       t]R 4       t]R	V 3R lR ll4       t]R 4       tRt	V t
R# )
ÚLTXVGeneratedKeyframesToGuidesi  c                óÀ  € \         P                  ! R RR. ROR\         P                  P                  R4      \         P                  P                  R4      \         P                  P                  R4      \         P
                  P                  RRR	7      \         P
                  P                  R
RR	7      \         P                  P                  RRRRRRR7      \         P                  P                  RRRRR7      .\         P                  P                  RRR7      \         P                  P                  RRR7      \         P
                  P                  RRR7      .R7      # )rR  z"LTXV Generated Keyframes to GuidesrÐ   aæ  Pin generated keyframes from an earlier stage as frozen image guides on a later canvas. They are decoded as standalone frames, resized if needed, and written with noise_mask=0 so they are not denoised again. After a temporal upscale, recorded indices are scaled from the canvas they were generated on onto this one (same moments). Use override_frame_indices to set positions explicitly. To keep generating (and denoising) keyframes at new positions, use Add Generated Keyframes instead.rI   rJ   rÓ   r¥   zOThe target video latent to add the guides to, e.g. the temporally upscaled one.rÑ   rÖ   z~The keyframes output of LTXV Separate Generated Keyframes, which carries the pixel frame index each keyframe was generated at.r  r  g        g      $@g{®Gáz„?z9Guide strength. 1.0 is a hard pin; lower values relax it.)rÕ   r›   rk   ÚsteprÒ   Úoverride_frame_indicesTrØ   uû   Optional â€” pin at these pixel frames instead of the recorded (or auto-scaled) positions. Provide one index per keyframe. Leave empty to reuse recorded positions, or to scale them when the target canvas is a different length (e.g. after temporal x2).rÙ   z@Positive conditioning with the keyframes pinned as image guides.rÚ   z@Negative conditioning with the keyframes pinned as image guides.z>Target video latent with the keyframes added as frozen guides.rÜ   )rã   rä   zkeyframe guides)	r   rå   ræ   rç   rè   ré   ÚFloatrë   rì   rí   s   &r   rï   Ú,LTXVGeneratedKeyframesToGuides.define_schema  sN  € ä�yŠyØ4Ø=Ø.ÚBðFô —‘×%Ñ% jÓ1Ü—‘×%Ñ% jÓ1Ü—‘—‘˜UÓ#Ü—	‘	—‘ØØmð  ó ô —	‘	—‘ØðXð  ó ô —‘—‘ØØØØØØWð ó ô —	‘	—‘Ø,Ø!Øð\ð  ó 
ð/"ôH —‘×&Ñ&Ø!+Ø^ð 'ó ô —‘×&Ñ&Ø!+Ø^ð 'ó ô —	‘	× Ñ Ø!)Ø\ð !ó ðôc?
ð ?	
r   c                ó0  € VP                   ^,          ^8w  d;   VP                   w  r4rVpVP                  ^^4      P                  W5,          V^Wg4      pVP                  V4      pVP                  ^8X  d"   VP                  ! R.VP                   RR O5!  pV# )z:Decode each keyframe latent on its own, never as one clip.Néÿÿÿÿéýÿÿÿ)rS   r  r  ÚdecoderŽ   )	rî   rÓ   rÆ   rI  rJ  rW   rK  rL  Úimagess	   &&&      r   Údecode_single_framesÚ3LTXVGeneratedKeyframesToGuides.decode_single_framesO  s“   € ð ×!Ñ! !Õ$¨Ô)Ø<L×<RÑ<RÑ9ˆE˜]°EØ/×7Ñ7¸¸1Ó=×EÑEØÕ% x°°Fó Ðð —‘Ð,Ó-ˆØ�;‰;˜!ÔØ—^’^ BÐ;¨¯©°b°cÐ):Ó;ˆFØˆr   c                ó4   <€ V ^8„  d   QhRS[ P                  /# r~   r  )rZ   r  s   "€r   r[   Ú+LTXVGeneratedKeyframesToGuides.__annotate__]  s   ø€ ÷ ^9ñ ^9ñ 
�‰ñ^9r   c                óø  € VP                  R R4      pVf   \        R4      h\        V4      e   \        R4      hVR,          p	\        P                  ! V	4      '       d   V	P
                  ^8w  d   \        R4      hV	P                  ^ ,          ^8w  d!   \        RV	P                  ^ ,           R24      hVR,          p
V
P                  ^,          ^8w  d;   V
P                  w  r¼rÞpV
P                  ^^4      P                  W½,          V^Wï4      p
V
P                  R,          V	P                  R,          8g  pV'       d   V P                  W:4      MT
pVP                  ^ ,          \        V4      8w  d-   \        R	VP                  ^ ,           R
\        V4       R24      h\        WP                  4      w  ppVP                  ^ ,          pV	P                  ^,          V,
          ^,
          V,          ^,           pV'       dO   \        V4      P                  4       '       d0   \        VR\        V4      ^V^,
          R\        V4       2RR7      pMDVP                  R4      pVe0   \!        V4      V8w  d    \#        \%        V4      \!        V4      V4      pV'       d,   \'        V4      V8¼  d   \        R\'        V4       RV R24      h\)        V4       F’  w  ppV'       dX   \*        P,                  ! VVVVVV,          P/                  ^ 4      \!        V4      V4      pV^ ,          V^,          V^,          rBpKe  V P1                  VVVVVVV^,            \!        V4      V4      w  rpK”  	  \2        P4                  ! WV4      # )r  Nz{This latent does not carry generated keyframe positions. Connect the keyframes output of LTXV Separate Generated Keyframes.z„This conditioning still carries generated keyframes. Connect the positive and negative outputs of LTXV Separate Generated Keyframes.r•   z‹Generated keyframe guides must be added to a plain video latent. Add them before merging the video and audio latents with Concat AV Latent.z)Only a batch size of 1 is supported, got zR. Each guide is encoded from one image, so it cannot differ across batch elements.rÀ   zGot z keyframes for z recorded positions.rU  zthe keyframes latent carries zto reuse the recorded positionsrò   rD  zKeyframe position z is outside this latent's zN frames. The target was resized temporally after the keyframes were generated.)rC   r)   r   r^   rº   rŽ   rS   r  r  r]  r,   r
   r  r!   r(   r;   r*   r|   rD   rk   Ú	enumerater   r&  Ú	unsqueezeÚappend_latent_keyframer   r  )rî   rI   rJ   rÓ   r¥   rÖ   r  rU  r7   r•   Ú
kf_samplesrI  rJ  rW   rK  rL  Úresize_neededÚguidesrü   r  r  ró   Úold_lenr#   Ú	frame_idxÚaddeds   &&&&&&&&                  r   r&  Ú&LTXVGeneratedKeyframesToGuides.execute\  sY  € ð —-‘-Ð <¸dÓCˆØŠ?Üð8óð ô # 8Ó,Ò8ÜðIóð ð
 ˜Õ#ˆÜ�Š˜w×'Ò'¨7¯<©<¸1Ô+<ÜðMóð ð �=‰=˜Õ˜qÔ ÜØ;¸G¿M¹MÈ!Õ<LÐ;Mð NHð Hóð ð
 ˜yÕ)ˆ
Ø×Ñ˜AÕ !Ô#Ø<F×<LÑ<LÑ9ˆE˜]°EØ#×+Ñ+¨A¨qÓ1×9Ñ9ØÕ% x°°FóˆJð #×(Ñ(¨Õ,°·±¸bÕ0AÑAˆß>K�×)Ñ)¨#Ô:ÐQ[ˆØ�<‰<˜�?œc '›lÔ*ÜØ�v—|‘| A•Ð' ´s¸7³|°nÐDXÐYóð ô 0°¿-¹-ÓHÑˆÐØ×7Ñ7¸Õ:ÐØ#ŸM™M¨!Õ,Ð/?Õ?À!ÕCÐGXÕXÐ[\Õ\Ðß!¤cÐ*@Ó&A×&GÑ&G×&IÒ&IÜ-Ø&Ø(Ü�G“ØØ  1Õ$Ø =¼cÀ'»l¸^ÐLØ<ô‰Gð  —m‘mÐ$CÓDˆGØÒ"¤s¨7£|Ð7GÔ'GÜ-¬d°7«m¼SÀ»\ÐK[Ó\�ß”s˜7“|Ð'7Ô7ÜØ$¤S¨£\ NÐ2LÐM]ÐL^ð _Tð Tóð ô
 !*¨'Ö 2ÑˆE�9ßÜ$×,Ò,ØØØØØ˜5•M×+Ñ+¨AÓ.Ü˜	“NØó�ð .3°1­X°u¸QµxÀÀqÅ F�¡Fà-0×-GÑ-GØØØØØ˜5 5¨1¥9Ð-Ü˜	“NØó.Ñ*�¢Fñ !3ô. �}Š}˜X°Ó8Ð8r   c           
     óT  € \        V4      p\        P                  ! VVVVR,          VVVVP                  4      w  rr˜\	        VV\
        P                  ! VP                  R,          4      \        VP                  R,          4      VR7      w  rVP                  4       p
WšR&   WŠR&   WV
3# )zYAppend an already encoded keyframe latent the same way LTXVAddGuide would after encoding.r•   :rV   NNr  r    )
r   r   Úappend_keyframer  r   ÚmathÚprodrS   rD   r  )rî   rI   rJ   rÓ   r¥   Úguiding_latentri  r  r    Úlatent_imager‰   s   &&&&&&&&   r   rd  Ú5LTXVGeneratedKeyframesToGuides.append_latent_keyframe½  s¯   € ô $ FÓ+ˆ
Ü7C×7SÒ7SØØØØ�9ÕØØØØ×'Ñ'ó	8
Ñ4ˆ˜Lô ;ØØÜ!ŸYšY ~×';Ñ';¸BÕ'?Ó@Ü˜n×2Ñ2°2Õ6Ó7Øô
Ñˆð �k‰k‹mˆØ%ˆI‰Ø&ˆLÑØ 3Ð&Ð&r   r°   N)rØ   )r)  r*  r+  r,  r-  rï   r]  r&  rd  r.  r/  r0  s   @r   rR  rR    s_   ø‡ € Øñ@
ó ð@
ðD ñ
ó ð
ð ÷^9ñ ^9ó ð^9ð@ ñ'ó ö'r   rR  c                   óL   a € ] tR tRt o ]R 4       t]V 3R lR l4       tRtV tR# )ÚLTXVFreezeLatentiØ  c                ó¾   € \         P                  ! R RR. R	OR\         P                  P                  RRR7      .\         P                  P	                  RR7      .R7      # )
rt  zLTXV Freeze Latentzmodel/latent/ltxvzÝSet noise_mask to 0 so this latent is kept clean during sampling. Works on video or audio. Typical uses: freeze audio before Concat AV so it only provides cross-attention, or freeze any latent that should not be denoised.r¥   z:Video or audio latent to freeze. Audio is 4D; video is 5D.rÑ   )rÛ   rÜ   )z
noise maskzfreeze audiozfreeze video)r   rå   ré   rç   rì   rí   s   &r   rï   ÚLTXVFreezeLatent.define_schemaÙ  sb   € ä�yŠyØ&Ø-Ø(ÚIð#ô —	‘	—‘ØØXð  ó ðô —	‘	× Ñ ¨hÐ Ó7ðô#
ð 	
r   c                ó4   <€ V ^8„  d   QhRS[ P                  /# r~   r  )rZ   r  s   "€r   r[   ÚLTXVFreezeLatent.__annotate__ò  s   ø€ ÷ "ñ "¡§¡ñ "r   c                ó\  € VR ,          p\         P                  ! V4      '       g   \        R4      hVP                  4       pVP                  ^8X  dL   VP
                  w  rEp p\         P                  ! V^V^^3\         P                  VP                  R7      VR&   M{VP                  ^8X  dI   VP
                  w  rEre\         P                  ! V^V^3\         P                  VP                  R7      VR&   M"\        R\        VP
                  4       R24      h\        P                  ! V4      # )r•   zhFreeze Latent expects a plain tensor, not a concatenated AV latent. Split with Separate AV Latent first.rÂ   r    z2Expected a 4D audio or 5D video latent, got shape r   )r^   rº   r)   r  rŽ   rS   rÅ   Úfloat32rÄ   rD   r   r  )rî   r¥   r•   r‰   rI  rü   r¼   s   &&     r   r&  ÚLTXVFreezeLatent.executeñ  s  € à˜Õ#ˆÜ�Š˜w×'Ò'Üð7óð ð �k‰k‹mˆØ�<‰<˜1ÔØ%,§]¡]Ñ"ˆE�f˜a Ü %§¢Ø˜˜6 1 aÐ(Ü—m‘mØ—~‘~ô!ˆC�Òð
 �\‰\˜QÔØ")§-¡-ÑˆE�fÜ %§¢Ø˜˜6 1Ð%Ü—m‘mØ—~‘~ô!ˆC�Òô ØDÄTÈ'Ï-É-ÓEXÐDYÐYZÐ[óð ô �}Š}˜SÓ!Ð!r   r°   N)	r)  r*  r+  r,  r-  rï   r&  r.  r/  r0  s   @r   rt  rt  Ø  s+   ø‡ € Øñ
ó ð
ð. ÷"ó ö"r   rt  c                   ó<   a € ] tR tRt o ]V 3R lR l4       tRtV tR# )ÚLTXVKeyframesExtensioni  c                óT   <€ V ^8„  d   QhRS[ S[S[P                  ,          ,          /# r~   )rD   Útyper   Ú	ComfyNode)rZ   r  s   "€r   r[   Ú#LTXVKeyframesExtension.__annotate__  s"   ø€ ÷ 
ñ 
¡T©$©r¯|©|Õ*<Õ%=ñ 
r   c              ƒ  ó6   "  € \         \        \        \        .# 5ir   )rÍ   r2  rR  rt  )Úselfs   &r   Úget_node_listÚ$LTXVKeyframesExtension.get_node_list  s   é € ô &Ü*Ü*Üð	
ð 	
ùs   ‚r°   N)r)  r*  r+  r,  r   r„  r.  r/  r0  s   @r   r}  r}    s   ø‡ € Ø÷
ó ö
r   r}  c                ó$   € V ^8„  d   QhR\         /# r~   ©r}  )rZ   s   "r   r[   r[     s   € ÷ $ñ $Ô 6ñ $r   c               ƒ   ó   "  € \        4       # 5ir   r‡  r°   r   r   Úcomfy_entrypointr‰    s   é € Ü!Ó#Ð#ùs   ‚g§èH.ÿï?r   ))rn  r   rG   r^   Ú)comfy.ldm.lightricks.symmetric_patchifierr   r   Úcomfy_api.latestr   r   Úcomfy_extras.nodes_ltr   r   r	   r
   r   Útyping_extensionsr   rF  r¤   r   r;   rT   rd   rm   rs   r|   r†   r‘   r©   r®   rµ   r¾   rË   r€  rÍ   r2  rR  rt  r}  r‰  r°   r   r   Ú<module>rŽ     sÚ   ðÛ Û 	ã Û ß aß /÷õ õ 'àÐ ØÐ òIò'òT"õ4õõ*õ õ"&õ*÷ &õRSòõ$ò* ôFv6 §¡ô v6ôr	_I R§\¡\ô _IôDJ' R§\¡\ô J'ôZ4"�r—|‘|ô 4"ôn
˜^ô 
÷$r   