mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2025-09-10 17:14:36 +00:00
inpaining support completed, invert mask added
This commit is contained in:
parent
23339ace9b
commit
27f575dc83
4 changed files with 12 additions and 2 deletions
1
expose.h
1
expose.h
|
@ -169,6 +169,7 @@ struct sd_generation_inputs
|
|||
const char * negative_prompt = nullptr;
|
||||
const char * init_images = "";
|
||||
const char * mask = "";
|
||||
const bool flip_mask = false;
|
||||
const float denoising_strength = 0.0f;
|
||||
const float cfg_scale = 0.0f;
|
||||
const int sample_steps = 0;
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -264,6 +264,7 @@ class sd_generation_inputs(ctypes.Structure):
|
|||
("negative_prompt", ctypes.c_char_p),
|
||||
("init_images", ctypes.c_char_p),
|
||||
("mask", ctypes.c_char_p),
|
||||
("flip_mask", ctypes.c_bool),
|
||||
("denoising_strength", ctypes.c_float),
|
||||
("cfg_scale", ctypes.c_float),
|
||||
("sample_steps", ctypes.c_int),
|
||||
|
@ -1486,6 +1487,7 @@ def sd_generate(genparams):
|
|||
init_images_arr = genparams.get("init_images", [])
|
||||
init_images = ("" if (not init_images_arr or len(init_images_arr)==0 or not init_images_arr[0]) else init_images_arr[0])
|
||||
mask = genparams.get("mask", "")
|
||||
flip_mask = genparams.get("inpainting_mask_invert", 0)
|
||||
denoising_strength = tryparsefloat(genparams.get("denoising_strength", 0.6))
|
||||
cfg_scale = tryparsefloat(genparams.get("cfg_scale", 5))
|
||||
sample_steps = tryparseint(genparams.get("steps", 20))
|
||||
|
@ -1523,6 +1525,7 @@ def sd_generate(genparams):
|
|||
inputs.negative_prompt = negative_prompt.encode("UTF-8")
|
||||
inputs.init_images = init_images.encode("UTF-8")
|
||||
inputs.mask = "".encode("UTF-8") if not mask else mask.encode("UTF-8")
|
||||
inputs.flip_mask = flip_mask
|
||||
inputs.cfg_scale = cfg_scale
|
||||
inputs.denoising_strength = denoising_strength
|
||||
inputs.sample_steps = sample_steps
|
||||
|
|
|
@ -160,7 +160,6 @@ bool sdtype_load_model(const sd_load_model_inputs inputs) {
|
|||
{
|
||||
printf("With Custom Clip-G Model: %s\n",clipg_filename.c_str());
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
//duplicated from expose.cpp
|
||||
int cl_parseinfo = inputs.clblast_info; //first digit is whether configured, second is platform, third is devices
|
||||
|
@ -516,6 +515,13 @@ sd_generation_outputs sdtype_generate(const sd_generation_inputs inputs)
|
|||
output.status = 0;
|
||||
return output;
|
||||
}
|
||||
if(inputs.flip_mask)
|
||||
{
|
||||
int bufsiz = resized_mask_buf.size();
|
||||
for (int i = 0; i < bufsiz; ++i) {
|
||||
resized_mask_buf[i] = 255 - resized_mask_buf[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
input_image.width = img2imgW;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue