0

Image generation with Torch.FX Stable Diffusion v3 and OpenVINO

Stable Diffusion V3 is next generation of latent diffusion image Stable Diffusion models family that outperforms state-of-the-art text-to-image generation systems in typography and prompt adherence, based on human preference evaluations. In comparison with previous versions, it based on Multimodal D

Example · مثال

Content

Image generation with Torch.FX Stable Diffusion v3 and OpenVINO

Stable Diffusion V3 is next generation of latent diffusion image Stable Diffusion models family that outperforms state-of-the-art text-to-image generation systems in typography and prompt adherence, based on human preference evaluations. In comparison with previous versions, it based on Multimodal Diffusion Transformer (MMDiT) text-to-image model that features greatly improved performance in image quality, typography, complex prompt understanding, and resource-efficiency.

!mmdit.png

More details about model can be found in model card, research paper and Stability.AI blog post. In this tutorial, we will consider how to convert Stable Diffusion v3 for running with OpenVINO. An additional part showcase the capabilities of NNCF and torch compile with OpenVINO backend in successfully optimizing with the torch FX model representation.

If you want to run another Stable Diffusion versions, please check our other notebooks:

  • [Stable Diffusion](../stable-diffusion-text-to-image)
  • [Stable Diffusion v3](../stable-diffusion-v3)
  • [Stable Diffusion XL](../stable-diffusion-xl)
  • [LCM Stable Diffusion](../latent-consistency-models-image-generation)

The image below illustrates the provided generated image example.

!text2img_example.png

Note: Some demonstrated models can require at least 32GB RAM for conversion and running.

Notebook Contents

This folder contains notebooks that demonstrate the use of the Stable Diffusion v3 model with OpenVINO and Torch FX representations.

The Torch FX tutorial consists of the following steps:

  • Install prerequisites
  • Collect Pytorch model pipeline
  • Convert model to Torch FX representation format and compress weights using NNCF
  • Compile the model using torch.compile with backend openvino
  • Run Text-to-Image generation
  • Compare the results of the original and optimized pipelines
  • Launch interactive demo

Installation Instructions

This is a self-contained example that relies solely on its own code.</br> We recommend running the notebook in a virtual environment. You only need a Jupyter server to start. For details, please refer to [Installation Guide](../../README.md).

Source and license

Source
Intel OpenVINO Notebooks
Original
openvinotoolkit/openvino_notebooks/notebooks/stable-diffusion-v3-torch-fx
License
Apache-2.0