Buckets:
| # OpenVINO | |
| 🤗 [Optimum](https://github.com/huggingface/optimum-intel) fornece pipelines de Stable Diffusion compatíveis com OpenVINO para realizar inferência em uma variedade de processadores Intel (veja a [lista completa](https://docs.openvino.ai/latest/openvino_docs_OV_UG_supported_plugins_Supported_Devices.html) de dispositivos suportados). | |
| Você precisará instalar o 🤗 Optimum Intel com a opção `--upgrade-strategy eager` para garantir que o [`optimum-intel`](https://github.com/huggingface/optimum-intel) esteja usando a versão mais recente: | |
| ```bash | |
| pip install --upgrade-strategy eager optimum["openvino"] | |
| ``` | |
| Este guia mostrará como usar os pipelines Stable Diffusion e Stable Diffusion XL (SDXL) com OpenVINO. | |
| ## Stable Diffusion | |
| Para carregar e executar inferência, use o `OVStableDiffusionPipeline`. Se você quiser carregar um modelo do PyTorch e convertê-lo para o formato OpenVINO em tempo de execução, defina `export=True`: | |
| ```python | |
| from optimum.intel import OVStableDiffusionPipeline | |
| model_id = "stable-diffusion-v1-5/stable-diffusion-v1-5" | |
| pipeline = OVStableDiffusionPipeline.from_pretrained(model_id, export=True) | |
| prompt = "sailing ship in storm by Rembrandt" | |
| image = pipeline(prompt).images[0] | |
| # Don't forget to save the exported model | |
| pipeline.save_pretrained("openvino-sd-v1-5") | |
| ``` | |
| Para acelerar ainda mais a inferência, redimensione o modelo de forma estática. Se você alterar parâmetros, como a altura ou a largura das saídas, será necessário redimensionar o modelo novamente de forma estática. | |
| ```python | |
| # Define the shapes related to the inputs and desired outputs | |
| batch_size, num_images, height, width = 1, 1, 512, 512 | |
| # Statically reshape the model | |
| pipeline.reshape(batch_size, height, width, num_images) | |
| # Compile the model before inference | |
| pipeline.compile() | |
| image = pipeline( | |
| prompt, | |
| height=height, | |
| width=width, | |
| num_images_per_prompt=num_images, | |
| ).images[0] | |
| ``` | |
| Você pode encontrar mais exemplos na [documentação](https://huggingface.co/docs/optimum/intel/inference#stable-diffusion) do 🤗 Optimum, e o Stable Diffusion é suportado para texto-para-imagem, imagem-para-imagem e inpainting. | |
| ## Stable Diffusion XL | |
| Para carregar e executar inferência com SDXL, use o `OVStableDiffusionXLPipeline`: | |
| ```python | |
| from optimum.intel import OVStableDiffusionXLPipeline | |
| model_id = "stabilityai/stable-diffusion-xl-base-1.0" | |
| pipeline = OVStableDiffusionXLPipeline.from_pretrained(model_id) | |
| prompt = "sailing ship in storm by Rembrandt" | |
| image = pipeline(prompt).images[0] | |
| ``` | |
| Para acelerar ainda mais a inferência, [redimensione estaticamente](#stable-diffusion) o modelo, conforme mostrado na seção Stable Diffusion. | |
| Você pode encontrar mais exemplos na [documentação](https://huggingface.co/docs/optimum/intel/inference#stable-diffusion-xl) do 🤗 Optimum, e a execução do SDXL no OpenVINO é suportada para texto-para-imagem e imagem-para-imagem. | |
Xet Storage Details
- Size:
- 2.95 kB
- Xet hash:
- aa01926eb5ab30a13b75c9df356c311a73aee74cc16ef0b0f6ebcf42c10fdd18
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.