Text to image: running Stable diffusion on AMD GPU/Windows. Step by step guide



Text to image: running Stable diffusion on AMD GPU/Windows. Step by step guide

Text to image: running Stable diffusion on AMD GPU/Windows. Step by step guide

Thank you for watching! please consider to subscribe. thank you! 👉ⓢⓤⓑⓢⓒⓡⓘⓑⓔ
👉🏽Update: 3/21/23: due to Pytorch upgrade, if you have issues, please install 1.13 pytorch by:
pip install torch==1.13.1+cpu torchvision==0.14.1+cpu torchaudio==0.13.1 –extra-index-url https://download.pytorch.org/whl/cpu
👉🏽Update: 1/15/23. For improvement, please check it out https://youtu.be/LfpnmEbl788
👉🏽Update: Mar 23. Please join the discord server at https://discord.gg/SgmBydQ2Mn where you can ask questions and also try out my recently developed free chatgpt bot and stable diffusion bot!
Follow up video of a web UI is shown in https://youtu.be/K6TWilbjSmc
Image to image generation UI was also created in https://youtu.be/GAnabn6qJLA
Step by step guide to run Stable diffusion AI text to image on AMD GPU and Windows.
My GPU model: 6700xt. Other modern AMD GPU should also work (I tested 5700XT in https://youtu.be/IRw4qdt3jyQ) .
For model downloads and converting please see: https://youtu.be/mYOuMqMWUWU and https://youtu.be/OpD2tKJz3vI
Some download links are included below. (based on comments, also added detailed commands)
1:20 Install Git
3:13 Install Python (miniconda)
5:43 Conda virtual environment
conda create –name sd39new python=3.9 -y
conda activate sd39new
8:30 Install python packages.
** added. pytorch version 1.13.1
pip install torch==1.13.1+cpu torchvision==0.14.1+cpu torchaudio==0.13.1 –extra-index-url https://download.pytorch.org/whl/cpu
pip install diffusers==0.10.2
pip install transformers==4.25.1
pip install onnxruntime==1.13.1
pip install onnx==1.13.0
11:47 DirectML package install
https://aiinfra.visualstudio.com/PublicPackages/_artifacts/feed/ORT-Nightly/PyPI/ort-nightly-directml/overview/1.13.0.dev20220908001
pip install ort_nightly_directml-1.13.0.dev20220908001-cp39-cp39-win_amd64.whl (may need to adjust the filename if file updated, check the file name for your downloaded file)
15:00 Convert stable diffusion model to onnx (stable diffusion model needs to be downloaded, e.g. from https://huggingface.co/CompVis/stable-diffusion-v1-4 see https://youtu.be/mYOuMqMWUWU for more details)
The python script can be downloaded from here https://github.com/huggingface/diffusers/blob/main/scripts/convert_stable_diffusion_checkpoint_to_onnx.py
python convert_stable_diffusion_checkpoint_to_onnx.py –model_path=”CompVis/stable-diffusion-v1-4″ –output_path=”./stable_diffusion_onnx”
20:08 Run the model to turn text into image!
run following in python console:
from diffusers import StableDiffusionOnnxPipeline
pipe = StableDiffusionOnnxPipeline.from_pretrained(“./stable_diffusion_onnx”, provider=”DmlExecutionProvider”)
prompt = “a photo of an astronaut riding a horse on mars”
image = pipe(prompt).images[0]
image.save(“astronaut_rides_horse.png”)
27:30 final output (example)

Comments are closed.