From ae1d5dcebbea59dede78233611d99fcc5a8e73af Mon Sep 17 00:00:00 2001 From: Urs Ganse Date: Mon, 20 Nov 2023 16:23:52 +0200 Subject: [PATCH] feat: allow LoRAs with negative multiplier (#83) * Allow Loras with negative weight, too. There are a couple of loras, which serve to adjust certain concepts in both positive and negative directions (like exposure, detail level etc). The current code rejects them if loaded with a negative weight, but I suggest that this check can simply be dropped. * ignore lora in the case of multiplier == 0.f --------- Co-authored-by: Urs Ganse Co-authored-by: leejet --- stable-diffusion.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/stable-diffusion.cpp b/stable-diffusion.cpp index b983594..ca28eb6 100644 --- a/stable-diffusion.cpp +++ b/stable-diffusion.cpp @@ -276,9 +276,11 @@ std::pair, std::string> extract_and_remov while (std::regex_search(text, matches, re)) { std::string filename = matches[1].str(); float multiplier = std::stof(matches[2].str()); - if (multiplier < 0.f) { + + if (multiplier == 0.f) { continue; } + if (filename2multiplier.find(filename) == filename2multiplier.end()) { filename2multiplier[filename] = multiplier; } else {