mirror of
https://github.com/justUmen/Bjornulf_custom_nodes.git
synced 2026-03-25 06:22:13 -03:00
0.65
This commit is contained in:
49
loader_lora_with_path.py
Normal file
49
loader_lora_with_path.py
Normal file
@@ -0,0 +1,49 @@
|
||||
import os
|
||||
import comfy.sd
|
||||
import comfy.utils
|
||||
|
||||
class LoaderLoraWithPath:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {
|
||||
"required": {
|
||||
"model": ("MODEL",),
|
||||
"clip": ("CLIP",),
|
||||
"lora_path": ("STRING", {"default": ""}),
|
||||
"strength_model": ("FLOAT", {"default": 1.0, "min": -100.0, "max": 100.0, "step": 0.01}),
|
||||
"strength_clip": ("FLOAT", {"default": 1.0, "min": -100.0, "max": 100.0, "step": 0.01}),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("MODEL", "CLIP")
|
||||
FUNCTION = "load_lora" # Added this line
|
||||
CATEGORY = "Bjornulf"
|
||||
|
||||
def load_lora(self, model, clip, lora_path, strength_model, strength_clip):
|
||||
try:
|
||||
# Check if path exists
|
||||
if not os.path.isfile(lora_path):
|
||||
print(f"Error: Lora file not found at path: {lora_path}")
|
||||
return (model, clip)
|
||||
|
||||
# Load the Lora file
|
||||
try:
|
||||
lora = comfy.utils.load_torch_file(lora_path)
|
||||
except Exception as e:
|
||||
print(f"Error loading Lora file: {str(e)}")
|
||||
return (model, clip)
|
||||
|
||||
# Apply the Lora
|
||||
model_lora, clip_lora = comfy.sd.load_lora_for_models(
|
||||
model,
|
||||
clip,
|
||||
lora,
|
||||
strength_model,
|
||||
strength_clip
|
||||
)
|
||||
|
||||
return (model_lora, clip_lora)
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error in load_lora: {str(e)}")
|
||||
return (model, clip)
|
||||
Reference in New Issue
Block a user