mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2025-09-11 01:24:36 +00:00
allow specifying width and height
This commit is contained in:
parent
fa1d8b8d95
commit
0c59c1ed90
6 changed files with 26 additions and 3 deletions
2
class.py
2
class.py
|
@ -273,7 +273,7 @@ class model_backend(InferenceModel):
|
|||
unbantokens=False, bantokens=None, usemirostat=None, forceversion=0, nommap=self.kcpp_nommap,
|
||||
usemlock=False, noavx2=self.kcpp_noavx2, debugmode=self.kcpp_debugmode, skiplauncher=True, hordeconfig=None, noblas=self.kcpp_noblas,
|
||||
useclblast=self.kcpp_useclblast, usecublas=self.kcpp_usecublas, usevulkan=self.kcpp_usevulkan, gpulayers=self.kcpp_gpulayers, tensor_split=self.kcpp_tensor_split, config=None,
|
||||
onready='', multiuser=False, foreground=False, preloadstory=None, noshift=False, remotetunnel=False, ssl=False, benchmark=False, nocertify=False)
|
||||
onready='', multiuser=False, foreground=False, preloadstory=None, noshift=False, remotetunnel=False, ssl=False, benchmark=False, nocertify=False, sdconfig=None)
|
||||
|
||||
|
||||
#koboldcpp.main(kcppargs,False) #initialize library without enabling Lite http server
|
||||
|
|
2
expose.h
2
expose.h
|
@ -115,6 +115,8 @@ struct sd_generation_inputs
|
|||
const char * negative_prompt;
|
||||
const float cfg_scale;
|
||||
const int sample_steps;
|
||||
const int width;
|
||||
const int height;
|
||||
const int seed;
|
||||
const char * sample_method;
|
||||
};
|
||||
|
|
|
@ -905,6 +905,8 @@
|
|||
"negative_prompt": "ugly, deformed, censored",
|
||||
"cfg_scale": 5,
|
||||
"steps": 20,
|
||||
"width": 512,
|
||||
"height": 512,
|
||||
"seed": -1,
|
||||
"sampler_name": "Euler a"
|
||||
},
|
||||
|
@ -922,6 +924,12 @@
|
|||
"steps": {
|
||||
"type": "number"
|
||||
},
|
||||
"width": {
|
||||
"type": "number"
|
||||
},
|
||||
"height": {
|
||||
"type": "number"
|
||||
},
|
||||
"seed": {
|
||||
"type": "number"
|
||||
},
|
||||
|
@ -1024,6 +1032,7 @@
|
|||
};
|
||||
</script>
|
||||
|
||||
|
||||
<script>
|
||||
//self destruct into json if requested
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
|
|
|
@ -5002,6 +5002,7 @@ Current version: 119
|
|||
let old_current_memory = current_memory;
|
||||
let old_current_wi = current_wi;
|
||||
let old_extrastopseq = extrastopseq;
|
||||
let old_notes = personal_notes;
|
||||
|
||||
//determine if oldui file or newui file format
|
||||
restart_new_game(false);
|
||||
|
@ -5121,6 +5122,7 @@ Current version: 119
|
|||
current_anote = old_current_anote;
|
||||
current_anotetemplate = old_current_anotetemplate;
|
||||
current_memory = old_current_memory;
|
||||
personal_notes = old_notes;
|
||||
}
|
||||
if(!loadworldinfo)
|
||||
{
|
||||
|
@ -8599,11 +8601,11 @@ Current version: 119
|
|||
last_token_budget = "";
|
||||
groupchat_removals = [];
|
||||
welcome = "";
|
||||
personal_notes = "";
|
||||
last_known_filename = "saved_story.json";
|
||||
is_impersonate_user = false;
|
||||
if (!keep_memory)
|
||||
{
|
||||
personal_notes = "";
|
||||
current_memory = "";
|
||||
current_anote = "";
|
||||
current_wi = [];
|
||||
|
|
10
koboldcpp.py
10
koboldcpp.py
|
@ -107,6 +107,8 @@ class sd_generation_inputs(ctypes.Structure):
|
|||
("negative_prompt", ctypes.c_char_p),
|
||||
("cfg_scale", ctypes.c_float),
|
||||
("sample_steps", ctypes.c_int),
|
||||
("width", ctypes.c_int),
|
||||
("height", ctypes.c_int),
|
||||
("seed", ctypes.c_int),
|
||||
("sample_method", ctypes.c_char_p)]
|
||||
|
||||
|
@ -505,12 +507,16 @@ def sd_generate(genparams):
|
|||
negative_prompt = genparams.get("negative_prompt", "")
|
||||
cfg_scale = genparams.get("cfg_scale", 5)
|
||||
sample_steps = genparams.get("steps", 20)
|
||||
width = genparams.get("width", 512)
|
||||
height = genparams.get("height", 512)
|
||||
seed = genparams.get("seed", -1)
|
||||
sample_method = genparams.get("sampler_name", "euler a")
|
||||
|
||||
#clean vars
|
||||
cfg_scale = (1 if cfg_scale < 1 else (25 if cfg_scale > 25 else cfg_scale))
|
||||
sample_steps = (1 if sample_steps < 1 else (80 if sample_steps > 80 else sample_steps))
|
||||
width = (128 if width < 128 else (1024 if width > 1024 else width))
|
||||
height = (128 if height < 128 else (1024 if height > 1024 else height))
|
||||
|
||||
#quick mode
|
||||
if args.sdconfig and len(args.sdconfig)>1 and args.sdconfig[1]=="quick":
|
||||
|
@ -524,6 +530,8 @@ def sd_generate(genparams):
|
|||
inputs.negative_prompt = negative_prompt.encode("UTF-8")
|
||||
inputs.cfg_scale = cfg_scale
|
||||
inputs.sample_steps = sample_steps
|
||||
inputs.width = width
|
||||
inputs.height = height
|
||||
inputs.seed = seed
|
||||
inputs.sample_method = sample_method.lower().encode("UTF-8")
|
||||
ret = handle.sd_generate(inputs)
|
||||
|
@ -1882,7 +1890,7 @@ def show_new_gui():
|
|||
makefileentry(images_tab, "Stable Diffusion Model (f16 safetensors):", "Select Stable Diffusion Model File", sd_model_var, 1, filetypes=[("*.safetensors","*.safetensors")], tooltiptxt="Select a .safetensors Stable Diffusion model file on disk to be loaded.")
|
||||
makecheckbox(images_tab, "Quick Mode (Low Quality)", sd_quick_var, 4,tooltiptxt="Force optimal generation settings for speed.")
|
||||
makelabelentry(images_tab, "Image threads:" , sd_threads_var, 6, 50,"How many threads to use during image generation.\nIf left blank, uses same value as threads.")
|
||||
makecheckbox(images_tab, "Compress Weights (Slight Memory Saved)", sd_quant_var, 8,tooltiptxt="Quantizes the SD model weights to save memory. May degrade quality.")
|
||||
makecheckbox(images_tab, "Compress Weights (Saves Memory)", sd_quant_var, 8,tooltiptxt="Quantizes the SD model weights to save memory. May degrade quality.")
|
||||
|
||||
|
||||
# launch
|
||||
|
|
|
@ -264,6 +264,8 @@ sd_generation_outputs sdtype_generate(const sd_generation_inputs inputs)
|
|||
sd_params->cfg_scale = inputs.cfg_scale;
|
||||
sd_params->sample_steps = inputs.sample_steps;
|
||||
sd_params->seed = inputs.seed;
|
||||
sd_params->width = inputs.width;
|
||||
sd_params->height = inputs.height;
|
||||
|
||||
printf("\nGenerating Image (%d steps)\n",inputs.sample_steps);
|
||||
fflush(stdout);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue