From 37ae77b486f50c49ddd40bade1dff36b2769495c Mon Sep 17 00:00:00 2001 From: Jedrzej Kosinski Date: Sat, 30 Mar 2024 05:29:22 -0500 Subject: [PATCH] Applied proper strength control to attn1_replace_patch as well --- adv_control/control_reference.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/adv_control/control_reference.py b/adv_control/control_reference.py index bc5d9fc..cadba8f 100644 --- a/adv_control/control_reference.py +++ b/adv_control/control_reference.py @@ -442,6 +442,10 @@ def _forward_inject_BasicTransformerBlock(self: RefBasicTransformerBlock, x: Ten bank_styles = self.injection_holder.bank_styles style_fidelity = bank_styles.get_avg_style_fidelity() real_bank = bank_styles.bank.copy() + for idx, order in enumerate(bank_styles.cn_idx): + if ref_controlnets[idx].should_apply_effective_strength: + effective_strength = ref_controlnets[idx].get_effective_strength() + real_bank[idx] = real_bank[idx] * effective_strength + context_attn1 * (1-effective_strength) n_uc = self.attn1.to_out(attn1_replace_patch[block_attn1]( n, self.attn1.to_k(torch.cat([context_attn1] + real_bank, dim=1)),