|
27 | 27 | // #define STB_IMAGE_WRITE_STATIC |
28 | 28 | // #include "stb_image_write.h" |
29 | 29 |
|
30 | | -static std::string pending_apply_lora_fname = ""; |
31 | | -static float pending_apply_lora_power = 1.0f; |
32 | 30 | static bool is_loaded_chroma = false; |
33 | 31 |
|
34 | 32 | const char* model_version_to_str[] = { |
@@ -762,11 +760,6 @@ class StableDiffusionGGML { |
762 | 760 | return result < -1; |
763 | 761 | } |
764 | 762 |
|
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 | | - |
770 | 763 | void apply_lora_from_file(const std::string& lora_path, float multiplier) { |
771 | 764 | int64_t t0 = ggml_time_ms(); |
772 | 765 | std::string st_file_path = lora_path; |
@@ -1775,14 +1768,14 @@ sd_image_t* generate_image_internal(sd_ctx_t* sd_ctx, |
1775 | 1768 | prompt = result_pair.second; |
1776 | 1769 | LOG_DEBUG("prompt after extract and remove lora: \"%s\"", prompt.c_str()); |
1777 | 1770 |
|
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"); |
1785 | 1775 | } |
| 1776 | + |
| 1777 | + int64_t t0 = ggml_time_ms(); |
| 1778 | + sd_ctx->sd->apply_loras(lora_f2m); |
1786 | 1779 | int64_t t1 = ggml_time_ms(); |
1787 | 1780 | LOG_INFO("apply_loras completed, taking %.2fs", (t1 - t0) * 1.0f / 1000); |
1788 | 1781 |
|
|
0 commit comments