Wondering how to run Stable Diffusion? We have got you covered.
Stable Diffusion is one of the best AI image generators that allows users to create stunning art from their text input - just like the DALL-E 2 and Imagen. On August 22, the Stable Diffusion was released publicly, which means now anyone can use them to generate images.
In the past, AI text-to-image models were not accessible to everyone (Midjourney AI, for instance). Only a few lucky individuals who managed to get beta access have been able to generate images. That's no longer the case.
With Stable Diffusion, anyone can generate images with their own text. We are going to show you how it is done. Let's get down to business!
How To Run Stable Diffusion
One of the easiest ways to run Stable Diffusion is by using the DreamStudio web app. DreamStudio Lite is a product of Stability AI - the same company that created Stable Diffusion. Using the DreamStudio interface, you can create any image you can "dream."
To run Stable Diffusion via DreamStudio:
- Navigate to the DreamStudio site.
- Create an account.
- Once you are in, input your text into the textbox at the bottom, next to the Dream button.
- Click on the Dream button once you have given your input to create the image. Your image will be generated within 5 seconds.
That's it! You can download the image you created by clicking the download icon in the middle of the generated image. There are a couple of settings on the right side that you can tweak, like the resolution of the image or the number of images to be generated.
Users get 200 credits when they sign up for DreamStudio. With that, you can generate 200 512x512 resolution free images with the DreamStudio web app. After that, you need to pay £1 ($1.18) to purchase 100 generations.
NSFW filters are applied to the images generated by this tool, so you will get a fully blurred image if you try to create images that are considered NSFW.
Run Stable Diffusion using Colab
Alternatively, you can access Stable Diffusion non-locally via Google Colab.
However, the caveat is that you need a Colab Pro account since the free version of Colab has slightly too little VRAM to generate images. It is worth noting that this tool also comes with its own NSFW filter.
How To Run Stable Diffusion Locally
If you have a GPU with at least 6GB of VRAM, you can run Stable Diffusion locally on your PC. The steps may seem a bit complicated, but it's actually easy to follow and you can get it done with a little effort. Here is what you need to do.
Downloading and setting up Stable Diffusion
- Create a Huggingface account. Go here, click Sign Up (top bar)and create an account. Once done, go here.
- Go to this link and select the Files and versions tab. Download the sd-v1-4.ckpt file. The file is more than 4GB, so while you wait, go get a coffee or watch the latest TikTok trends.
- Download the cloned repo and unzip it. To download, click on Code (green button) and select Download ZIP.
- Open the unzipped file and navigate to stable-diffusion-main/models/ldm. Create a folder called "stable-diffusion-v1" there. Rename sd-v1-4.ckpt file to "model.ckpt", and copy it into that folder (stable-diffusion-v1) you've made.
- Open the file environment.yaml in Notepad, and after the line saying "dependencies:", add "- git" The "-" should be lined up with the ones in the following lines.
- Go here and download Miniconda 3 Windows.
- Install Miniconda for all users. Uncheck "Register Miniconda as the system Python 3.9".
Generating the images
- Open Anaconda Prompt (Miniconda 3). Type "cd" and then drag the folder into the Anaconda prompt console.
- Run the following command: "conda env create -f environment.yaml". Make sure you are in the stable-diffusion-main folder before doing this.
- Run the following command: "conda activate ldm".
- To generate an image run the following command: "python scripts/txt2img.py --prompt "Elon Musk as an alien" --H 512 --W 512 --seed 27 --n_iter 2 --ddim_steps 50".
- For custom images, replace the Elon Musk statement with the image you wish to create.
That's how you create an image. A bit of work, right?
To create a new image you have to repeat steps 2 through 4. You can adjust the height and width of the image by changing the numbers next to H and W. However, to get higher resolution images, you will need 10 or 12 GB of VRAM.
In case you get an out-of-ram error, run the following command in step 10: "python optimizedSD/optimized_txt2img.py --prompt "Elon Musk as an alien" --H 512 --W 512 --seed 27 --n_iter 1 --ddim_steps 50".
Go ahead! Turn your imagination into art.
Since you are here, have a look at how to use Midjourney AI - another image generator AI like the Stable Fusion.