Install Stable Diffusion (like Dall-E) Locally for Free
AI image generation from prompts, like those powered by Dall-E or Midjourney, is indeed fascinating, but pricey. You can do it for free by running it locally. Let's see how.
Published on April 20th, 2023
Why is it so expensive?
Let's look at the pricing of Dall-E 2 . They have a credit system, where you buy credits and use them to generate images per prompt. Each time you click on generate, you use up a credit. You get 115 credits for $15, which may not seem too high, but when you consider taxes and the fact that you'll be generating multiple images by tweaking your prompt to get the desired results, your credits will drain FAST.
Now, why is it expensive? Simply because the technology is difficult to build and maintain. Costs of training data, computational power, research and development, infrastructure and maintenance, and continuous improvement keep adding up.
But that doesn't mean you shouldn't dip your toes into this amazing technology, especially when it's possible to do so for free.
Yes, you can set up Stable Diffusion locally, and it will be free, but as you might imagine, it won't be as good as Dall-E or Midjourney. The accuracy comes from the size of the trained data, which these companies have extensive access to. On the other hand, you can train your own data to generate images that are tailored to your specific needs.
What do you need?
What you need is a PC (Windows or Linux) with an Nvidia GPU (preferably a decent one). Unfortunately, Windows with AMD GPU is not supported as discussed Here . Overall, AMD GPU support is very sketchy. For this tutorial, we will be considering a Windows PC with an Nvidia GPU, but the process is quite similar for a Linux machine as well.
Also, make sure you have the latest Nvidia drivers installed.
Let's Get Started
First of all, you need to have Git up and running on your PC. If you don't, just download and install it from Here
Next, clone the Stable Diffusion Web UI repo from Github . This will create a web interface where you can add your prompts and other variables to generate your images.
Next, you need to download a Stable Diffusion trained model. Hugging Face maintains a repository of pre-trained models to perform tasks on different modalities, such as text, vision, and audio. You DO NOT need to create an account. You can search for Stable Diffusion models or directly use the one I used: Stable Diffusion v1.5 . You will need to download the CKPT files. These files will be HUGE. So, put them on download and grab a cup of coffee while you wait.
Once the file has downloaded, you need to copy the file into a directory of the repo you just cloned. Paste it inside the stable-diffusion-webui/models/Stable-diffusion folder.
You then need to have Python installed on your PC. If you haven't already, you can download Python for Windows from Here . When installing Python, make sure to enable the "Add Python 3.xx to PATH" checkbox. Otherwise, your .bat file may not find the Python installation.
After that, go to the root folder of the repo (stable-diffusion-webui), and you will see a webui-user .bat file. Just double-click it to run. This will start running scripts and will take some time. Now is a good time to take a break.
After the installation is complete, you will see a mention of a local URL where the Web UI is running.
All you have to do now is access the URL, and you will see a Web UI where you can provide your prompts to generate your image.
You can now experiment with different sampling methods, sampling steps, batch sizes, and more. Since it's free, you can keep trying without having to worry about running out of credits.
Conclusion
Setting up Stable Diffusion locally is an excellent option if you have the hardware, and with the thousands of pre-trained models, you can keep experimenting without having to worry about the cost. Yes, many of those images will be sub-par, but you can keep generating them until you find something that suits you. On the other hand, it's almost impossible to match the results that Midjourney or Dall-E can generate.
Your local setup will not replace these services, and if you have a commercial requirement where accuracy is important, paying for the service is a better idea. However, if you're looking to try it out as a hobby, or if accuracy and realism are not major concerns, this is a very viable option.
You can also train your own data models with your images to get more personalized results. Check it out
Sign Up 🚀
A Newsletter for
Enthusiasts
â–Ž
This Blog is intended to create content for people who are interested in Tech and everthing around it. My newsletter is designed to expand on tha same! I will notify you where there is new content so that you never miss out!
No Spam. Unsubscribe Anytime.