
    3j                        S r SSKrSSKJr  SSKrSSKrSSKJrJ	r	   " S S\	R                  5      r " S S\	R                  5      r " S	 S
\	R                  5      r " S S\	R                  5      r " S S\5      rS\4S jrg)a  
This file is part of ComfyUI.
Copyright (C) 2024 Stability AI

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.
    N)override)ComfyExtensionioc                   8    \ rS rSr\S 5       r\SS j5       rSrg)StableCascade_EmptyLatentImage   c                    [         R                  " SS[         R                  R                  SSS[        R
                  SS9[         R                  R                  SSS[        R
                  SS9[         R                  R                  S	S
SSSSS9[         R                  R                  SSSSS9/[         R                  R                  SS9[         R                  R                  SS9/S9$ )Nr   model/latent/stable cascadewidthi         )defaultminmaxstepheightcompression*            Tr   r   r   r   advanced
batch_sizei   )r   r   r   stage_cdisplay_namestage_bnode_idcategoryinputsoutputs)r   SchemaIntInputnodesMAX_RESOLUTIONLatentOutputclss    A/home/wildlama/comfy/ComfyUI/comfy_extras/nodes_stable_cascade.pydefine_schema,StableCascade_EmptyLatentImage.define_schema   s    yy42WdAUAU\]^Xt%BVBV]^_]BA3QY]^\1!F	 		  i 8		  i 8
 	
    c                     [         R                  " USX#-  X-  /5      n[         R                  " USUS-  US-  /5      n[        R                  " SU0SU05      $ )N   r   samples)torchzerosr   
NodeOutput)r,   r   r   r   r   c_latentb_latents          r-   execute&StableCascade_EmptyLatentImage.execute-   se    ;;
B0EuG[\];;
Av{EQJGH}}x
 x
 	r0    N)r   __name__
__module____qualname____firstlineno__classmethodr.   r9   __static_attributes__r;   r0   r-   r   r      s(    
 
   r0   r   c                   4    \ rS rSr\S 5       r\S 5       rSrg)StableCascade_StageC_VAEEncode8   c                 Z   [         R                  " SS[         R                  R                  S5      [         R                  R                  S5      [         R
                  R                  SSSSS	S
S9/[         R                  R                  SS9[         R                  R                  SS9/S9$ )NrD   r
   imagevaer   r   r   r   r   Tr   r   r   r   r   )r   r$   Imager&   Vaer%   r)   r*   r+   s    r-   r.   ,StableCascade_StageC_VAEEncode.define_schema9   s    yy42w'U#]BA3QY]^ 		  i 8		  i 8
 	
r0   c                    UR                   S   nUR                   S   nXC-  UR                  -  nXS-  UR                  -  n[        R                  R	                  UR                  SS5      XgSS5      R                  SS5      nUR                  US S 2S S 2S S 2S S24   5      n	[        R                  " U	R                   S   S	US
-  S-  US
-  S-  /5      n
[        R                  " SU	0SU
05      $ )Nr   bicubiccenter   r   r   r      r3   )shapedownscale_ratiocomfyutilscommon_upscalemovedimencoder4   r5   r   r6   )r,   rG   rH   r   r   r   	out_width
out_heightsr7   r8   s              r-   r9   &StableCascade_StageC_VAEEncode.executeI   s    BR)S-@-@@	+s/B/BB
KK&&u}}R':IS\^fgoopqrtu::a!Abqbk*;;q 11v{a6G%ST*XYIYZ[}}x
 x
 	r0   r;   Nr<   r;   r0   r-   rD   rD   8   s(    
 
  r0   rD   c                   4    \ rS rSr\S 5       r\S 5       rSrg)!StableCascade_StageB_Conditioning[   c                     [         R                  " SS[         R                  R                  S5      [         R                  R                  S5      /[         R                  R                  5       /S9$ )Nr`   z!model/conditioning/stable cascadeconditioningr   r   )r   r$   Conditioningr&   r)   r*   r+   s    r-   r.   /StableCascade_StageB_Conditioning.define_schema\   sW    yy78%%n5			*
 &&(

 
	
r0   c                     / nU H6  nUS   R                  5       nUS   US'   US   U/nUR                  U5        M8     [        R                  " U5      $ )Nr   r3   stable_cascade_priorr   )copyappendr   r6   )r,   rc   r   ctdns          r-   r9   )StableCascade_StageB_Conditioning.executej   sY    A!		A(/	(:A$%1q	AHHQK	 
 }}Qr0   r;   Nr<   r;   r0   r-   r`   r`   [   s(    
 
    r0   r`   c                   4    \ rS rSr\S 5       r\S 5       rSrg)'StableCascade_SuperResolutionControlnetu   c                 R   [         R                  " SSS[         R                  R                  S5      [         R                  R                  S5      /[         R                  R                  SS9[         R                  R                  SS9[         R                  R                  S	S9/S
9$ )Nrp   zexperimental/stable_cascadeTrG   rH   controlnet_inputr   r   r   )r    r!   is_experimentalr"   r#   )r   r$   rI   r&   rJ   r*   r)   r+   s    r-   r.   5StableCascade_SuperResolutionControlnet.define_schemav   s    yy=2 w'U#
 -?@		  i 8		  i 8
 	
r0   c                 t   UR                   S   nUR                   S   nUR                   S   nUR                  US S 2S S 2S S 2S S24   5      R                  SS5      n[        R                  " USUS-  US-  /5      n[        R                  " USUS	-  US	-  /5      n[
        R                  " US
U0S
U05      $ )NrM   rN   r   rR   r   rO   r2   r   rS   r3   )rT   rZ   rY   r4   r5   r   r6   )	r,   rG   rH   r   r   r   rs   r7   r8   s	            r-   r9   /StableCascade_SuperResolutionControlnet.execute   s    BR[[^
::eAa"1"Ho6>>q"E;;
B"erkJK;;
Av{EQJGH}}-x0
 x
 	r0   r;   Nr<   r;   r0   r-   rp   rp   u   s(    
 
   r0   rp   c                   L    \ rS rSr\S\\\R                        4S j5       r	Sr
g)StableCascadeExtension   returnc                 6   #    [         [        [        [        /$ 7fN)r   r`   rD   rp   )selfs    r-   get_node_list$StableCascadeExtension.get_node_list   s      +-*3	
 	
s   r;   N)r=   r>   r?   r@   r   listtyper   	ComfyNoder   rB   r;   r0   r-   ry   ry      s)    
T$r||*<%= 
 
r0   ry   r{   c                     #    [        5       $ 7fr}   )ry   r;   r0   r-   comfy_entrypointr      s     !##s   )__doc__r4   typing_extensionsr   comfy.utilsrV   r'   comfy_api.latestr   r   r   r   rD   r`   rp   ry   r   r;   r0   r-   <module>r      sv   $  &   /R\\ : R\\  F   4bll D
^ 
$ 6 $r0   