
    +j                         d dl mZmZ d dlZd dlZ G d dej                  Z G d de          Z G d de          Z	d	 Z
dS )
    )ComfyExtensionioNc                       e Zd Zedej        fd            Zeg ddfdej        j        de	de	de
d	e	d
ede
de	dedee	         dededej        fd            ZdS )ContextWindowsManualNodereturnc                    t          j        ddddt           j                            dd          t           j                            dd	d
dd          t           j                            ddddd          t           j                            dt          j        j        j	        t          j        j        j
        t          j        j        j        t          j        j        j        gd          t           j                            dd	d	dd          t           j                            ddd          t           j                            dt          j        j        j        t          j        j        j        d          t           j                            ddddd !          t           j                            d"dd#          t           j                            d$d%d&          t           j                            d'dd(          t           j                            d)dd*          gt           j                            d+          gd,          S )-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_schemaz&ContextWindowsManualNode.define_schema   s<   y*3"7w0hii-1bJmx|}}.AqJny}~~1):J):K):I):B	<
  C  D D -1a  JS  ^b  c  c
    HX   Y  Y}e6K6^6jty  uJ  u]  ue  o_  `  `Uq!Euvv
  e  FM   N  N	 8"  Op  q  q
  !95  S@   A  A
  !4d  MR   S  S#( (abb !7
 
 
 	
    FTr
   r   r   r   r   r   r"   r%   r(   r*   r,   r-   c                    |                                 }t          j                            t          j                            |          t          j                            |          ||||||	|
||          |j        d<   t          j                            |           |	rt          j                            |           t          j
        |          S )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)rG   r
   r   r   r   r   r   r"   r%   r(   r*   r,   r-   s                rH   executez ContextWindowsManualNode.execute'   s     161F1^1^"2PPQabb-FF{SS)+)##9#9/ 2_ 2
 2
-. 	==eDDD 	G!??FFF}U###rJ   N)__name__
__module____qualname__classmethodr   r5   rI   r6   TypeintstrboollistrU    rJ   rH   r   r      s        
bi 
 
 
 [
> 24SXrv$ $BHM $3 $QT $hk $  ~A $  PT $  cf $  mp $  }A $(,S	$NR$mq${}  |D$ $ $ [$ $ $rJ   r   c                        e Zd Zedej        f fd            Zeg dfdej        j        de	de	de
de	d	ed
e
dedee	         dedej        f fd            Z xZS )WanContextWindowsManualNoder   c                    t                                                      }d|_        d|_        d|_        t
          j                            dd          t
          j                            ddt          j
        d	d
dd          t
          j                            ddddd          t
          j                            dt          j        j        j        t          j        j        j        t          j        j        j        t          j        j        j        gd          t
          j                            ddddd          t
          j                            ddd          t
          j                            dt          j        j        j        t          j        j        j        d          t
          j                            ddd           g|_        |S )!NWanContextWindowsManualzWAN Context Windows (Manual)z9Manually set context windows for WAN-like models (dim=2).r
   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)   )superrI   r.   r/   r1   r   r6   r7   r8   nodesMAX_RESOLUTIONr9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   r2   )rG   schema	__class__s     rH   rI   z)WanContextWindowsManualNode.define_schema?   s   &&((2<XHNN7,dNee-1%:NUV`b  mP  [_  `  `.ArKoz~1):J):K):I):B	<
  C  D D -1a  JS  ^b  c  c
    HX   Y  Y}e6K6^6jty  uJ  u]  ue  o_  `  `
  e  FM   N  N
" rJ   Fr
   r   r   r   r   r   r"   r(   r*   r,   c                     t          |dz
  dz  dz   d          }t          |dz
  dz  dz   d          }t                                          |||||||d||	|
          S )Nr   r   r      )r%   r(   r*   r,   )r'   rg   rU   )rG   r
   r   r   r   r   r   r"   r(   r*   r,   rk   s              rH   rU   z#WanContextWindowsManualNode.executeX   s     ~1a71<a@@! 39Q>BBwwunoGWYgit  wB  HI  U^  wM  f|  }  }  	}rJ   )rV   rW   rX   rY   r   r5   rI   r6   rZ   r[   r\   r]   r^   rU   __classcell__)rk   s   @rH   ra   ra   >   s       bi      [0 24SX} }BHM }3 }QT }hk }  ~A }  PT }  cf }  sw }(,S	}NR}]_]e} } } } } [} } } } }rJ   ra   c                   <    e Zd Zdeeej                          fdZdS )ContextWindowsExtensionr   c                 "   K   t           t          gS N)r   ra   )selfs    rH   get_node_listz%ContextWindowsExtension.get_node_lista   s      $'
 	
rJ   N)rV   rW   rX   r^   typer   	ComfyNodert   r_   rJ   rH   rp   rp   `   s;        
T$r|*<%= 
 
 
 
 
 
rJ   rp   c                      t                      S rr   )rp   r_   rJ   rH   comfy_entrypointrx   g   s    "$$$rJ   )comfy_api.latestr   r   comfy.context_windowsr:   rh   rv   r   ra   rp   rx   r_   rJ   rH   <module>r{      s    / / / / / / / /     6$ 6$ 6$ 6$ 6$r| 6$ 6$ 6$p} } } } }": } } }D
 
 
 
 
n 
 
 
% % % % %rJ   