Skip to content

Latest commit

 

History

History
 
 

stable-diffusion-python-onnx

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Stable Diffusion inference with Python

This directory illustrates how to run Stable Diffusion through MAX Engine. Specifically, this example extracts StableDiffusion-1.5 from Hugging Face and executes it via the MAX Engine Python API.

Quickstart

Magic instructions

If you have magic, you can run the following command:

magic run bash run.sh

Conda instructions

Create a Conda environment, activate that environment, and install the requirements:

# Create a Conda environment if you don't have one
conda create -n max-repo
# Update the environment with the environment.yml file
conda env update -n max-repo -f environment.yml --prune
# Run the example
conda run -n max-repo --live-stream bash run.sh

Custom Images

Getting started with your own creative prompts is as simple as:

./text_to_image.py --prompt "my image description" -o my-image.png

But of course, there are some additional settings that can be tweaked for more fine-grained control over image output. See ./text_to_image.py --help for details.

Files

  • download-model.py: Downloads runwayml/stable-diffusion-v1-5 and exports it as ONNX.

  • text_to_image.py: Example program that runs full stable-diffusion pipeline through MAX Engine in order to generate images from the given prompt.