Created
March 5, 2023 21:59
-
-
Save sonicrules1234/6e435a1caf2290c9eec768e2793a36eb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use pyke_diffusers::{ | |
DiffusionDeviceControl, EulerDiscreteScheduler, OrtEnvironment, SchedulerOptimizedDefaults, | |
StableDiffusionOptions, StableDiffusionPipeline, StableDiffusionTxt2ImgOptions, | |
}; | |
fn main() { | |
let environment = OrtEnvironment::default().into_arc(); | |
let mut scheduler = EulerDiscreteScheduler::stable_diffusion_v1_optimized_default().unwrap(); | |
println!("Making pipeline..."); | |
let pipeline = StableDiffusionPipeline::new( | |
&environment, | |
"./wd_1_3/", | |
StableDiffusionOptions { | |
devices: DiffusionDeviceControl { | |
vae_encoder: pyke_diffusers::DiffusionDevice::ROCm(0), | |
vae_decoder: pyke_diffusers::DiffusionDevice::ROCm(0), | |
text_encoder: pyke_diffusers::DiffusionDevice::ROCm(0), | |
unet: pyke_diffusers::DiffusionDevice::ROCm(0), | |
..Default::default() | |
}, | |
..Default::default() | |
}, | |
) | |
.unwrap(); | |
println!("Made pipeline."); | |
println!("Making image..."); | |
let imgs = pipeline | |
.txt2img( | |
"photo of a red fox", | |
&mut scheduler, | |
StableDiffusionTxt2ImgOptions { | |
steps: 30, | |
..Default::default() | |
}, | |
) | |
.unwrap(); | |
imgs[0].clone().into_rgb8().save("result.png").unwrap(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment