Update snake_oil.py
This commit is contained in:
+13
-13
@@ -5,7 +5,7 @@ import comfy.utils
|
||||
from comfy.sd import load_lora_for_models
|
||||
from safetensors.torch import load_file
|
||||
|
||||
class SnakeOil:
|
||||
class NegativeLoRALoader:
|
||||
def __init__(self):
|
||||
self.loaded_lora = None
|
||||
|
||||
@@ -28,22 +28,22 @@ class SnakeOil:
|
||||
"required": {
|
||||
"model": ("MODEL",),
|
||||
"nlora": (file_list, {"label": "nLoRA Model", "description": "Select the nLoRA model to apply"}),
|
||||
"snake_oil_amount": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 2.0, "step": 0.01, "display": "slider", "label": "Snake Oil Amount", "description": "Adjust the amount of Snake Oil to apply (0.0 to 2.0)"}),
|
||||
"inverted_strength_value": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 2.0, "step": 0.01, "display": "slider", "label": "Snake Oil Amount", "description": "Adjust the amount of Snake Oil to apply (0.0 to 2.0)"}),
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("MODEL",)
|
||||
FUNCTION = "apply_snake_oil"
|
||||
FUNCTION = "apply_inverted_LoRA"
|
||||
CATEGORY = "🐍🛢️ Snake Oil"
|
||||
|
||||
def apply_snake_oil(self, model, nlora, snake_oil_amount):
|
||||
if snake_oil_amount == 0:
|
||||
print("snake_oil_amount is 0, returning the original model.")
|
||||
def apply_snake_oil(self, model, nlora, inverted_strength_value):
|
||||
if inverted_strength_value == 0:
|
||||
print("inverted_strength_value is 0, returning the original model.")
|
||||
return (model,)
|
||||
|
||||
# Invert the snake_oil_amount value to its negative equivalent haha yes really
|
||||
snake_oil_amount = -snake_oil_amount
|
||||
print(f"Inverted snake_oil_amount: {snake_oil_amount}")
|
||||
# Invert the inverted_strength_value value to its negative equivalent haha yes really
|
||||
inverted_strength_value = -inverted_strength_value
|
||||
print(f"Inverted inverted_strength_value: {inverted_strength_value}")
|
||||
|
||||
# Define the directory where nLoRA models are stored using a relative path again maybe
|
||||
lora_directory = os.path.join(os.path.dirname(__file__), "..", "..", "models", "nloras")
|
||||
@@ -70,8 +70,8 @@ class SnakeOil:
|
||||
return (model,)
|
||||
|
||||
try:
|
||||
model_lora, _ = load_lora_for_models(model, None, lora, snake_oil_amount, 0)
|
||||
print(f"Successfully applied LoRA model with snake_oil_amount: {snake_oil_amount}")
|
||||
model_lora, _ = load_lora_for_models(model, None, lora, inverted_strength_value, 0)
|
||||
print(f"Successfully applied LoRA model with inverted_strength_value: {inverted_strength_value}")
|
||||
except Exception as e:
|
||||
print(f"Error applying LoRA model: {e}")
|
||||
return (model,)
|
||||
@@ -80,10 +80,10 @@ class SnakeOil:
|
||||
|
||||
# A dictionary that contains all nodes you want to export with their names
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
"SnakeOil": SnakeOil
|
||||
"NegativeLoRALoader": NegativeLoRALoader
|
||||
}
|
||||
|
||||
# A dictionary that contains the friendly/humanly readable titles for the nodes
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"SnakeOil": "🐍🛢️ SnakeOil"
|
||||
"NegativeLoRALoader": "Negative LoRA Loader"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user