@@ -54,6 +54,7 @@ const char* sampling_methods_str[] = {
5454 " DDIM \" trailing\" " ,
5555 " TCD" ,
5656 " Euler A" ,
57+ " Gradient Estimation" ,
5758};
5859
5960/* ================================================== Helper Functions ================================================*/
@@ -1123,6 +1124,7 @@ class StableDiffusionGGML {
11231124 float eta,
11241125 int shifted_timestep,
11251126 sample_method_t method,
1127+ float ge_gamma,
11261128 const std::vector<float >& sigmas,
11271129 int start_merge_step,
11281130 SDCondition id_cond,
@@ -1353,7 +1355,7 @@ class StableDiffusionGGML {
13531355 return denoised;
13541356 };
13551357
1356- sample_k_diffusion (method, denoise, work_ctx, x, sigmas, rng, eta);
1358+ sample_k_diffusion (method, denoise, work_ctx, x, sigmas, rng, eta, ge_gamma );
13571359
13581360 if (inverse_noise_scaling) {
13591361 x = denoiser->inverse_noise_scaling (sigmas[sigmas.size () - 1 ], x);
@@ -1782,6 +1784,7 @@ const char* sample_method_to_str[] = {
17821784 " ddim_trailing" ,
17831785 " tcd" ,
17841786 " euler_a" ,
1787+ " gradient_estimation" ,
17851788};
17861789
17871790const char * sd_sample_method_name (enum sample_method_t sample_method) {
@@ -1953,6 +1956,7 @@ void sd_sample_params_init(sd_sample_params_t* sample_params) {
19531956 sample_params->scheduler = DEFAULT;
19541957 sample_params->sample_method = SAMPLE_METHOD_DEFAULT;
19551958 sample_params->sample_steps = 20 ;
1959+ sample_params->ge_gamma = 2 .0f ;
19561960}
19571961
19581962char * sd_sample_params_to_str (const sd_sample_params_t * sample_params) {
@@ -1973,6 +1977,7 @@ char* sd_sample_params_to_str(const sd_sample_params_t* sample_params) {
19731977 " sample_method: %s, "
19741978 " sample_steps: %d, "
19751979 " eta: %.2f, "
1980+ " ge_gamma: %.2f, "
19761981 " shifted_timestep: %d)" ,
19771982 sample_params->guidance .txt_cfg ,
19781983 std::isfinite (sample_params->guidance .img_cfg )
@@ -1987,6 +1992,7 @@ char* sd_sample_params_to_str(const sd_sample_params_t* sample_params) {
19871992 sd_sample_method_name (sample_params->sample_method ),
19881993 sample_params->sample_steps ,
19891994 sample_params->eta ,
1995+ sample_params->ge_gamma ,
19901996 sample_params->shifted_timestep );
19911997
19921998 return buf;
@@ -2122,6 +2128,7 @@ sd_image_t* generate_image_internal(sd_ctx_t* sd_ctx,
21222128 int width,
21232129 int height,
21242130 enum sample_method_t sample_method,
2131+ float ge_gamma,
21252132 const std::vector<float >& sigmas,
21262133 int64_t seed,
21272134 int batch_count,
@@ -2403,6 +2410,7 @@ sd_image_t* generate_image_internal(sd_ctx_t* sd_ctx,
24032410 eta,
24042411 shifted_timestep,
24052412 sample_method,
2413+ ge_gamma,
24062414 sigmas,
24072415 start_merge_step,
24082416 id_cond,
@@ -2711,6 +2719,7 @@ sd_image_t* generate_image(sd_ctx_t* sd_ctx, const sd_img_gen_params_t* sd_img_g
27112719 width,
27122720 height,
27132721 sample_method,
2722+ sd_img_gen_params->sample_params .ge_gamma ,
27142723 sigmas,
27152724 seed,
27162725 sd_img_gen_params->batch_count ,
@@ -3034,6 +3043,7 @@ SD_API sd_image_t* generate_video(sd_ctx_t* sd_ctx, const sd_vid_gen_params_t* s
30343043 sd_vid_gen_params->high_noise_sample_params .eta ,
30353044 sd_vid_gen_params->high_noise_sample_params .shifted_timestep ,
30363045 sd_vid_gen_params->high_noise_sample_params .sample_method ,
3046+ sd_vid_gen_params->high_noise_sample_params .ge_gamma ,
30373047 high_noise_sigmas,
30383048 -1 ,
30393049 {},
@@ -3070,6 +3080,7 @@ SD_API sd_image_t* generate_video(sd_ctx_t* sd_ctx, const sd_vid_gen_params_t* s
30703080 sd_vid_gen_params->sample_params .eta ,
30713081 sd_vid_gen_params->sample_params .shifted_timestep ,
30723082 sd_vid_gen_params->sample_params .sample_method ,
3083+ sd_vid_gen_params->sample_params .ge_gamma ,
30733084 sigmas,
30743085 -1 ,
30753086 {},
0 commit comments