@@ -44,7 +44,7 @@ const char* sample_method_str[] = {
44
44
};
45
45
46
46
// Names of the sigma schedule overrides, same order as sample_schedule in stable-diffusion.h
47
- const char * schedule_str [] = {
47
+ const char * schedulers [] = {
48
48
" default" ,
49
49
" discrete" ,
50
50
" karras" ,
@@ -54,6 +54,8 @@ const char* schedule_str[] = {
54
54
};
55
55
56
56
sd_ctx_t * sd_c;
57
+ // Moved from the context (load time) to generation time params
58
+ scheduler_t scheduler = scheduler_t ::DEFAULT;
57
59
58
60
sample_method_t sample_method;
59
61
@@ -105,7 +107,7 @@ int load_model(const char *model, char *model_path, char* options[], int threads
105
107
const char *clip_g_path = " " ;
106
108
const char *t5xxl_path = " " ;
107
109
const char *vae_path = " " ;
108
- const char *scheduler = " " ;
110
+ const char *scheduler_str = " " ;
109
111
const char *sampler = " " ;
110
112
char *lora_dir = model_path;
111
113
bool lora_dir_allocated = false ;
@@ -133,7 +135,7 @@ int load_model(const char *model, char *model_path, char* options[], int threads
133
135
vae_path = optval;
134
136
}
135
137
if (!strcmp (optname, " scheduler" )) {
136
- scheduler = optval;
138
+ scheduler_str = optval;
137
139
}
138
140
if (!strcmp (optname, " sampler" )) {
139
141
sampler = optval;
@@ -170,22 +172,13 @@ int load_model(const char *model, char *model_path, char* options[], int threads
170
172
}
171
173
sample_method = (sample_method_t )sample_method_found;
172
174
173
- int schedule_found = -1 ;
174
175
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);
179
179
}
180
180
}
181
181
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
-
189
182
fprintf (stderr, " Creating context\n " );
190
183
sd_ctx_params_t ctx_params;
191
184
sd_ctx_params_init (&ctx_params);
@@ -205,7 +198,6 @@ int load_model(const char *model, char *model_path, char* options[], int threads
205
198
ctx_params.free_params_immediately = false ;
206
199
ctx_params.n_threads = threads;
207
200
ctx_params.rng_type = STD_DEFAULT_RNG;
208
- ctx_params.schedule = schedule;
209
201
sd_ctx_t * sd_ctx = new_sd_ctx (&ctx_params);
210
202
211
203
if (sd_ctx == NULL ) {
@@ -241,15 +233,16 @@ int gen_image(char *text, char *negativeText, int width, int height, int steps,
241
233
242
234
p.prompt = text;
243
235
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 ();
247
239
p.width = width;
248
240
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;
251
243
p.seed = seed;
252
244
p.input_id_images_path = " " ;
245
+ p.sample_params .scheduler = scheduler;
253
246
254
247
// Handle input image for img2img
255
248
bool has_input_image = (src_image != NULL && strlen (src_image) > 0 );
0 commit comments