Skip to content

Commit

Permalink
feat: allow LoRAs with negative multiplier (#83)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Co-authored-by: leejet <[email protected]>
  • Loading branch information
3 people authored Nov 20, 2023
1 parent 51b53d4 commit ae1d5dc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion stable-diffusion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,11 @@ std::pair<std::unordered_map<std::string, float>, 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 {
Expand Down

0 comments on commit ae1d5dc

Please sign in to comment.