Skip to content

Commit e2a21bc

Browse files
stduhpfthxCode
authored andcommitted
fix:: unapply current loras properly (leejet#590)
1 parent 4a60373 commit e2a21bc

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

stable-diffusion.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -881,14 +881,19 @@ class StableDiffusionGGML {
881881
for (auto& kv : lora_state) {
882882
const std::string& lora_name = kv.first;
883883
float multiplier = kv.second;
884-
885-
if (curr_lora_state.find(lora_name) != curr_lora_state.end()) {
886-
float curr_multiplier = curr_lora_state[lora_name];
887-
multiplier -= curr_multiplier;
888-
}
889-
if (multiplier != 0.f) {
890-
lora_state_diff[lora_name] = multiplier;
891-
}
884+
lora_state_diff[lora_name] += multiplier;
885+
}
886+
for (auto& kv : curr_lora_state) {
887+
const std::string& lora_name = kv.first;
888+
float curr_multiplier = kv.second;
889+
lora_state_diff[lora_name] -= curr_multiplier;
890+
}
891+
892+
size_t rm = lora_state_diff.size() - lora_state.size();
893+
if (rm != 0) {
894+
LOG_INFO("Attempting to apply %lu LoRAs (removing %lu applied LoRAs)", lora_state.size(), rm);
895+
} else {
896+
LOG_INFO("Attempting to apply %lu LoRAs", lora_state.size());
892897
}
893898

894899
for (auto& kv : lora_state_diff) {

0 commit comments

Comments
 (0)