
    +j
                         d Z ddlZddlmZ ddlZddlZddlmZm	Z	  G d de	j
                  Z G d de          Zd	efd
ZdS )z"PiD (Pixel Diffusion Decoder) node    N)override)ComfyExtensionioc                   b    e Zd Zedej        fd            Zedededej	        fd            Z
dS )PiDConditioningreturnc                 |   t          j        ddddt           j                            d          t           j                            dd          t           j                            d	g d
dd          t           j                            dddddd          gt           j                                        g          S )Nr   zPiD Conditioningzadvanced/conditioningzYAttaches a latent and a degrade_sigma scalar to a CONDITIONING for PiD decoding/upscalingpositivelatentz&latent (from VAEEncode or a KSampler).)tooltiplatent_format)fluxsd3sdxl	qwenimager   zFlux1 (16-ch) and Flux2 (128-ch) latents are auto-detected from channel dim under 'flux'. For SD3 (16-ch), SDXL (4-ch), or QwenImage (16-ch), select manually.)optionsdefaultr   degrade_sigmag        g      ?g{Gz?z?0 = clean latent. Increase to denoise corrupted latent outputs.)r   minmaxstepr   )node_iddisplay_namecategorydescriptioninputsoutputs)r   SchemaConditioningInputLatentComboFloatOutput)clss    6/home/wildlama/comfy/ComfyUI/comfy_extras/nodes_pid.pydefine_schemazPiDConditioning.define_schema   s    y%+,k %%j11	2Z[[8\8\8\fl (H  I I#Scs]   	 _++--.#
 
 
 	
    r   r   c                 X   |d         }|dk    r4|j         d         dk    rt          j        j        nt          j        j        }nZ|dk    rt          j        j        }nB|dk    rt          j        j        }n*|dk    rt          j        j        }nt          d|            |            	                    |          }|j
        d	k    r|d d d d d
f         }t          j        t          |          gt          j                  }t          j        t#          j        |||d                    S )Nsamplesr         r   r   r   zUnknown latent_format:    r   )dtype)	lq_latentr   )shapecomfylatent_formatsFlux2FluxSD3SDXLWan21
ValueError
process_inndimtorchtensorfloatfloat32r   
NodeOutputnode_helpersconditioning_set_values)	r%   r
   r   r   r   r*   fmt_clsr/   sigma_ts	            r&   executezPiDConditioning.execute"   s/   #F""4;M!4D4K4Ke*00QVQeQjGGe##*.GGf$$*/GGk))*0GGF}FFGGGGII((11	>Q!!!!QQQ'*I,m 4 45U]KKK}\AIHH
 
   	r(   N)__name__
__module____qualname__classmethodr   r   r'   strr=   r?   rD    r(   r&   r   r      st        
bi 
 
 
 [
* c % TVTa    [  r(   r   c                   L    e Zd Zedeeej                          fd            ZdS )PiDExtensionr   c                    K   t           gS N)r   )selfs    r&   get_node_listzPiDExtension.get_node_list9   s        r(   N)	rE   rF   rG   r   listtyper   	ComfyNoderP   rJ   r(   r&   rL   rL   8   sE        !T$r|*<%= ! ! ! X! ! !r(   rL   r   c                  "   K   t                      S rN   )rL   rJ   r(   r&   comfy_entrypointrU   >   s      >>r(   )__doc__r;   typing_extensionsr   r@   comfy.latent_formatsr1   comfy_api.latestr   r   rS   r   rL   rU   rJ   r(   r&   <module>rZ      s    ( (  & & & & & &         / / / / / / / /* * * * *bl * * *Z! ! ! ! !> ! ! !      r(   