Spaces:
Runtime error
Runtime error
| <!--Copyright 2023 The HuggingFace Team. All rights reserved. | |
| Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | |
| the License. You may obtain a copy of the License at | |
| http://www.apache.org/licenses/LICENSE-2.0 | |
| Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | |
| an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | |
| specific language governing permissions and limitations under the License. | |
| --> | |
| # How to use OpenVINO for inference | |
| π€ [Optimum](https://github.com/huggingface/optimum-intel) provides a Stable Diffusion pipeline compatible with OpenVINO. You can now easily perform inference with OpenVINO Runtime on a variety of Intel processors ([see](https://docs.openvino.ai/latest/openvino_docs_OV_UG_supported_plugins_Supported_Devices.html) the full list of supported devices). | |
| ## Installation | |
| Install π€ Optimum Intel with the following command: | |
| ``` | |
| pip install optimum["openvino"] | |
| ``` | |
| ## Stable Diffusion Inference | |
| To load an OpenVINO model and run inference with OpenVINO Runtime, you need to replace `StableDiffusionPipeline` with `OVStableDiffusionPipeline`. In case you want to load a PyTorch model and convert it to the OpenVINO format on-the-fly, you can set `export=True`. | |
| ```python | |
| from optimum.intel.openvino import OVStableDiffusionPipeline | |
| model_id = "runwayml/stable-diffusion-v1-5" | |
| pipe = OVStableDiffusionPipeline.from_pretrained(model_id, export=True) | |
| prompt = "a photo of an astronaut riding a horse on mars" | |
| images = pipe(prompt).images[0] | |
| ``` | |
| You can find more examples (such as static reshaping and model compilation) in [optimum documentation](https://huggingface.co/docs/optimum/intel/inference#export-and-inference-of-stable-diffusion-models). | |