CoolFace
Apppublic

fred-dev/comfy_ui_ali

sourceHugging Facemitupdated 1y agoView on Hugging Face
0likes
sample.cpython-312.pyc18 linesDownload Raw Back to __pycache__
1�

2���g���^�ddlZddlZddlZddlZddlZddlZdd�Zd�Z	d�Z3d�Zd	d�Zd4d�Z
y)�Nc�0�tj|�}|�<tj|j�|j|j5|d��St
j|d��\}}g}t|ddz�D]d}tjdgt|j��ddz|j|j6|d��}||vs�T|j|��f|D�cgc]}||��	}}tj|d�	�}|Scc}w)7z�8    creates random noise given a latent image and a seed.9    optional arg skip can be used to skip and discard x number of noise generations for a given seed10    N�cpu)�dtype�layout�	generator�deviceT)�return_inverse������r)�axis)�torch�manual_seed�randn�sizerr�np�unique�range�list�append�cat)	�latent_image�seed�11noise_indsr�unique_inds�inverse�noises�i�noises	         �W/Users/fredrodrigues/Library/CloudStorage/Dropbox/Code/comfyui_hardware/comfy/sample.py�
prepare_noiser s��12�!�!�$�'�I����{�{�<�,�,�.�l�6H�6H�Q]�Qd�Qd�py�CH�I�	I��9�9�Z��E��K��
�F�
�;�r�?�1�$�
%�����Q�C�$�|�'8�'8�':�";�A�B�"?�?�|�GY�GY�bn�bu�bu�BK�TY�Z������M�M�%� �&�")�
)��A�f�Q�i��F�
)�
�Y�Y�v�A�
&�F��M��*s�,Dc�F�|jd�}|j|jdk7rDtj|�dk(r,t13jj||jd��}|jdk(r |jdk(r|jd�}|S)N�
latent_formatrr)�dim���)�get_model_object�latent_channels�shaper
�
count_nonzero�comfy�utils�repeat_to_batch_size�latent_dimensions�ndim�	unsqueeze)�modelrr"s   r�fix_empty_latent_channelsr2s����*�*�?�;�M��$�$��(:�(:�1�(=�=�%�BU�BU�Vb�Bc�gh�Bh��{�{�7�7��m�Fc�Fc�ij�7�k���&�&�!�+��0A�0A�Q�0F�#�-�-�a�0����c�:�tjd�||||gfS)NzLWarning: comfy.sample.prepare_sampling isn't used anymore and can be removed��logging�warning)r1�noise_shape�positive�negative�14noise_masks     r�prepare_samplingr<#s ���O�O�b�c��(�H�j�"�4�4r3c�.�tjd�y)NzUWarning: comfy.sample.cleanup_additional_models isn't used anymore and can be removedr5)�modelss r�cleanup_additional_modelsr?'s���O�O�k�lr3c��tjj|||j|||	|j��}|j||||||||
|||||��
}|j
tjj��}|S)N)�stepsr�sampler�	scheduler�denoise�
model_options)15�cfgr�16start_step�	last_step�force_full_denoise�denoise_mask�sigmas�callback�disable_pbarr)	r+�samplers�KSampler�load_devicerE�sample�to�model_management�intermediate_device)r1rrArF�sampler_namerCr9r:rrD�
disable_noiserGrHrIr;rKrLrMrrB�sampless                     rrQrQ*s����n�n�%�%�e�5��AR�AR�\h�t}�HO�_d�_r�_r�%�s�G��n�n�U�H�h�C�l�gq�~G�\n�}G�PV�ai�xD�KO�n�P�G��j�j��/�/�C�C�E�F�G��Nr3c���tjj||||||j|||j|||	|17|��}|jtjj��}|S)N)rErrJrLrMr)r+rNrQrPrErRrSrT)
r1rrFrBrKr9r:rr;rLrMrrWs
             r�
sample_customrY1s����n�n�#�#�E�5�(�H�c�5�K\�K\�^e�gm�~C�~Q�~Q�`l�{E�PX�gs�z~�#��G��j�j��/�/�C�C�E�F�G��Nr3)N)18g�?FNNFNNNFN)NNFN)r
�comfy.model_managementr+�comfy.samplers�comfy.utils�numpyrr6r r2r<r?rQrY�r3r�<module>r_s6���������&�5�m��r3