2023-01-16 16:55:24 +00:00
|
|
|
from diffusers import OnnxStableDiffusionPipeline
|
|
|
|
from os import path
|
|
|
|
|
|
|
|
cfg = 8
|
|
|
|
steps = 22
|
|
|
|
height = 512
|
|
|
|
width = 512
|
|
|
|
|
2023-04-17 04:18:35 +00:00
|
|
|
model = path.join('..', 'models', 'stable-diffusion-onnx-v1-5')
|
2023-01-16 16:55:24 +00:00
|
|
|
prompt = 'an astronaut eating a hamburger'
|
2023-04-17 04:18:35 +00:00
|
|
|
output = path.join('..', 'outputs', 'test.png')
|
2023-01-16 16:55:24 +00:00
|
|
|
|
|
|
|
print('generating test image...')
|
|
|
|
pipe = OnnxStableDiffusionPipeline.from_pretrained(model, provider='DmlExecutionProvider', safety_checker=None)
|
|
|
|
image = pipe(prompt, height, width, num_inference_steps=steps, guidance_scale=cfg).images[0]
|
|
|
|
image.save(output)
|
|
|
|
print('saved test image to %s' % output)
|