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 <urs@nerd2nerd.org>
Co-authored-by: leejet <leejet714@gmail.com>
This commit is contained in:
Urs Ganse 2023-11-20 16:23:52 +02:00 committed by GitHub
parent 51b53d4cb1
commit ae1d5dcebb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -276,9 +276,11 @@ std::pair<std::unordered_map<std::string, float>, std::string> extract_and_remov
while (std::regex_search(text, matches, re)) { while (std::regex_search(text, matches, re)) {
std::string filename = matches[1].str(); std::string filename = matches[1].str();
float multiplier = std::stof(matches[2].str()); float multiplier = std::stof(matches[2].str());
if (multiplier < 0.f) {
if (multiplier == 0.f) {
continue; continue;
} }
if (filename2multiplier.find(filename) == filename2multiplier.end()) { if (filename2multiplier.find(filename) == filename2multiplier.end()) {
filename2multiplier[filename] = multiplier; filename2multiplier[filename] = multiplier;
} else { } else {