diff --git a/examples/common/common.cpp b/examples/common/common.cpp index d2ddca9f6..ceb781430 100644 --- a/examples/common/common.cpp +++ b/examples/common/common.cpp @@ -1008,7 +1008,7 @@ ArgOptions SDGenerationParams::get_options() { &hires_upscaler}, {"", "--extra-sample-args", - "extra sampler/scheduler/guidance args, key=value list. CFG supports guidance_schedule; APG supports apg_eta, apg_momentum, apg_norm_threshold, apg_norm_threshold_smoothing; SLG supports slg_uncond; lcm supports noise_clip_std, noise_scale_start, noise_scale_end; flux supports base_shift, max_shift; ltx2 supports max_shift, base_shift, stretch, terminal; euler_ge supports gamma;; logit_normal supports mu, std, logsnr_min, logsnr_max, resolution_aware", + "extra sampler/scheduler/guidance args, key=value list. CFG supports guidance_schedule; APG supports apg_eta, apg_momentum, apg_norm_threshold, apg_norm_threshold_smoothing; SLG supports slg_uncond; lcm supports noise_clip_std, noise_scale_start, noise_scale_end; flux supports base_shift, max_shift; ltx2 supports max_shift, base_shift, stretch, terminal; euler_ge supports gamma; beta scheduler supports alpha, beta; logit_normal supports mu, std, logsnr_min, logsnr_max, resolution_aware", (int)',', &extra_sample_args}, {"", diff --git a/src/runtime/denoiser.hpp b/src/runtime/denoiser.hpp index 48dd3b51d..67aac538a 100644 --- a/src/runtime/denoiser.hpp +++ b/src/runtime/denoiser.hpp @@ -306,8 +306,33 @@ struct KarrasScheduler : SigmaScheduler { }; struct BetaScheduler : SigmaScheduler { - static constexpr double alpha = 0.6; - static constexpr double beta = 0.6; + double alpha = 0.6; + double beta = 0.6; + + explicit BetaScheduler(const char* extra_sample_args = nullptr) { + parse_extra_sample_args(extra_sample_args); + LOG_DEBUG("Beta scheduler: alpha=%.4f, beta=%.4f", alpha, beta); + } + + void parse_extra_sample_args(const char* extra_sample_args) { + for (const auto& [key, value] : parse_key_value_args(extra_sample_args, "beta scheduler arg")) { + if (key == "alpha") { + float parsed; + if (!parse_strict_float(value, parsed) || parsed <= 0.0) { + LOG_WARN("ignoring invalid beta scheduler arg '%s=%s'", key.c_str(), value.c_str()); + } else { + alpha = static_cast(parsed); + } + } else if (key == "beta") { + float parsed; + if (!parse_strict_float(value, parsed) || parsed <= 0.0) { + LOG_WARN("ignoring invalid beta scheduler arg '%s=%s'", key.c_str(), value.c_str()); + } else { + beta = static_cast(parsed); + } + } + } + } static double log_beta(double a, double b) { return std::lgamma(a) + std::lgamma(b) - std::lgamma(a + b); @@ -1032,7 +1057,7 @@ struct Denoiser { break; case BETA_SCHEDULER: LOG_INFO("get_sigmas with Beta scheduler"); - scheduler = std::make_shared(); + scheduler = std::make_shared(extra_sample_args); break; case EXPONENTIAL_SCHEDULER: LOG_INFO("get_sigmas exponential scheduler");