Files
aodh-pack/nodes/lora_from_string/lora_from_string.py
Aodhan Collins 2417dcc090 Initial commit
2025-12-29 20:50:25 +00:00

36 lines
1.2 KiB
Python

import folder_paths
import comfy.utils
import comfy.sd
class LoraFromString:
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"model": ("MODEL",),
"clip": ("CLIP",),
"lora_name": ("STRING", {"multiline": False}),
"strength_model": ("FLOAT", {"default": 1.0, "min": -10.0, "max": 10.0, "step": 0.01}),
"strength_clip": ("FLOAT", {"default": 1.0, "min": -10.0, "max": 10.0, "step": 0.01}),
}
}
RETURN_TYPES = ("MODEL", "CLIP")
FUNCTION = "load_lora"
CATEGORY = "AODH Pack"
def load_lora(self, model, clip, lora_name, strength_model, strength_clip):
if strength_model == 0 and strength_clip == 0:
return (model, clip)
lora_path = folder_paths.get_full_path("loras", lora_name)
lora = None
if lora_path:
lora = comfy.utils.load_torch_file(lora_path, safe_load=True)
else:
print(f"Lora not found: {lora_name}")
return (model, clip)
model_lora, clip_lora = comfy.sd.load_lora_for_models(model, clip, lora, strength_model, strength_clip)
return (model_lora, clip_lora)