Skip to content

Commit 9c3d85f

Browse files
richiejpmudler
andauthored
chore: ⬆️ Update leejet/stable-diffusion.cpp to d7f430cd693f2e12ecbaa0ce881746cf305c3b1f (#6213)
* ⬆️ 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 <[email protected]> --------- Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Signed-off-by: Richard Palethorpe <[email protected]> Co-authored-by: mudler <[email protected]>
1 parent 007ca64 commit 9c3d85f

File tree

3 files changed

+17
-22
lines changed

3 files changed

+17
-22
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
package/
22
sources/
3+
.cache/
4+
build/
35
libgosd.so
46
stablediffusion-ggml

backend/go/stablediffusion-ggml/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ JOBS?=$(shell nproc --ignore=1)
88

99
# stablediffusion.cpp (ggml)
1010
STABLEDIFFUSION_GGML_REPO?=https://github.com/leejet/stable-diffusion.cpp
11-
STABLEDIFFUSION_GGML_VERSION?=2eb3845df5675a71565d5a9e13b7bad0881fafcd
11+
STABLEDIFFUSION_GGML_VERSION?=d7f430cd693f2e12ecbaa0ce881746cf305c3b1f
1212

1313
CMAKE_ARGS+=-DGGML_MAX_NAME=128
1414

backend/go/stablediffusion-ggml/gosd.cpp

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const char* sample_method_str[] = {
4444
};
4545

4646
// Names of the sigma schedule overrides, same order as sample_schedule in stable-diffusion.h
47-
const char* schedule_str[] = {
47+
const char* schedulers[] = {
4848
"default",
4949
"discrete",
5050
"karras",
@@ -54,6 +54,8 @@ const char* schedule_str[] = {
5454
};
5555

5656
sd_ctx_t* sd_c;
57+
// Moved from the context (load time) to generation time params
58+
scheduler_t scheduler = scheduler_t::DEFAULT;
5759

5860
sample_method_t sample_method;
5961

@@ -105,7 +107,7 @@ int load_model(const char *model, char *model_path, char* options[], int threads
105107
const char *clip_g_path = "";
106108
const char *t5xxl_path = "";
107109
const char *vae_path = "";
108-
const char *scheduler = "";
110+
const char *scheduler_str = "";
109111
const char *sampler = "";
110112
char *lora_dir = model_path;
111113
bool lora_dir_allocated = false;
@@ -133,7 +135,7 @@ int load_model(const char *model, char *model_path, char* options[], int threads
133135
vae_path = optval;
134136
}
135137
if (!strcmp(optname, "scheduler")) {
136-
scheduler = optval;
138+
scheduler_str = optval;
137139
}
138140
if (!strcmp(optname, "sampler")) {
139141
sampler = optval;
@@ -170,22 +172,13 @@ int load_model(const char *model, char *model_path, char* options[], int threads
170172
}
171173
sample_method = (sample_method_t)sample_method_found;
172174

173-
int schedule_found = -1;
174175
for (int d = 0; d < SCHEDULE_COUNT; d++) {
175-
if (!strcmp(scheduler, schedule_str[d])) {
176-
schedule_found = d;
177-
fprintf (stderr, "Found scheduler: %s\n", scheduler);
178-
176+
if (!strcmp(scheduler_str, schedulers[d])) {
177+
scheduler = (scheduler_t)d;
178+
fprintf (stderr, "Found scheduler: %s\n", scheduler_str);
179179
}
180180
}
181181

182-
if (schedule_found == -1) {
183-
fprintf (stderr, "Invalid scheduler! using DEFAULT\n");
184-
schedule_found = DEFAULT;
185-
}
186-
187-
schedule_t schedule = (schedule_t)schedule_found;
188-
189182
fprintf (stderr, "Creating context\n");
190183
sd_ctx_params_t ctx_params;
191184
sd_ctx_params_init(&ctx_params);
@@ -205,7 +198,6 @@ int load_model(const char *model, char *model_path, char* options[], int threads
205198
ctx_params.free_params_immediately = false;
206199
ctx_params.n_threads = threads;
207200
ctx_params.rng_type = STD_DEFAULT_RNG;
208-
ctx_params.schedule = schedule;
209201
sd_ctx_t* sd_ctx = new_sd_ctx(&ctx_params);
210202

211203
if (sd_ctx == NULL) {
@@ -241,15 +233,16 @@ int gen_image(char *text, char *negativeText, int width, int height, int steps,
241233

242234
p.prompt = text;
243235
p.negative_prompt = negativeText;
244-
p.guidance.txt_cfg = cfg_scale;
245-
p.guidance.slg.layers = skip_layers.data();
246-
p.guidance.slg.layer_count = skip_layers.size();
236+
p.sample_params.guidance.txt_cfg = cfg_scale;
237+
p.sample_params.guidance.slg.layers = skip_layers.data();
238+
p.sample_params.guidance.slg.layer_count = skip_layers.size();
247239
p.width = width;
248240
p.height = height;
249-
p.sample_method = sample_method;
250-
p.sample_steps = steps;
241+
p.sample_params.sample_method = sample_method;
242+
p.sample_params.sample_steps = steps;
251243
p.seed = seed;
252244
p.input_id_images_path = "";
245+
p.sample_params.scheduler = scheduler;
253246

254247
// Handle input image for img2img
255248
bool has_input_image = (src_image != NULL && strlen(src_image) > 0);

0 commit comments

Comments
 (0)