From 9c3d85fc2899d7a7c4abbce696e04da269973649 Mon Sep 17 00:00:00 2001 From: Richard Palethorpe Date: Sun, 7 Sep 2025 15:34:45 +0100 Subject: [PATCH] =?UTF-8?q?chore:=20=E2=AC=86=EF=B8=8F=20Update=20leejet/s?= =?UTF-8?q?table-diffusion.cpp=20to=20d7f430cd693f2e12ecbaa0ce881746cf305c?= =?UTF-8?q?3b1f=20(#6213)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * :arrow_up: Update leejet/stable-diffusion.cpp Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix(stablediffusion-ggml): Use new sample_params_t Signed-off-by: Richard Palethorpe --------- Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Signed-off-by: Richard Palethorpe Co-authored-by: mudler <2420543+mudler@users.noreply.github.com> --- backend/go/stablediffusion-ggml/.gitignore | 2 ++ backend/go/stablediffusion-ggml/Makefile | 2 +- backend/go/stablediffusion-ggml/gosd.cpp | 35 +++++++++------------- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/backend/go/stablediffusion-ggml/.gitignore b/backend/go/stablediffusion-ggml/.gitignore index fb79b68be..2dfc6b056 100644 --- a/backend/go/stablediffusion-ggml/.gitignore +++ b/backend/go/stablediffusion-ggml/.gitignore @@ -1,4 +1,6 @@ package/ sources/ +.cache/ +build/ libgosd.so stablediffusion-ggml diff --git a/backend/go/stablediffusion-ggml/Makefile b/backend/go/stablediffusion-ggml/Makefile index 170c69a7f..394992309 100644 --- a/backend/go/stablediffusion-ggml/Makefile +++ b/backend/go/stablediffusion-ggml/Makefile @@ -8,7 +8,7 @@ JOBS?=$(shell nproc --ignore=1) # stablediffusion.cpp (ggml) STABLEDIFFUSION_GGML_REPO?=https://github.com/leejet/stable-diffusion.cpp -STABLEDIFFUSION_GGML_VERSION?=2eb3845df5675a71565d5a9e13b7bad0881fafcd +STABLEDIFFUSION_GGML_VERSION?=d7f430cd693f2e12ecbaa0ce881746cf305c3b1f CMAKE_ARGS+=-DGGML_MAX_NAME=128 diff --git a/backend/go/stablediffusion-ggml/gosd.cpp b/backend/go/stablediffusion-ggml/gosd.cpp index 7e5efb6ec..b2026fdb3 100644 --- a/backend/go/stablediffusion-ggml/gosd.cpp +++ b/backend/go/stablediffusion-ggml/gosd.cpp @@ -44,7 +44,7 @@ const char* sample_method_str[] = { }; // Names of the sigma schedule overrides, same order as sample_schedule in stable-diffusion.h -const char* schedule_str[] = { +const char* schedulers[] = { "default", "discrete", "karras", @@ -54,6 +54,8 @@ const char* schedule_str[] = { }; sd_ctx_t* sd_c; +// Moved from the context (load time) to generation time params +scheduler_t scheduler = scheduler_t::DEFAULT; sample_method_t sample_method; @@ -105,7 +107,7 @@ int load_model(const char *model, char *model_path, char* options[], int threads const char *clip_g_path = ""; const char *t5xxl_path = ""; const char *vae_path = ""; - const char *scheduler = ""; + const char *scheduler_str = ""; const char *sampler = ""; char *lora_dir = model_path; bool lora_dir_allocated = false; @@ -133,7 +135,7 @@ int load_model(const char *model, char *model_path, char* options[], int threads vae_path = optval; } if (!strcmp(optname, "scheduler")) { - scheduler = optval; + scheduler_str = optval; } if (!strcmp(optname, "sampler")) { sampler = optval; @@ -170,22 +172,13 @@ int load_model(const char *model, char *model_path, char* options[], int threads } sample_method = (sample_method_t)sample_method_found; - int schedule_found = -1; for (int d = 0; d < SCHEDULE_COUNT; d++) { - if (!strcmp(scheduler, schedule_str[d])) { - schedule_found = d; - fprintf (stderr, "Found scheduler: %s\n", scheduler); - + if (!strcmp(scheduler_str, schedulers[d])) { + scheduler = (scheduler_t)d; + fprintf (stderr, "Found scheduler: %s\n", scheduler_str); } } - if (schedule_found == -1) { - fprintf (stderr, "Invalid scheduler! using DEFAULT\n"); - schedule_found = DEFAULT; - } - - schedule_t schedule = (schedule_t)schedule_found; - fprintf (stderr, "Creating context\n"); sd_ctx_params_t ctx_params; sd_ctx_params_init(&ctx_params); @@ -205,7 +198,6 @@ int load_model(const char *model, char *model_path, char* options[], int threads ctx_params.free_params_immediately = false; ctx_params.n_threads = threads; ctx_params.rng_type = STD_DEFAULT_RNG; - ctx_params.schedule = schedule; sd_ctx_t* sd_ctx = new_sd_ctx(&ctx_params); if (sd_ctx == NULL) { @@ -241,15 +233,16 @@ int gen_image(char *text, char *negativeText, int width, int height, int steps, p.prompt = text; p.negative_prompt = negativeText; - p.guidance.txt_cfg = cfg_scale; - p.guidance.slg.layers = skip_layers.data(); - p.guidance.slg.layer_count = skip_layers.size(); + p.sample_params.guidance.txt_cfg = cfg_scale; + p.sample_params.guidance.slg.layers = skip_layers.data(); + p.sample_params.guidance.slg.layer_count = skip_layers.size(); p.width = width; p.height = height; - p.sample_method = sample_method; - p.sample_steps = steps; + p.sample_params.sample_method = sample_method; + p.sample_params.sample_steps = steps; p.seed = seed; p.input_id_images_path = ""; + p.sample_params.scheduler = scheduler; // Handle input image for img2img bool has_input_image = (src_image != NULL && strlen(src_image) > 0);