From f7044cc8c478319cad4705533ffb0b653964b6bb Mon Sep 17 00:00:00 2001 From: Urs Ganse Date: Mon, 20 Nov 2023 11:00:21 +0200 Subject: [PATCH 1/2] 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. --- stable-diffusion.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/stable-diffusion.cpp b/stable-diffusion.cpp index b9835947..bd7a52cc 100644 --- a/stable-diffusion.cpp +++ b/stable-diffusion.cpp @@ -276,9 +276,6 @@ 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) { - continue; - } if (filename2multiplier.find(filename) == filename2multiplier.end()) { filename2multiplier[filename] = multiplier; } else { From ae93b152a2b1ac3ebe2ccdf419338106e5a9f89a Mon Sep 17 00:00:00 2001 From: leejet Date: Mon, 20 Nov 2023 22:20:05 +0800 Subject: [PATCH 2/2] ignore lora in the case of multiplier == 0.f --- stable-diffusion.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/stable-diffusion.cpp b/stable-diffusion.cpp index bd7a52cc..ca28eb69 100644 --- a/stable-diffusion.cpp +++ b/stable-diffusion.cpp @@ -276,6 +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) { + continue; + } + if (filename2multiplier.find(filename) == filename2multiplier.end()) { filename2multiplier[filename] = multiplier; } else {