@@ -99,7 +99,7 @@ int load_model(char *model, char* options[], int threads, int diff) {
99
99
}
100
100
101
101
int sample_method_found = -1 ;
102
- for (int m = 0 ; m < N_SAMPLE_METHODS ; m++) {
102
+ for (int m = 0 ; m < SAMPLE_METHOD_COUNT ; m++) {
103
103
if (!strcmp (sampler, sample_method_str[m])) {
104
104
sample_method_found = m;
105
105
}
@@ -111,7 +111,7 @@ int load_model(char *model, char* options[], int threads, int diff) {
111
111
sample_method = (sample_method_t )sample_method_found;
112
112
113
113
int schedule_found = -1 ;
114
- for (int d = 0 ; d < N_SCHEDULES ; d++) {
114
+ for (int d = 0 ; d < SCHEDULE_COUNT ; d++) {
115
115
if (!strcmp (scheduler, schedule_str[d])) {
116
116
schedule_found = d;
117
117
fprintf (stderr, " Found scheduler: %s\n " , scheduler);
@@ -125,30 +125,28 @@ int load_model(char *model, char* options[], int threads, int diff) {
125
125
}
126
126
127
127
schedule_t schedule = (schedule_t )schedule_found;
128
-
128
+
129
129
fprintf (stderr, " Creating context\n " );
130
- sd_ctx_t * sd_ctx = new_sd_ctx (model,
131
- clip_l_path,
132
- clip_g_path,
133
- t5xxl_path,
134
- stableDiffusionModel,
135
- vae_path,
136
- " " ,
137
- " " ,
138
- " " ,
139
- " " ,
140
- " " ,
141
- false ,
142
- false ,
143
- false ,
144
- threads,
145
- SD_TYPE_COUNT,
146
- STD_DEFAULT_RNG,
147
- schedule,
148
- false ,
149
- false ,
150
- false ,
151
- false );
130
+ sd_ctx_params_t ctx_params;
131
+ sd_ctx_params_init (&ctx_params);
132
+ ctx_params.model_path = model;
133
+ ctx_params.clip_l_path = clip_l_path;
134
+ ctx_params.clip_g_path = clip_g_path;
135
+ ctx_params.t5xxl_path = t5xxl_path;
136
+ ctx_params.diffusion_model_path = stableDiffusionModel;
137
+ ctx_params.vae_path = vae_path;
138
+ ctx_params.taesd_path = " " ;
139
+ ctx_params.control_net_path = " " ;
140
+ ctx_params.lora_model_dir = " " ;
141
+ ctx_params.embedding_dir = " " ;
142
+ ctx_params.stacked_id_embed_dir = " " ;
143
+ ctx_params.vae_decode_only = false ;
144
+ ctx_params.vae_tiling = false ;
145
+ ctx_params.free_params_immediately = false ;
146
+ ctx_params.n_threads = threads;
147
+ ctx_params.rng_type = STD_DEFAULT_RNG;
148
+ ctx_params.schedule = schedule;
149
+ sd_ctx_t * sd_ctx = new_sd_ctx (&ctx_params);
152
150
153
151
if (sd_ctx == NULL ) {
154
152
fprintf (stderr, " failed loading model (generic error)\n " );
@@ -169,29 +167,21 @@ int gen_image(char *text, char *negativeText, int width, int height, int steps,
169
167
170
168
fprintf (stderr, " Generating image\n " );
171
169
172
- results = txt2img (sd_c,
173
- text,
174
- negativeText,
175
- -1 , // clip_skip
176
- cfg_scale, // sfg_scale
177
- 3 .5f ,
178
- 0 , // eta
179
- width,
180
- height,
181
- sample_method,
182
- steps,
183
- seed,
184
- 1 ,
185
- NULL ,
186
- 0 .9f ,
187
- 20 .f ,
188
- false ,
189
- " " ,
190
- skip_layers.data (),
191
- skip_layers.size (),
192
- 0 ,
193
- 0.01 ,
194
- 0.2 );
170
+ sd_img_gen_params_t p;
171
+ sd_img_gen_params_init (&p);
172
+
173
+ p.prompt = text;
174
+ p.negative_prompt = negativeText;
175
+ p.guidance .txt_cfg = cfg_scale;
176
+ p.guidance .slg .layers = skip_layers.data ();
177
+ p.guidance .slg .layer_count = skip_layers.size ();
178
+ p.width = width;
179
+ p.height = height;
180
+ p.sample_method = sample_method;
181
+ p.sample_steps = steps;
182
+ p.seed = seed;
183
+
184
+ results = generate_image (sd_c, &p);
195
185
196
186
if (results == NULL ) {
197
187
fprintf (stderr, " NO results\n " );
0 commit comments