
    3j                         S SK JrJr  S SKrS SKr " S S\R                  5      r " S S\5      r " S S\5      r	S	 r
g)
    )ComfyExtensionioNc                       \ rS rSr\S\R                  4S j5       r\/ SS4S\R                  R                  S\
S\
S	\S
\
S\S\S\
S\S\\
   S\S\S\R                  4S jj5       rSrg)ContextWindowsManualNode   returnc                    [         R                  " SSSS[         R                  R                  SSS9[         R                  R                  SS	S
SSS9[         R                  R                  SSSSSS9[         R
                  R                  S[        R                  R                  R                  [        R                  R                  R                  [        R                  R                  R                  [        R                  R                  R                  /SS9[         R                  R                  SS	S	SSS9[         R                  R                  SSSS9[         R
                  R                  S[        R                  R                  R                  [        R                  R                  R                   SS9[         R                  R                  SSSSS S!9[         R                  R                  S"SS#S9[         R"                  R                  S$S%S&S9[         R                  R                  S'SS(S9[         R                  R                  S)SS*S9/[         R                  R%                  S+S9/SS,9$ )-NContextWindowsManualzContext Windows (Manual)zmodel/patchzManually set context windows.model6The model to apply context windows to during sampling.tooltipcontext_length      !The length of the context window.Tmindefaultr   advancedcontext_overlapr      "The overlap of the context window.context_schedule!The stride of the context window.optionsr   context_strideGThe stride of the context window; only applicable to uniform schedules.closed_loopFNWhether to close the context window loop; only applicable to looped schedules.r   r   fuse_method.The method to use to fuse the context windows.r   r   r   dim   z.The dimension to apply the context windows to.)r   maxr   r   	freenoiseEWhether to apply FreeNoise noise shuffling, improves window blending.cond_retain_index_list zList of latent indices to retain in the conditioning tensors for each window, for example setting this to '0' will use the initial start image for each window.split_conds_to_windowszkWhether to split multiple conditionings (created by ConditionCombine) to each window based on region index.causal_window_fixzCWhether to add a causal fix frame to non-0-indexed context windows.z7The model with context windows applied during sampling.)node_iddisplay_namecategorydescriptioninputsoutputsis_experimental)r   SchemaModelInputIntCombocomfycontext_windowsContextSchedulesSTATIC_STANDARDUNIFORM_STANDARDUNIFORM_LOOPEDBATCHEDBooleanContextFuseMethodsLIST_STATICPYRAMIDStringOutput)clss    B/home/wildlama/comfy/ComfyUI/comfy_extras/nodes_context_windows.pydefine_schema&ContextWindowsManualNode.define_schema   sQ   yy*3"7w0hi-1bJmx|}.AqJny}~1))::JJ))::KK))::II))::BB	<
  C  D -1a  JS  ^b  c

    HX   Y}e6K6K6^6^6j6jty  uJ  uJ  u]  u]  ue  ue  o_  `Uq!Euv

  e  FM   N		 8"  Op  q

  !95  S@   A

  !4d  MR   S#( (ab !7
 	
    FTr   r   r   r   r   r    r#   r&   r)   r+   r-   r.   c                    UR                  5       n[        R                  R                  [        R                  R	                  U5      [        R                  R                  U5      UUUUUU	U
UUS9UR                  S'   [        R                  R                  U5        U	(       a  [        R                  R                  U5        [        R                  " U5      $ )N)r   r#   r   r   r   r    r&   r)   r+   r-   r.   context_handler)cloner;   r<   IndexListContextHandlerget_matching_context_scheduleget_matching_fuse_methodmodel_optionscreate_prepare_sampling_wrappercreate_sampler_sample_wrapperr   
NodeOutput)rH   r   r   r   r   r   r    r#   r&   r)   r+   r-   r.   s                rI   execute ContextWindowsManualNode.execute'   s     161F1F1^1^"22PPQab--FF{S)+)##9#9/ 2_ 2
-. 	==eD!!??F}}U##rL    N)__name__
__module____qualname____firstlineno__classmethodr   r6   rJ   r7   TypeintstrboollistrW   __static_attributes__rY   rL   rI   r   r      s    
bii 
 
> 24SXrv$BHHMM $3 $QT $hk $  ~A $  PT $  cf $  mp $  }A $(,S	$NR$mq${}  |D  |D$ $rL   r   c                      ^  \ rS rSr\S\R                  4U 4S jj5       r\/ S4S\R                  R                  S\
S\
S\S	\
S
\S\S\S\\
   S\S\R                  4U 4S jjj5       rSrU =r$ )WanContextWindowsManualNode>   r   c                   > [         TU ]  5       nSUl        SUl        SUl        SUl        [        R                  R                  SSS9[        R                  R                  SS	[        R                  S
SSSS9[        R                  R                  SSSSSS9[        R                  R                  S[        R                  R                  R                   [        R                  R                  R"                  [        R                  R                  R$                  [        R                  R                  R&                  /SS9[        R                  R                  SS	S	SSS9[        R(                  R                  SSSS9[        R                  R                  S[        R                  R*                  R,                  [        R                  R*                  R.                  SS9[        R(                  R                  S SS!S9/Ul        U$ )"NWanContextWindowsManualzWAN Context Windows (Manual)z9Manually set context windows for WAN-like models (dim=2).zmodel/patch/wanr   r   r   r   r   r   Q   r   T)r   r(   stepr   r   r   r   r      r   r   r   r   r   r   r   r    Fr!   r"   r#   r$   r%   r)   r*   )superrJ   r/   r0   r2   r1   r   r7   r8   r9   nodesMAX_RESOLUTIONr:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   r3   )rH   schema	__class__s     rI   rJ   )WanContextWindowsManualNode.define_schema?   s   &(2<X)HHNN7,dNe-1%:N:NUV`b  mP  [_  `.ArKoz~1))::JJ))::KK))::II))::BB	<
  C  D -1a  JS  ^b  c

    HX   Y}e6K6K6^6^6j6jty  uJ  uJ  u]  u]  ue  ue  o_  `

  e  FM   N
" rL   Fr   r   r   r   r   r    r#   r)   r+   r-   c                 ~   > [        US-
  S-  S-   S5      n[        US-
  S-  S-   S5      n[        TU ]	  XX4XVUSXU
S9$ )Nr   r   r      )r&   r)   r+   r-   )r(   rm   rW   )rH   r   r   r   r   r   r    r#   r)   r+   r-   rq   s              rI   rW   #WanContextWindowsManualNode.executeY   ss     ~1a71<a@! 39Q>BwuoYg  wB  HI  U^  f|  }  	}rL   rY   )rZ   r[   r\   r]   r^   r   r6   rJ   r7   r_   r`   ra   rb   rc   rW   rd   __classcell__)rq   s   @rI   rf   rf   >   s    bii  2 24SX}BHHMM }3 }QT }hk }  ~A }  PT }  cf }  sw }(,S	}NR}]_]e]e} }rL   rf   c                   B    \ rS rSrS\\\R                        4S jrSr	g)ContextWindowsExtensiona   r   c                 "   #    [         [        /$ 7fN)r   rf   )selfs    rI   get_node_list%ContextWindowsExtension.get_node_listb   s     $'
 	
s   rY   N)
rZ   r[   r\   r]   rc   typer   	ComfyNoder}   rd   rY   rL   rI   rx   rx   a   s    
T$r||*<%= 
rL   rx   c                      [        5       $ r{   )rx   rY   rL   rI   comfy_entrypointr   h   s    "$$rL   )comfy_api.latestr   r   comfy.context_windowsr;   rn   r   r   rf   rx   r   rY   rL   rI   <module>r      s@    /  6$r|| 6$p }":  }F
n 
%rL   