mirror of
https://github.com/huggingface/candle.git
synced 2025-06-18 11:37:11 +00:00
Add a --seed argument to the stable-diffusion example. (#1812)
* Add a --seed argument to the stable-diffusion example. * Make the case when no seed is specified, that it will not be set, but use the engine's default. This will make the CPU engine work again when no --seed is given, and will cause a bailout when a seed is there, as the engine does not currently support it. --------- Co-authored-by: niklas <niklas@appli.se>
This commit is contained in:
@ -96,6 +96,10 @@ struct Args {
|
|||||||
/// information.
|
/// information.
|
||||||
#[arg(long, default_value_t = 0.8)]
|
#[arg(long, default_value_t = 0.8)]
|
||||||
img2img_strength: f64,
|
img2img_strength: f64,
|
||||||
|
|
||||||
|
/// The seed to use when generating random samples.
|
||||||
|
#[arg(long)]
|
||||||
|
seed: Option<u64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, clap::ValueEnum, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, clap::ValueEnum, PartialEq, Eq)]
|
||||||
@ -374,6 +378,7 @@ fn run(args: Args) -> Result<()> {
|
|||||||
use_flash_attn,
|
use_flash_attn,
|
||||||
img2img,
|
img2img,
|
||||||
img2img_strength,
|
img2img_strength,
|
||||||
|
seed,
|
||||||
..
|
..
|
||||||
} = args;
|
} = args;
|
||||||
|
|
||||||
@ -427,6 +432,9 @@ fn run(args: Args) -> Result<()> {
|
|||||||
|
|
||||||
let scheduler = sd_config.build_scheduler(n_steps)?;
|
let scheduler = sd_config.build_scheduler(n_steps)?;
|
||||||
let device = candle_examples::device(cpu)?;
|
let device = candle_examples::device(cpu)?;
|
||||||
|
if let Some(seed) = seed {
|
||||||
|
device.set_seed(seed)?;
|
||||||
|
}
|
||||||
let use_guide_scale = guidance_scale > 1.0;
|
let use_guide_scale = guidance_scale > 1.0;
|
||||||
|
|
||||||
let which = match sd_version {
|
let which = match sd_version {
|
||||||
|
Reference in New Issue
Block a user