close
Skip to content

Issue on docs - CLIPMergeSimple: ratio is described wrong #918

@morphinapg

Description

@morphinapg

Path: /built-in-nodes/ClipMergeSimple

It says:

Ratio Parameter Explained

ratio = 0.0: Fully uses clip1, ignores clip2
ratio = 0.5: 50% contribution from each model
ratio = 1.0: Fully uses clip2, ignores clip1

While this seems like it would make sense, the ModelMergeSimple node works the opposite way:

When this value is 1, the output model is 100% model1, and when this value is 0, the output model is 100% model2.

This inconsistency made me curious whether the documentation for one of these was incorrect, and it appears ClipMergeSimple is described wrong. The code for ModelMergeSimple and CLIPMergeSimple appear to both handle the ratio parameter the same way:

class ModelMergeSimple:
    @classmethod
    def INPUT_TYPES(s):
        return {"required": { "model1": ("MODEL",),
                              "model2": ("MODEL",),
                              "ratio": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}),
                              }}
    RETURN_TYPES = ("MODEL",)
    FUNCTION = "merge"

    CATEGORY = "advanced/model_merging"

    def merge(self, model1, model2, ratio):
        m = model1.clone()
        kp = model2.get_key_patches("diffusion_model.")
        for k in kp:
            m.add_patches({k: kp[k]}, 1.0 - ratio, ratio)
        return (m, )
class CLIPMergeSimple:
    @classmethod
    def INPUT_TYPES(s):
        return {"required": { "clip1": ("CLIP",),
                              "clip2": ("CLIP",),
                              "ratio": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}),
                              }}
    RETURN_TYPES = ("CLIP",)
    FUNCTION = "merge"

    CATEGORY = "advanced/model_merging"

    def merge(self, clip1, clip2, ratio):
        m = clip1.clone()
        kp = clip2.get_key_patches()
        for k in kp:
            if k.endswith(".position_ids") or k.endswith(".logit_scale"):
                continue
            m.add_patches({k: kp[k]}, 1.0 - ratio, ratio)
        return (m, )

Both of them appear to use ratio where 1.0 = the first model and 0.0 = the second model

Documentation should be updated to reflect this

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions