Skip to content

Commit ae1d5dc

Browse files
ursgder-ursleejet
authored
feat: allow LoRAs with negative multiplier (leejet#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 <urs@nerd2nerd.org> Co-authored-by: leejet <leejet714@gmail.com>
1 parent 51b53d4 commit ae1d5dc

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

stable-diffusion.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,11 @@ std::pair<std::unordered_map<std::string, float>, std::string> extract_and_remov
276276
while (std::regex_search(text, matches, re)) {
277277
std::string filename = matches[1].str();
278278
float multiplier = std::stof(matches[2].str());
279-
if (multiplier < 0.f) {
279+
280+
if (multiplier == 0.f) {
280281
continue;
281282
}
283+
282284
if (filename2multiplier.find(filename) == filename2multiplier.end()) {
283285
filename2multiplier[filename] = multiplier;
284286
} else {

0 commit comments

Comments
 (0)