From 1a79969d23a18481619db73eec9f4445d6eaed86 Mon Sep 17 00:00:00 2001 From: Pedro Cuenca Date: Thu, 8 Sep 2022 16:46:24 +0200 Subject: [PATCH] Initial ONNX doc (TODO: Installation) (#426) --- docs/source/optimization/onnx.mdx | 37 ++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/docs/source/optimization/onnx.mdx b/docs/source/optimization/onnx.mdx index 044f3937b9..95fd59c86d 100644 --- a/docs/source/optimization/onnx.mdx +++ b/docs/source/optimization/onnx.mdx @@ -11,22 +11,33 @@ specific language governing permissions and limitations under the License. --> +# How to use the ONNX Runtime for inference -# Quicktour +🤗 Diffusers provides a Stable Diffusion pipeline compatible with the ONNX Runtime. This allows you to run Stable Diffusion on any hardware that supports ONNX (including CPUs), and where an accelerated version of PyTorch is not available. -Start using Diffusers🧨 quickly! -To start, use the [`DiffusionPipeline`] for quick inference and sample generations! +## Installation -``` -pip install diffusers +- TODO + +## Stable Diffusion Inference + +The snippet below demonstrates how to use the ONNX runtime. You need to use `StableDiffusionOnnxPipeline` instead of `StableDiffusionPipeline`. You also need to download the weights from the `onnx` branch of the repository, and indicate the runtime provider you want to use. + +```python +# make sure you're logged in with `huggingface-cli login` +from diffusers import StableDiffusionOnnxPipeline + +pipe = StableDiffusionOnnxPipeline.from_pretrained( + "CompVis/stable-diffusion-v1-4", + revision="onnx", + provider="CUDAExecutionProvider", + use_auth_token=True, +) + +prompt = "a photo of an astronaut riding a horse on mars" +image = pipe(prompt).images[0] ``` -## Main classes - -### Models - -### Schedulers - -### Pipeliens - +## Known Issues +- Generating multiple prompts in a batch seems to take too much memory. While we look into it, you may need to iterate instead of batching.