mirror of
https://github.com/huggingface/candle.git
synced 2025-06-20 20:09:50 +00:00
Stable Diffusion Turbo Support (#1395)
* Add support for SD Turbo * Set Leading as default in euler_ancestral discrete * Use the appropriate default values for n_steps and guidance_scale. --------- Co-authored-by: Laurent <laurent.mazare@gmail.com>
This commit is contained in:
@ -3,9 +3,25 @@
|
||||
//!
|
||||
//! Noise schedulers can be used to set the trade-off between
|
||||
//! inference speed and quality.
|
||||
|
||||
use candle::{Result, Tensor};
|
||||
|
||||
pub trait SchedulerConfig: std::fmt::Debug {
|
||||
fn build(&self, inference_steps: usize) -> Result<Box<dyn Scheduler>>;
|
||||
}
|
||||
|
||||
/// This trait represents a scheduler for the diffusion process.
|
||||
pub trait Scheduler {
|
||||
fn timesteps(&self) -> &[usize];
|
||||
|
||||
fn add_noise(&self, original: &Tensor, noise: Tensor, timestep: usize) -> Result<Tensor>;
|
||||
|
||||
fn init_noise_sigma(&self) -> f64;
|
||||
|
||||
fn scale_model_input(&self, sample: Tensor, _timestep: usize) -> Result<Tensor>;
|
||||
|
||||
fn step(&self, model_output: &Tensor, timestep: usize, sample: &Tensor) -> Result<Tensor>;
|
||||
}
|
||||
|
||||
/// This represents how beta ranges from its minimum value to the maximum
|
||||
/// during training.
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
|
Reference in New Issue
Block a user