@@ -59,6 +59,7 @@ const char* sampling_methods_str[] = {
5959 " DDIM \" trailing\" " ,
6060 " TCD" ,
6161 " Euler A" ,
62+ " Gradient Estimation" ,
6263};
6364
6465/* ================================================== Helper Functions ================================================*/
@@ -1124,6 +1125,7 @@ class StableDiffusionGGML {
11241125 float eta,
11251126 int shifted_timestep,
11261127 sample_method_t method,
1128+ float ge_gamma,
11271129 const std::vector<float >& sigmas,
11281130 int start_merge_step,
11291131 SDCondition id_cond,
@@ -1354,7 +1356,7 @@ class StableDiffusionGGML {
13541356 return denoised;
13551357 };
13561358
1357- sample_k_diffusion (method, denoise, work_ctx, x, sigmas, rng, eta);
1359+ sample_k_diffusion (method, denoise, work_ctx, x, sigmas, rng, eta, ge_gamma );
13581360
13591361 if (inverse_noise_scaling) {
13601362 x = denoiser->inverse_noise_scaling (sigmas[sigmas.size () - 1 ], x);
@@ -1725,6 +1727,7 @@ const char* sample_method_to_str[] = {
17251727 " ddim_trailing" ,
17261728 " tcd" ,
17271729 " euler_a" ,
1730+ " gradient_estimation" ,
17281731};
17291732
17301733const char * sd_sample_method_name (enum sample_method_t sample_method) {
@@ -1896,6 +1899,7 @@ void sd_sample_params_init(sd_sample_params_t* sample_params) {
18961899 sample_params->scheduler = DEFAULT;
18971900 sample_params->sample_method = SAMPLE_METHOD_DEFAULT;
18981901 sample_params->sample_steps = 20 ;
1902+ sample_params->ge_gamma = 2 .0f ;
18991903}
19001904
19011905char * sd_sample_params_to_str (const sd_sample_params_t * sample_params) {
@@ -1916,6 +1920,7 @@ char* sd_sample_params_to_str(const sd_sample_params_t* sample_params) {
19161920 " sample_method: %s, "
19171921 " sample_steps: %d, "
19181922 " eta: %.2f, "
1923+ " ge_gamma: %.2f, "
19191924 " shifted_timestep: %d)" ,
19201925 sample_params->guidance .txt_cfg ,
19211926 isfinite (sample_params->guidance .img_cfg )
@@ -1930,6 +1935,7 @@ char* sd_sample_params_to_str(const sd_sample_params_t* sample_params) {
19301935 sd_sample_method_name (sample_params->sample_method ),
19311936 sample_params->sample_steps ,
19321937 sample_params->eta ,
1938+ sample_params->ge_gamma ,
19331939 sample_params->shifted_timestep );
19341940
19351941 return buf;
@@ -2065,6 +2071,7 @@ sd_image_t* generate_image_internal(sd_ctx_t* sd_ctx,
20652071 int width,
20662072 int height,
20672073 enum sample_method_t sample_method,
2074+ float ge_gamma,
20682075 const std::vector<float >& sigmas,
20692076 int64_t seed,
20702077 int batch_count,
@@ -2353,6 +2360,7 @@ sd_image_t* generate_image_internal(sd_ctx_t* sd_ctx,
23532360 eta,
23542361 shifted_timestep,
23552362 sample_method,
2363+ ge_gamma,
23562364 sigmas,
23572365 start_merge_step,
23582366 id_cond,
@@ -2692,6 +2700,7 @@ sd_image_t* generate_image(sd_ctx_t* sd_ctx, const sd_img_gen_params_t* sd_img_g
26922700 width,
26932701 height,
26942702 sample_method,
2703+ sd_img_gen_params->sample_params .ge_gamma ,
26952704 sigmas,
26962705 seed,
26972706 sd_img_gen_params->batch_count ,
@@ -3019,6 +3028,7 @@ SD_API sd_image_t* generate_video(sd_ctx_t* sd_ctx, const sd_vid_gen_params_t* s
30193028 sd_vid_gen_params->high_noise_sample_params .eta ,
30203029 sd_vid_gen_params->high_noise_sample_params .shifted_timestep ,
30213030 sd_vid_gen_params->high_noise_sample_params .sample_method ,
3031+ sd_vid_gen_params->high_noise_sample_params .ge_gamma ,
30223032 high_noise_sigmas,
30233033 -1 ,
30243034 {},
@@ -3055,6 +3065,7 @@ SD_API sd_image_t* generate_video(sd_ctx_t* sd_ctx, const sd_vid_gen_params_t* s
30553065 sd_vid_gen_params->sample_params .eta ,
30563066 sd_vid_gen_params->sample_params .shifted_timestep ,
30573067 sd_vid_gen_params->sample_params .sample_method ,
3068+ sd_vid_gen_params->sample_params .ge_gamma ,
30583069 sigmas,
30593070 -1 ,
30603071 {},
0 commit comments