This commit is contained in:
lvmin
2023-08-10 17:32:51 -07:00
parent 23892b324f
commit 5e752790b9
2 changed files with 15 additions and 2 deletions
+11 -1
View File
@@ -10,7 +10,7 @@ import numpy as np
import comfy.model_management
import comfy.utils
from comfy.sd import load_checkpoint_guess_config
from comfy.sd import load_checkpoint_guess_config, load_lora_for_models
from nodes import VAEDecode, EmptyLatentImage, CLIPTextEncode
from comfy.sample import prepare_mask, broadcast_cond, load_additional_models, cleanup_additional_models
from modules.samplers_advanced import KSampler, KSamplerWithRefiner
@@ -39,6 +39,16 @@ def load_model(ckpt_filename):
return StableDiffusionModel(unet=unet, clip=clip, vae=vae, clip_vision=clip_vision)
@torch.no_grad()
def load_lora(model, lora_filename, strength_model=1.0, strength_clip=1.0):
if strength_model == 0 and strength_clip == 0:
return model
lora = comfy.utils.load_torch_file(lora_filename, safe_load=True)
model.unet, model.clip = comfy.sd.load_lora_for_models(model.unet, model.clip, lora, strength_model, strength_clip)
return model
@torch.no_grad()
def encode_prompt_condition(clip, prompt):
return opCLIPTextEncode.encode(clip=clip, text=prompt)[0]