From cb5755bc963c83dc0bb2924ab1de9cf0f8214431 Mon Sep 17 00:00:00 2001 From: Concedo <39025047+LostRuins@users.noreply.github.com> Date: Thu, 12 Feb 2026 17:53:04 +0800 Subject: [PATCH] reworked soft limit default restrictions for sd image gen --- koboldcpp.py | 3 --- otherarch/sdcpp/sdtype_adapter.cpp | 16 ++++++---------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/koboldcpp.py b/koboldcpp.py index e0e0bdec8..225953b9a 100755 --- a/koboldcpp.py +++ b/koboldcpp.py @@ -2123,9 +2123,6 @@ def sd_generate(genparams): sample_steps = (1 if sample_steps < 1 else (forced_steplimit if sample_steps > forced_steplimit else sample_steps)) vid_req_frames = (1 if vid_req_frames < 1 else (100 if vid_req_frames > 100 else vid_req_frames)) - if args.sdclamped: - sample_steps = (40 if sample_steps > 40 else sample_steps) - inputs = sd_generation_inputs() inputs.prompt = prompt.encode("UTF-8") inputs.negative_prompt = negative_prompt.encode("UTF-8") diff --git a/otherarch/sdcpp/sdtype_adapter.cpp b/otherarch/sdcpp/sdtype_adapter.cpp index 61e6b3a4e..fa4eb27f5 100644 --- a/otherarch/sdcpp/sdtype_adapter.cpp +++ b/otherarch/sdcpp/sdtype_adapter.cpp @@ -849,8 +849,8 @@ sd_generation_outputs sdtype_generate(const sd_generation_inputs inputs) const int default_res_limit = 8192; // arbitrary, just to simplify the code // avoid crashes due to bugs/limitations on certain models // although it can be possible for a single side to exceed 1024, the total resolution of the image - // cannot exceed (832x832) for sd1/sd2 or (1280x1280) for sdxl/sd3/flux, to prevent crashing the server - const int hard_megapixel_res_limit = (loadedsdver==SDVersion::VERSION_SD1 || loadedsdver==SDVersion::VERSION_SD2)?832:1280; + // cannot exceed (832x832) for sd1/sd2 or (2048x2048) for sdxl/sd3/flux, to prevent crashing the server + const int hard_megapixel_res_limit = (loadedsdver==SDVersion::VERSION_SD1 || loadedsdver==SDVersion::VERSION_SD2)?832:2048; int img_hard_limit = default_res_limit; if (cfg_side_limit > 0) { @@ -858,15 +858,11 @@ sd_generation_outputs sdtype_generate(const sd_generation_inputs inputs) } int img_soft_limit = default_res_limit; - if (cfg_square_limit > 0) { - img_soft_limit = std::max(std::min(cfg_square_limit, default_res_limit), 64); - } - - if (cfg_square_limit > 0 && sddebugmode == 1) { - img_soft_limit = std::min(hard_megapixel_res_limit * 2, img_soft_limit); //double the limit for debugmode if cfg_square_limit is set - } else { - img_soft_limit = std::min(hard_megapixel_res_limit, img_soft_limit); + if (cfg_square_limit <= 0) { + cfg_square_limit = 1024; //defaults to 1 megapixel soft e.g. 1024x1024 if unspecified } + img_soft_limit = std::max(std::min(cfg_square_limit, default_res_limit), 64); + img_soft_limit = std::min(hard_megapixel_res_limit, img_soft_limit); sd_fix_resolution(sd_params->width, sd_params->height, img_hard_limit, img_soft_limit); if (inputs.width != sd_params->width || inputs.height != sd_params->height) {