INNER CODE UNIT · Python

patch

Extraltodeus/ComfyUI-AutomaticCFG · experimental_temperature.py:104

    def patch(self, model, Temperature, Attention, **kwargs):
        m = model.clone()
        levels = ["input","middle","output"]
        parameters_output = {level:[] for level in levels}
        for key, toggle_enabled in kwargs.items():
            current_level = key.split("_")[0]
            if current_level in levels and toggle_enabled:
                b_number = int(key.split("_")[1])
                parameters_output[current_level].append(b_number)
                patcher = temperature_patcher(Temperature,key)

                if Attention in ["both","self"]:
                    m.set_model_attn1_replace(patcher.attention_basic_with_temperature, current_level, b_number)
                if Attention in ["both","cross"]:
                    m.set_model_attn2_replace(patcher.attention_basic_with_temperature, current_level, b_number)

        parameters_as_string = "\n".join(f"{k}: {','.join(map(str, v))}" for k, v in parameters_output.items())
        parameters_as_string = f"Temperature: {Temperature}\n{parameters_as_string}\nAttention: {Attention}"

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…