2023-01-05 15:44:01 +00:00
|
|
|
from diffusers import OnnxStableDiffusionPipeline
|
2023-01-12 03:59:58 +00:00
|
|
|
from os import path
|
2023-01-05 15:44:01 +00:00
|
|
|
|
2023-01-05 16:05:23 +00:00
|
|
|
cfg = 8
|
|
|
|
steps = 22
|
|
|
|
height = 512
|
|
|
|
width = 512
|
2023-01-05 15:44:01 +00:00
|
|
|
|
2023-01-12 03:59:58 +00:00
|
|
|
model = path.join('..', 'models', 'stable-diffusion-onnx-v1-5')
|
|
|
|
prompt = 'an astronaut eating a hamburger'
|
|
|
|
output = path.join('..', 'outputs', 'test.png')
|
|
|
|
|
|
|
|
pipe = OnnxStableDiffusionPipeline.from_pretrained(model, provider='DmlExecutionProvider', safety_checker=None)
|
2023-01-05 15:44:01 +00:00
|
|
|
image = pipe(prompt, height, width, num_inference_steps=steps, guidance_scale=cfg).images[0]
|
2023-01-12 03:59:58 +00:00
|
|
|
image.save(output)
|