diff --git a/expose.h b/expose.h
index 5a56ba816..d474ed41e 100644
--- a/expose.h
+++ b/expose.h
@@ -181,7 +181,7 @@ struct sd_generation_inputs
const char * negative_prompt = nullptr;
const char * init_images = "";
const char * mask = "";
- const char * photomaker_image = "";
+ const char * extra_image = "";
const bool flip_mask = false;
const float denoising_strength = 0.0f;
const float cfg_scale = 0.0f;
diff --git a/kcpp_sdui.embd b/kcpp_sdui.embd
index 8ea800f9d..597f8ee17 100644
--- a/kcpp_sdui.embd
+++ b/kcpp_sdui.embd
@@ -5,18 +5,18 @@
Stable UI for KoboldCpp
-
-
diff --git a/koboldcpp.py b/koboldcpp.py
index 0258576ac..27af6fe60 100644
--- a/koboldcpp.py
+++ b/koboldcpp.py
@@ -291,7 +291,7 @@ class sd_generation_inputs(ctypes.Structure):
("negative_prompt", ctypes.c_char_p),
("init_images", ctypes.c_char_p),
("mask", ctypes.c_char_p),
- ("photomaker_image", ctypes.c_char_p),
+ ("extra_image", ctypes.c_char_p),
("flip_mask", ctypes.c_bool),
("denoising_strength", ctypes.c_float),
("cfg_scale", ctypes.c_float),
@@ -1714,7 +1714,7 @@ def sd_generate(genparams):
seed = random.randint(100000, 999999)
sample_method = genparams.get("sampler_name", "k_euler_a")
clip_skip = tryparseint(genparams.get("clip_skip", -1),-1)
- photomaker_image = strip_base64_prefix(genparams.get("photomaker_image", ""))
+ extra_image = strip_base64_prefix(genparams.get("extra_image", ""))
#clean vars
cfg_scale = (1 if cfg_scale < 1 else (25 if cfg_scale > 25 else cfg_scale))
@@ -1728,7 +1728,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.photomaker_image = "".encode("UTF-8") if not photomaker_image else photomaker_image.encode("UTF-8")
+ inputs.extra_image = "".encode("UTF-8") if not extra_image else extra_image.encode("UTF-8")
inputs.flip_mask = flip_mask
inputs.cfg_scale = cfg_scale
inputs.denoising_strength = denoising_strength
diff --git a/otherarch/sdcpp/sdtype_adapter.cpp b/otherarch/sdcpp/sdtype_adapter.cpp
index 0909c8b8a..31d3a1a37 100644
--- a/otherarch/sdcpp/sdtype_adapter.cpp
+++ b/otherarch/sdcpp/sdtype_adapter.cpp
@@ -116,7 +116,7 @@ static int sddebugmode = 0;
static std::string recent_data = "";
static uint8_t * input_image_buffer = NULL;
static uint8_t * input_mask_buffer = NULL;
-static uint8_t * input_photomaker_buffer = NULL;
+static uint8_t * input_extraimage_buffer = NULL;
static std::string sdplatformenv, sddeviceenv, sdvulkandeviceenv;
static int cfg_tiled_vae_threshold = 0;
@@ -434,14 +434,9 @@ sd_generation_outputs sdtype_generate(const sd_generation_inputs inputs)
std::string cleannegprompt = clean_input_prompt(inputs.negative_prompt);
std::string img2img_data = std::string(inputs.init_images);
std::string img2img_mask = std::string(inputs.mask);
- std::string photomaker_image_data = std::string(inputs.photomaker_image);
+ std::string extra_image_data = std::string(inputs.extra_image);
std::string sampler = inputs.sample_method;
- if(!photomaker_enabled)
- {
- photomaker_image_data = "";
- }
-
sd_params->prompt = cleanprompt;
sd_params->negative_prompt = cleannegprompt;
sd_params->cfg_scale = inputs.cfg_scale;
@@ -508,17 +503,17 @@ sd_generation_outputs sdtype_generate(const sd_generation_inputs inputs)
//for img2img
sd_image_t input_image = {0,0,0,nullptr};
- sd_image_t photomaker_reference = {0,0,0,nullptr};
+ sd_image_t extraimage_reference = {0,0,0,nullptr};
std::vector image_buffer;
std::vector image_mask_buffer;
- std::vector photomaker_buffer;
+ std::vector extraimage_buffer;
int nx, ny, nc;
int img2imgW = sd_params->width; //for img2img input
int img2imgH = sd_params->height;
int img2imgC = 3; // Assuming RGB image
std::vector resized_image_buf(img2imgW * img2imgH * img2imgC);
std::vector resized_mask_buf(img2imgW * img2imgH * img2imgC);
- std::vector resized_photomaker_buf(img2imgW * img2imgH * img2imgC);
+ std::vector resized_extraimage_buf(img2imgW * img2imgH * img2imgC);
std::string ts = get_timestamp_str();
if(!sd_is_quiet)
@@ -563,35 +558,38 @@ sd_generation_outputs sdtype_generate(const sd_generation_inputs inputs)
sd_params->sample_method = sample_method_t::EULER_A;
}
- if(photomaker_image_data!="")
+ if(extra_image_data!="")
{
- if(input_photomaker_buffer!=nullptr) //just in time free old buffer
+ if(input_extraimage_buffer!=nullptr) //just in time free old buffer
{
- stbi_image_free(input_photomaker_buffer);
- input_photomaker_buffer = nullptr;
+ stbi_image_free(input_extraimage_buffer);
+ input_extraimage_buffer = nullptr;
}
int nx2, ny2, nc2;
- photomaker_buffer = kcpp_base64_decode(photomaker_image_data);
- input_photomaker_buffer = stbi_load_from_memory(photomaker_buffer.data(), photomaker_buffer.size(), &nx2, &ny2, &nc2, 1);
+ extraimage_buffer = kcpp_base64_decode(extra_image_data);
+ input_extraimage_buffer = stbi_load_from_memory(extraimage_buffer.data(), extraimage_buffer.size(), &nx2, &ny2, &nc2, 1);
// Resize the image
- int resok = stbir_resize_uint8(input_photomaker_buffer, nx2, ny2, 0, resized_photomaker_buf.data(), img2imgW, img2imgH, 0, 1);
+ int resok = stbir_resize_uint8(input_extraimage_buffer, nx2, ny2, 0, resized_extraimage_buf.data(), img2imgW, img2imgH, 0, 1);
if (!resok) {
- printf("\nKCPP SD: resize photomaker image failed!\n");
+ printf("\nKCPP SD: resize extra image failed!\n");
output.data = "";
output.status = 0;
return output;
}
- photomaker_reference.width = img2imgW;
- photomaker_reference.height = img2imgH;
- photomaker_reference.channel = img2imgC;
- photomaker_reference.data = resized_photomaker_buf.data();
+ extraimage_reference.width = img2imgW;
+ extraimage_reference.height = img2imgH;
+ extraimage_reference.channel = img2imgC;
+ extraimage_reference.data = resized_extraimage_buf.data();
//ensure prompt has img keyword, otherwise append it
- if (sd_params->prompt.find("img") == std::string::npos) {
- sd_params->prompt += " img";
- } else if (sd_params->prompt.rfind("img", 0) == 0) {
- // "img" found at the start of the string (position 0), which is not allowed. Add some text before it
- sd_params->prompt = "person " + sd_params->prompt;
+ if(photomaker_enabled)
+ {
+ if (sd_params->prompt.find("img") == std::string::npos) {
+ sd_params->prompt += " img";
+ } else if (sd_params->prompt.rfind("img", 0) == 0) {
+ // "img" found at the start of the string (position 0), which is not allowed. Add some text before it
+ sd_params->prompt = "person " + sd_params->prompt;
+ }
}
}
@@ -638,7 +636,7 @@ sd_generation_outputs sdtype_generate(const sd_generation_inputs inputs)
sd_params->slg_scale,
sd_params->skip_layer_start,
sd_params->skip_layer_end,
- (photomaker_image_data!=""?(&photomaker_reference):nullptr));
+ (photomaker_enabled && extra_image_data!=""?(&extraimage_reference):nullptr));
} else {
if (sd_params->width <= 0 || sd_params->width % 64 != 0 || sd_params->height <= 0 || sd_params->height % 64 != 0) {
@@ -762,7 +760,7 @@ sd_generation_outputs sdtype_generate(const sd_generation_inputs inputs)
sd_params->slg_scale,
sd_params->skip_layer_start,
sd_params->skip_layer_end,
- (photomaker_image_data!=""?(&photomaker_reference):nullptr));
+ (photomaker_enabled && extra_image_data!=""?(&extraimage_reference):nullptr));
}
if (results == NULL) {