Skip to content

Commit cf77a5c

Browse files
committed
Clean up pending LoRA code and simplify LoRA changes to upstream
1 parent e03650f commit cf77a5c

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

otherarch/sdcpp/sdtype_adapter.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,6 @@ bool sdtype_load_model(const sd_load_model_inputs inputs) {
305305
if(lorafilename!="" && inputs.lora_multiplier>0)
306306
{
307307
printf("\nApply LoRA...\n");
308-
// sd_ctx->sd->set_pending_lora(lorafilename,inputs.lora_multiplier);
309308
sd_ctx->sd->apply_lora_from_file(lorafilename,inputs.lora_multiplier);
310309
}
311310

otherarch/sdcpp/stable-diffusion.cpp

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
// #define STB_IMAGE_WRITE_STATIC
2828
// #include "stb_image_write.h"
2929

30-
static std::string pending_apply_lora_fname = "";
31-
static float pending_apply_lora_power = 1.0f;
3230
static bool is_loaded_chroma = false;
3331

3432
const char* model_version_to_str[] = {
@@ -762,11 +760,6 @@ class StableDiffusionGGML {
762760
return result < -1;
763761
}
764762

765-
void set_pending_lora(const std::string& lora_path, float multiplier) {
766-
pending_apply_lora_fname = lora_path;
767-
pending_apply_lora_power = multiplier;
768-
}
769-
770763
void apply_lora_from_file(const std::string& lora_path, float multiplier) {
771764
int64_t t0 = ggml_time_ms();
772765
std::string st_file_path = lora_path;
@@ -1775,14 +1768,14 @@ sd_image_t* generate_image_internal(sd_ctx_t* sd_ctx,
17751768
prompt = result_pair.second;
17761769
LOG_DEBUG("prompt after extract and remove lora: \"%s\"", prompt.c_str());
17771770

1778-
int64_t t0 = ggml_time_ms();
1779-
// sd_ctx->sd->apply_loras(lora_f2m); //only use hardcoded lora for kcpp
1780-
if(pending_apply_lora_fname!="" && pending_apply_lora_power>0)
1781-
{
1782-
printf("\nApplying LoRA now...\n");
1783-
sd_ctx->sd->apply_lora_from_file(pending_apply_lora_fname,pending_apply_lora_power);
1784-
pending_apply_lora_fname = "";
1771+
//only use hardcoded lora for kcpp
1772+
if (!lora_f2m.empty()) {
1773+
lora_f2m.clear();
1774+
printf("\nWarning: not applying LoRAs requested by prompt!\n");
17851775
}
1776+
1777+
int64_t t0 = ggml_time_ms();
1778+
sd_ctx->sd->apply_loras(lora_f2m);
17861779
int64_t t1 = ggml_time_ms();
17871780
LOG_INFO("apply_loras completed, taking %.2fs", (t1 - t0) * 1.0f / 1000);
17881781

0 commit comments

Comments
 (0)