mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-01-11 02:15:17 +00:00
Add some nodes to subtract and add model weights.
This commit is contained in:
parent
0b829fe35b
commit
30de95e4b4
@ -27,6 +27,44 @@ class ModelMergeSimple:
|
|||||||
m.add_patches({k: kp[k]}, 1.0 - ratio, ratio)
|
m.add_patches({k: kp[k]}, 1.0 - ratio, ratio)
|
||||||
return (m, )
|
return (m, )
|
||||||
|
|
||||||
|
class ModelSubtract:
|
||||||
|
@classmethod
|
||||||
|
def INPUT_TYPES(s):
|
||||||
|
return {"required": { "model1": ("MODEL",),
|
||||||
|
"model2": ("MODEL",),
|
||||||
|
"multiplier": ("FLOAT", {"default": 1.0, "min": -10.0, "max": 10.0, "step": 0.01}),
|
||||||
|
}}
|
||||||
|
RETURN_TYPES = ("MODEL",)
|
||||||
|
FUNCTION = "merge"
|
||||||
|
|
||||||
|
CATEGORY = "_for_testing/model_merging"
|
||||||
|
|
||||||
|
def merge(self, model1, model2, multiplier):
|
||||||
|
m = model1.clone()
|
||||||
|
kp = model2.get_key_patches("diffusion_model.")
|
||||||
|
for k in kp:
|
||||||
|
m.add_patches({k: kp[k]}, - multiplier, multiplier)
|
||||||
|
return (m, )
|
||||||
|
|
||||||
|
class ModelAdd:
|
||||||
|
@classmethod
|
||||||
|
def INPUT_TYPES(s):
|
||||||
|
return {"required": { "model1": ("MODEL",),
|
||||||
|
"model2": ("MODEL",),
|
||||||
|
}}
|
||||||
|
RETURN_TYPES = ("MODEL",)
|
||||||
|
FUNCTION = "merge"
|
||||||
|
|
||||||
|
CATEGORY = "_for_testing/model_merging"
|
||||||
|
|
||||||
|
def merge(self, model1, model2):
|
||||||
|
m = model1.clone()
|
||||||
|
kp = model2.get_key_patches("diffusion_model.")
|
||||||
|
for k in kp:
|
||||||
|
m.add_patches({k: kp[k]}, 1.0, 1.0)
|
||||||
|
return (m, )
|
||||||
|
|
||||||
|
|
||||||
class CLIPMergeSimple:
|
class CLIPMergeSimple:
|
||||||
@classmethod
|
@classmethod
|
||||||
def INPUT_TYPES(s):
|
def INPUT_TYPES(s):
|
||||||
@ -144,6 +182,8 @@ class CheckpointSave:
|
|||||||
NODE_CLASS_MAPPINGS = {
|
NODE_CLASS_MAPPINGS = {
|
||||||
"ModelMergeSimple": ModelMergeSimple,
|
"ModelMergeSimple": ModelMergeSimple,
|
||||||
"ModelMergeBlocks": ModelMergeBlocks,
|
"ModelMergeBlocks": ModelMergeBlocks,
|
||||||
|
"ModelMergeSubtract": ModelSubtract,
|
||||||
|
"ModelMergeAdd": ModelAdd,
|
||||||
"CheckpointSave": CheckpointSave,
|
"CheckpointSave": CheckpointSave,
|
||||||
"CLIPMergeSimple": CLIPMergeSimple,
|
"CLIPMergeSimple": CLIPMergeSimple,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user