o
    i                     @   sN   d dl Z d dlZd dlZG dd dZG dd deZeedZdddZdS )	    Nc                   @   sD   e Zd ZdZdd Zedd ZdZdZdZ	d	Z
d
ZdZdd ZdS )LoraLoaderBypassz
    Apply LoRA in bypass mode without modifying base model weights.

    Bypass mode computes: output = base_forward(x) + lora_path(x)
    This is useful for training and when model weights are offloaded.
    c                 C   s
   d | _ d S )N)loaded_lora)self r   ;/mnt/c/Users/fbmor/ComfyUI/comfy_extras/nodes_lora_debug.py__init__   s   
zLoraLoaderBypass.__init__c                 C   sR   ddddifdddift dddifd	d
dddddfd	d
dddddfdiS )NrequiredMODELtooltipz0The diffusion model the LoRA will be applied to.CLIPz+The CLIP model the LoRA will be applied to.loraszThe name of the LoRA.FLOAT      ?      Y      Y@{Gz?zGHow strongly to modify the diffusion model. This value can be negative.)defaultminmaxstepr
   zBHow strongly to modify the CLIP model. This value can be negative.)modelclip	lora_namestrength_modelstrength_clipfolder_pathsget_filename_listsr   r   r   INPUT_TYPES   s   

zLoraLoaderBypass.INPUT_TYPES)r	   r   )zThe modified diffusion model.zThe modified CLIP model.	load_loraloaderszApply LoRA in bypass mode. Unlike regular LoRA, this doesn't modify model weights - instead it injects the LoRA computation during forward pass. Useful for training scenarios.Tc           
      C   s   |dkr|dkr||fS t d|}d }| jd ur)| jd |kr&| jd }nd | _|d u r:tjj|dd}||f| _tj|||||\}}	||	fS )Nr   r      T)	safe_load)r   get_full_path_or_raiser   comfyutilsload_torch_filesdload_bypass_lora_for_models)
r   r   r   r   r   r   	lora_pathlora
model_lora	clip_lorar   r   r   r!   %   s   

zLoraLoaderBypass.load_loraN)__name__
__module____qualname____doc__r   classmethodr    RETURN_TYPESOUTPUT_TOOLTIPSFUNCTIONCATEGORYDESCRIPTIONEXPERIMENTALr!   r   r   r   r   r      s    
r   c                   @   s(   e Zd Zedd ZdZdZdd ZdS )LoraLoaderBypassModelOnlyc              	   C   s&   ddt dfdddddd	fd
iS )Nr   r	   r   r   r   r   r   r   )r   r   r   r   )r   r   r   r   r   r   r   r   r    :   s   
z%LoraLoaderBypassModelOnly.INPUT_TYPESr;   load_lora_model_onlyc                 C   s   |  |d ||dd fS )Nr   )r!   )r   r   r   r   r   r   r   r<   C   s   z.LoraLoaderBypassModelOnly.load_lora_model_onlyN)r/   r0   r1   r3   r    r4   r6   r<   r   r   r   r   r:   9   s    
r:   )r   r:   z"Load LoRA (Bypass) (For debugging)z.Load LoRA (Bypass, Model Only) (for debugging))r   comfy.utilsr&   comfy.sdr   r:   NODE_CLASS_MAPPINGSNODE_DISPLAY_NAME_MAPPINGSr   r   r   r   <module>   s    3
