mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2026-05-07 09:02:04 +00:00
zimage cfg clamp is opt out with remove_limits
This commit is contained in:
parent
010995c967
commit
ab9bc6f2ae
3 changed files with 18 additions and 12 deletions
1
expose.h
1
expose.h
|
|
@ -213,6 +213,7 @@ struct sd_generation_inputs
|
|||
const int clip_skip = -1;
|
||||
const int vid_req_frames = 1;
|
||||
const int vid_req_avi = 0;
|
||||
const bool remove_limits = false;
|
||||
};
|
||||
struct sd_generation_outputs
|
||||
{
|
||||
|
|
|
|||
|
|
@ -332,7 +332,8 @@ class sd_generation_inputs(ctypes.Structure):
|
|||
("scheduler", ctypes.c_char_p),
|
||||
("clip_skip", ctypes.c_int),
|
||||
("vid_req_frames", ctypes.c_int),
|
||||
("vid_req_avi", ctypes.c_int)]
|
||||
("vid_req_avi", ctypes.c_int),
|
||||
("remove_limits", ctypes.c_bool)]
|
||||
|
||||
class sd_generation_outputs(ctypes.Structure):
|
||||
_fields_ = [("status", ctypes.c_int),
|
||||
|
|
@ -1878,7 +1879,7 @@ def sd_process_meta_fields(fields):
|
|||
}
|
||||
fields_dict = {aliases.get(k, k): v for k, v in fields}
|
||||
# whitelist accepted parameters
|
||||
whitelist = ['scheduler', 'shifted_timestep', 'distilled_guidance', 'sampler_name', 'cfg_scale', 'add_sd_step_limit', 'add_sd_cfg_limit']
|
||||
whitelist = ['scheduler', 'shifted_timestep', 'distilled_guidance', 'sampler_name', 'cfg_scale', 'add_sd_step_limit', 'add_sd_cfg_limit', 'remove_limits']
|
||||
fields_dict = {k: v for k, v in fields_dict.items() if k in whitelist}
|
||||
return fields_dict
|
||||
|
||||
|
|
@ -1926,6 +1927,7 @@ def sd_generate(genparams):
|
|||
forced_posprompt = adapter_obj.get("add_sd_prompt", "")
|
||||
forced_steplimit = tryparseint(adapter_obj.get("add_sd_step_limit", genparams.get("add_sd_step_limit",80)),80)
|
||||
forced_maxcfg = tryparsefloat(adapter_obj.get("add_sd_cfg_limit", genparams.get("add_sd_cfg_limit",25)),25)
|
||||
allow_remove_limits = tryparseint(adapter_obj.get("remove_limits", genparams.get("remove_limits",0)),0)
|
||||
|
||||
prompt = genparams.get("prompt", "high quality")
|
||||
negative_prompt = genparams.get("negative_prompt", "")
|
||||
|
|
@ -2007,6 +2009,7 @@ def sd_generate(genparams):
|
|||
inputs.clip_skip = clip_skip
|
||||
inputs.vid_req_frames = vid_req_frames
|
||||
inputs.vid_req_avi = vid_req_avi
|
||||
inputs.remove_limits = allow_remove_limits
|
||||
ret = handle.sd_generate(inputs)
|
||||
outstr = ""
|
||||
animated = False
|
||||
|
|
|
|||
|
|
@ -109,6 +109,7 @@ static std::string sdmodelfilename = "";
|
|||
static bool photomaker_enabled = false;
|
||||
|
||||
static bool is_vid_model = false;
|
||||
static bool remove_limits = false;
|
||||
|
||||
static int get_loaded_sd_version(sd_ctx_t* ctx)
|
||||
{
|
||||
|
|
@ -784,16 +785,16 @@ sd_generation_outputs sdtype_generate(const sd_generation_inputs inputs)
|
|||
}
|
||||
}
|
||||
|
||||
// if(loadedsdver == SDVersion::VERSION_Z_IMAGE)
|
||||
// {
|
||||
// if(sd_params->cfg_scale > 3.0f)
|
||||
// {
|
||||
// if (!sd_is_quiet && sddebugmode) {
|
||||
// printf("Z-Image: clamping CFG Scale to 3.0 to preserve quality\n");
|
||||
// }
|
||||
// sd_params->cfg_scale = 3.0f;
|
||||
// }
|
||||
// }
|
||||
if(!remove_limits && loadedsdver == SDVersion::VERSION_Z_IMAGE)
|
||||
{
|
||||
if(sd_params->cfg_scale > 3.0f)
|
||||
{
|
||||
if (!sd_is_quiet && sddebugmode) {
|
||||
printf("Z-Image: clamping CFG Scale to 3.0 to preserve quality\n");
|
||||
}
|
||||
sd_params->cfg_scale = 3.0f;
|
||||
}
|
||||
}
|
||||
|
||||
if(is_wan && extra_image_data.size()==0 && is_img2img)
|
||||
{
|
||||
|
|
@ -985,6 +986,7 @@ sd_generation_outputs sdtype_generate(const sd_generation_inputs inputs)
|
|||
int vid_req_frames = inputs.vid_req_frames;
|
||||
int vid_req_avi = inputs.vid_req_avi;
|
||||
int generated_num_results = 1;
|
||||
remove_limits = inputs.remove_limits;
|
||||
|
||||
if(is_vid_model)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue