Generating AI Images from your own PC
Tags: generativeai, beginners, tutorial, ai
Published: 2023-10-02 17:39:39

---
title: Generating AI Images from your own PC
published: true
description: Want to use AI to generate images on your own computer? This is a step-by-step guide that will have you generating images in minutes.
tags: generativeai, beginners, tutorial, ai
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rvdc8gskcylc94cpw9lm.jpg
canonical_url: https://www.jeremymorgan.com/tutorials/generative-ai/how-to-create-ai-images/
#published_at: 2023-10-02 17:19 +0000
---

You want to create AI-generated images. You've probably signed up with Dall-E, or Bing, or Midjourney. You've created some cool stuff. If you're reading this, you want to generate those images on your *own computer*. There is no website or discord to deal with. Running locally on your machine. 

Why would anyone do this? Here are a few reasons:

- It's educational 
- You can generate as many images as you want
- It's free

With this tutorial's help, you can generate images with AI on your own computer with [Stable Diffusion](https://github.com/Stability-AI/stablediffusion).

Let's get started. 

## Step 1: Requirements 

There are some requirements for doing this on your own machine. It must have: 

### Hardware: 

- A modern AMD or Intel CPU 
- 16 Gigabytes of RAM 
- SATA or NVMe solid state drive 
- NVidia GeForce GPU with at least 8 gigabytes of GDDR6 RAM

### Software: 

- You must have Python installed ([How to install Python in Windows 11](https://www.pythonhelp.org/learn/introduction/setting-up-development-environment-windows/)). 
- You can use Anaconda if you want ([How to install Anaconda in Windows 11](https://www.jeremymorgan.com/tutorials/python-tutorials/how-to-install-anaconda-windows/)).

- You must have Git Installed ([How to install Git in Windows 11](https://www.simplilearn.com/tutorials/git-tutorial/git-installation-on-windows)).

- You need an account at [HuggingFace](https://huggingface.co) (it's a free account)

Check your Python version to make sure it's up to snuff:

!["How to Install Free AI image Generator"][0]

And make sure Git is installed: 

!["How to Install Free AI image Generator"][1]

And you're ready to go. 

## Step 2: Install Stable Diffusion Web UI 

Create a folder somewhere where you want the software to live. Go to that folder:

`cd /your/project/directory`

(for me it's C:\Users\jerem\Projects) 

Then clone the repository: 

`git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git stable-diffusion-demo`

!["How to Install Free AI image Generator"][2]

You should see the folder you just created: 

`stable-diffusion-demo`

Now we need to go into the models folder: 

`cd stable-diffusion-demo\models\Stable-diffusion`

It should look like this: 

!["How to Install Free AI image Generator"][3]

This is where we'll put the Stable Diffusion models when we download them. 

## Step 3: Download the Model from Hugging Face

Next, we need a stable diffusion model, and we can get one from [Hugging Face](https://huggingface.co). 

Let's try the [v1-5-pruned-emaonly.ckpt](https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.ckpt) model. Download it to the `stable-diffusion-demo/models/Stable-diffusion` folder: 

!["How to Install Free AI image Generator"][4]

It might take a while to download (4GB at the time of this article). 

Ok, now.. you're ready to run the web app! 

### Step 4: Run the Stable Diffusion Web UI 

At your command prompt, make sure you're in the folder you created in step 2. 

`cd stable-diffusion-demo`

Then run `webui-user.bat`

The first time you do this, it will install everything needed, so it may take a few minutes. 

!["How to Install Free AI image Generator"][5]

Once it's completed, your command prompt will look something like this: 

!["How to Install Free AI image Generator"][6]

And the web server will be up and running. 

### Step 5: The Web Interface

Load up the following URL in your web browser:

`http://127.0.0.1:7860/`

It may load up automatically in the browser as well. But you'll see a full web interface you can use to generate images:

!["How to Install Free AI image Generator"][7]

Awesome! Let's try it out! 

The sampling method is the first thing you might notice in the generation tab. There are a LOT of them:

!["How to Install Free AI image Generator"][8]

I suggest spending some time adjusting and playing with this. But for now, we'll use `DPM++ 2M Karras` that's selected as default. 

Here are some settings to pay attention to:

- **Sampling steps** - This will repeatedly try to improve the image as it generates. Low values will be low quality, but fast. High values will be higher quality and slower to generate. 
- **Width and height** - These will control the size of the generated image. Like above, larger images will look better and take longer.
- **CFG Scale** - This will change how "random" the result is. A higher value will attempt to take the prompt as literally as possible. Lower values will produce more creative results.
- **Seed** - This value determines the output of the random number generator. You can use it as a key. If you use the same prompt with the same seed, you'll get the same image. You can create many variations from the same "key". 

So today, I will leave everything at the default settings. I will only create a `seed` to progressively improve the same image as we go.

!["How to Install Free AI image Generator"][9]

And I'll add a prompt to make something silly. 

'a photo of an anthropomorphic frog riding a skateboard in Times Square`

It took about a minute to generate this image. (Laptop with RTX 3060)

!["How to Install Free AI image Generator"][10]

And it's pretty cool! It's impressive, considering it's being run on my local machine. Let's improve this image!

### Step 6: Improving Images

Here's actual image I produced:

!["How to Install Free AI image Generator"][11]

Let's mess with the settings to see what we can improve. Let's change the Sampling steps. This is how many times it goes through the image and tries to improve it. The default setting is `20`. Let's set it to the maximum number of `150`. This will take more than a minute to produce now.

!["How to Install Free AI image Generator"][12]

I will leave the prompt and the seed the same and click "Generate" again. 

I'll warn you: it can work the GPU when you do this.

!["How to Install Free AI image Generator"][13]

Here is the result after **150** sampling steps:

!["How to Install Free AI image Generator"][14]

So it's certainly different, but not in a significant way. We don't want to scale up our generating time by 10x for this small of a change. I'll change it back to `20` and `CFG Scale` to `5`. This will make the model more "creative". 

Here are the settings:

!["How to Install Free AI image Generator"][15]

And here is the result: 

!["How to Install Free AI image Generator"][16]

Ok, that's too creative. But you can see the changes that occur when you adjust it. You can also use different sampling methods as well: 


#### DPM++ SDE Karras 
!["How to Install Free AI image Generator"][17]

This model's output is kinda neat because it shows the frog skateboarding better. 

#### Euler
!["How to Install Free AI image Generator"][18]

#### DPM++ 3M SDE
!["How to Install Free AI image Generator"][19]

When you're attempting to draw things in cartoon, especially anthropomorphic models, it can come out very bizarre. 

!["How to Install Free AI image Generator"][20]

But that's all there is to it! 

## Conclusion 

In this tutorial, we:

- Installed the Stable Diffusion Web UI
- Downloaded a model
- Generated AI images
- Modified the output 

All from our local machine! Here are the benefits and downsides of this method compared to something like Midjourney:

Pros:

- It's free!
- Generate as many images as you like
- Runs locally and is not dependent on an internet connection

Cons: 

- Nowhere near the level of quality as Midjourney and others
- You need a good machine to run this
- It may take longer to generate images


!["How to Install Free AI image Generator"][21]

So there you have it! Now, you can generate images on your machine and show your creations to the world. We are barely getting started with the possibilities available from this model. We'll explore it more in the coming weeks. 

If you have any questions, feel free to reach out! 

- Jeremy

Questions? Comments? [Yell at me!](http://bit.ly/JeremyCMorgan)

[0]: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r27wjyul3aipx5ovm37m.png
[1]: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0rbq3c5awtvp5nyxxv5k.png
[2]: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ahnb4m4svite4s79bgl7.png
[3]: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f0sjqac1t4vmcjaavlrc.png
[4]: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mk4gn35mq3ajuvi0x6sx.png
[5]: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v5qvkeqsu6823ekf7x3d.png
[6]: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g4tm0u1rvyuyod5ubb20.png
[7]: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ijc62j7nhu9c1y5ysh9m.png
[8]: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s5fnw9jjcr6c1pq4epz9.png
[9]: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/62ujo13sm65wcb7wrqgg.png
[10]: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3g70si82ylvkl613tm3b.png
[11]: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c4gq23svhr3au07cp64f.png
[12]: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/so2jnango8s05661g3u6.png
[13]: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tfel0zjwuzb9r0mbs25m.png
[14]: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iyawu4ecfmz3ejr0fbm9.png
[15]: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lu1u5e65e01ialcq2l9j.png
[16]: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9i96jad3wflqse9f4po8.png
[17]: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7ko11wdex772oqmv01j1.png
[18]: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/660fny7dzxqkvwqytoak.png
[19]: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yvfeeb7phhjtdn6oh9ch.png
[20]: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eeiux8ropxtyngxchp96.png
[21]: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k92oaxl21kimt0po2n5s.png