diff --git a/stable-diffusion.cpp b/stable-diffusion.cpp index cea12e6f2..3284edbda 100644 --- a/stable-diffusion.cpp +++ b/stable-diffusion.cpp @@ -673,19 +673,20 @@ class StableDiffusionGGML { for (auto& kv : lora_state) { const std::string& lora_name = kv.first; float multiplier = kv.second; - - if (curr_lora_state.find(lora_name) != curr_lora_state.end()) { - float curr_multiplier = curr_lora_state[lora_name]; - float multiplier_diff = multiplier - curr_multiplier; - if (multiplier_diff != 0.f) { - lora_state_diff[lora_name] = multiplier_diff; - } - } else { - lora_state_diff[lora_name] = multiplier; - } + lora_state_diff[lora_name] += multiplier; + } + for (auto& kv : curr_lora_state) { + const std::string& lora_name = kv.first; + float curr_multiplier = kv.second; + lora_state_diff[lora_name] -= curr_multiplier; + } + + size_t rm = lora_state_diff.size() - lora_state.size(); + if (rm != 0) { + LOG_INFO("Attempting to apply %lu LoRAs (removing %lu applied LoRAs)", lora_state.size(), rm); + } else { + LOG_INFO("Attempting to apply %lu LoRAs", lora_state.size()); } - - LOG_INFO("Attempting to apply %lu LoRAs", lora_state.size()); for (auto& kv : lora_state_diff) { apply_lora(kv.first, kv.second);