Buckets:
| # OpenVINO | |
| 🤗 [Optimum](https://github.com/huggingface/optimum-intel) ofrece pipelines de Stable Diffusion compatibles con OpenVINO para realizar inferencia en una variedad de procesadores de Intel (consulte la [lista completa](https://docs.openvino.ai/latest/openvino_docs_OV_UG_supported_plugins_Supported_Devices.html) de dispositivos compatibles). | |
| Deberás instalar 🤗 Optimum Intel con la opción `--upgrade-strategy eager` para asegurarte de que [`optimum-intel`](https://github.com/huggingface/optimum-intel) esté usando la última versión: | |
| ```bash | |
| pip install --upgrade-strategy eager optimum["openvino"] | |
| ``` | |
| Esta guía te mostrará cómo usar los pipelines de Stable Diffusion y Stable Diffusion XL (SDXL) con OpenVINO. | |
| ## Stable Diffusion | |
| Para cargar y ejecutar la inferencia, use `OVStableDiffusionPipeline`. Si desea cargar un modelo de PyTorch y convertirlo al formato OpenVINO sobre la marcha, establezca `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 aún más la inferencia, redimensiona el modelo de forma estática. Si cambias algún parámetro, como la altura o el ancho de las salidas, deberás redimensionar el modelo de forma estática de nuevo. | |
| ```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] | |
| ``` | |
| Puedes encontrar más ejemplos en la [documentación](https://huggingface.co/docs/optimum/intel/inference#stable-diffusion) de 🤗 Optimum, y Stable Diffusion es compatible con texto a imagen, imagen a imagen e inpainting. | |
| ## Stable Diffusion XL | |
| Para cargar y ejecutar inferencia con SDXL, use `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 aún más la inferencia, [redimensiona de forma estática](#stable-diffusion) el modelo, como se muestra en la sección de Stable Diffusion. | |
| Puedes encontrar más ejemplos en la [documentación](https://huggingface.co/docs/optimum/intel/inference#stable-diffusion-xl) de 🤗 Optimum, y la ejecución de SDXL en OpenVINO está soportada para texto a imagen e imagen a imagen. | |
Xet Storage Details
- Size:
- 2.92 kB
- Xet hash:
- e420683500f0c7b4ac0ee74162f8ff1025e2ea72d07b49a266f833d11e1e7b9e
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.