This sample provides a simple way to load and run Stability AI's text-to-image generation models, Stable Diffusion Turbo & XL Turbo, with our DirectML-backend.
Stable Diffusion Turbo & XL Turbo are distilled versions of SD 2.1 and SDXL 1.0 respectively. Both models are fast generative text-to-image model that can synthesize photorealistic images from a text prompt in a single network evaluation.
Refer to the HuggingFace repositories for SDXL Turbo and SD Turbo for more information.
Once you've set up torch-directml
following our Windows and WSL guidance, install the requirements by running:
pip install -r requirements.txt
To use Stable Diffusion with the text-to-image interface, run:
> python app.py
When you run this code, a local URL will be displayed on the console. Open http://localhost:7860 (or the local URL you see) in a browser to interact with the text-to-image interface.
Within the interface, use the dropdown to switch between SD Turbo and SDXL Turbo. You can also use the slider to set the number of iteration steps (1 to 4) for image generation.
Enter the desired prompt and "Run" to generate an image:
Sample Prompt: A professional photo of a cat eating cake
Two sample images will be generated:
The models are intended for both non-commercial and commercial usage under the following licenses: SDXL Turbo, SD Turbo.
For commercial use, please refer to https://stability.ai/license.