How to deploy SDXL Turbo?

How to deploy SDXL Turbo?

Month ago, Stability AI released an open source model SDXL Turbo. Like the LCM, it only takes 1~4 steps to complete image generation, most of the time it finished almost instantly, while the image quality is still good. If SDXL Turbo is deployed locally, you can realize real-time generation of AI images on your own computer for free.

Today we would like to introduce several ways to deploy and use SDXL Turbo models, including using Stable Diffusion WebUI, ComfyUI and Fooocus. After testing, the image generation speed can be increased by 6~10 times.

Table of Contents

  1. Deploy in SD WebUI
  2. Deploy in Fooocus
  3. Deploy in ComfyUI
  4. Use LCM-LoRA to implement real-time generation in ComfyUI

Deploy in SD WebUI

A master on Civitai merged LCM and SDXL Turbo into a new model, which can be used to generate images in real time after being installed in SD WebUI.

First we need to update SD WebUI to the latest version, than download the Realities EdgeXLLCM_TURBOXL large model and install it into the models/stable diffusion folder in the root directory of WebUI. There is also an sdxl vae file in the source package, which installed in the models/VAE folder in the root directory.

After entering the WebUI, set the model of RealitiesEdgeXLLCM_TURBOXL, VAE: sdxl vae. Adjust the clip skip value to 1, and set the number of sampling steps between 4 and 10.

Then set the CFG scale parameter between 1 and 2. The size of the image set to 1024px. The sampler can be Euler A or LCM. It has been tested that it only take 8 seconds to generate a 1024*1024px image on an 8G 4060, which is 8 times faster than SDXL 1.0, and maintain the high image quality at the same time.

This large model can also be used with SDXL Controlnet. The picture below is a 1024*1024 px image generated by using the sai_xl_canny control model. The generation time is 13 seconds, which is 6 or 7 times faster than the generation speed of the SDXL 1.0 Base model.

Deploy in Fooocus

Fooocus is a very light and simple tool for AI painting. It combines advantages of Midjourney and WebUI, and focus on SDXL models. The SDXL Turbo can also be used in Fooocus:

  1. Download and install the sd_xl_turbo_1.0_fp16 model officially released by Stabilty AI, and install it into the Fooocus\models\checkpoints folder in the root directory.
  2. Enter the Fooocus operation interface, check the Advanced option, and make the following settings in the option bar on the right.
  3. In the Model section, select the large model sd_xl_turbo_1.0_fp16; select None for refiner.
  4. In the Advanced area, set the Guidance Scale parameter to between 1-4, check Developer Debug Mode, and in the pop-up options, change Sampler to euler_ancestral; change the Forced Overwrite of Sampling Step parameter to 1; change Forced Overwrite of Generating Width and Height parameters are modified to 512.

After the settings are completed, you can click to generate images. After testing, it only takes 2 seconds to generate an image, but the quality has also dropped slightly. In fact, according to Fooocus's usual style, the above setting steps are actually quite complicated. This is because SDXL Turbo has just been released, and the author of Fooocus is currently busy and has not made the corresponding compatibility settings. We can also wait for the later updates of Fooocus, which should be more convenient to use.

Deploy in ComfyUI

After deploying SDXL Turbo in ComfyUI, it only takes 0.3 seconds to generate an image. The generated image will change in real time according to the input prompt words, achieving true "real-time generation". The specific operation method is as follows:

  1. Download the sd_xl_turbo_1.0_fp16 model officially released by Stabilty AI and install it into the model root directory of ComfyUI (if the model is shared with WebUI, put it in the model folder of the WebUI root directory). ComfyUI needs to be updated to the latest version.
  2. Enter the ComfyUI deployment live build workflow. You can click the image below to manually arrange it automatically, or directly download the flow node file from the resource package at the end of the article. The numerical settings in the workflow still need to be noted.
  3. You also need to pay attention to setting parameters: the number of sampling steps can be set to 1; the CFG Scale parameter is between 1-2; select LCM for the sampler, and the image size can only be 512*512 at present. If it is too high, the picture will collapse (it is currently A small flaw, which should be fixed by the official later).

Enable the Auto queue automatic generation option in the right toolbar; this way the workflow will start automatically, and you can experience the real-time generation effect by just entering the prompt word.

Use LCM-LoRA to implement real-time generation in ComfyUI

With the screen capture plug-in mixlab nodes, we can also use the LCM-LoRA plug-in to achieve another way of real-time image generation in ComfyUI. Compared with SDXL Turbo, the advantage of LCM-LoRA is that it can be used with most SD1.5 and SDXL large models, the generated image styles are more diverse, and the size can be set freely.

The above are the relevant tutorials on deploying SDXL turbo models in Stable Diffusion WebUI, ComfyUI and Fooocus and realizing real-time image generation. Let's try it out.