Views
No views yet
pip install "optimum-intel[openvino, diffusers]". This installs all the necessary dependencies,
including Transformers and OpenVINO. For more detailed steps, please see this installation guide.1from optimum.intel.openvino import OVStableDiffusionPipeline
2
3stable_diffusion = OVStableDiffusionPipeline.from_pretrained("helenai/wavymulder-portraitplus-ov")
4images = stable_diffusion("a random image").imagesstable_diffusion.to("GPU") before stable_diffusion.compile() in the example below.
Model loading will take some time the first time, but will be faster after that, because the model will be cached. On GPU, for stable
diffusion only static shapes are supported at the moment.1from optimum.intel.openvino.modeling_diffusion import OVStableDiffusionPipeline
2
3batch_size = 1
4num_images_per_prompt = 1
5height = 256
6width = 256
7
8# load the model and reshape to static shapes for faster inference
9model_id = "helenai/wavymulder-portraitplus-ov"
10stable_diffusion = OVStableDiffusionPipeline.from_pretrained(model_id, compile=False)
11stable_diffusion.reshape( batch_size=batch_size, height=height, width=width, num_images_per_prompt=num_images_per_prompt)
12stable_diffusion.compile()
13
14# generate image!
15prompt = "a random image"
16images = stable_diffusion(prompt, height=height, width=width, num_images_per_prompt=num_images_per_prompt).images
17images[0].save("result.png")