Credits got depleted and can't create AI images anymore? How to run your own image generator for free
Tags: ai, aiart, stablediffusion, lora
Published: 2024-04-07 14:32:04


### Struggles of Running Image Generators: Limited Use and Frustration 

New innovations like AI image generators are gathering popularity. With tools like [midjourney](https://www.midjourney.com/home) and [DALL-E 3](https://openai.com/dall-e-3), people can generate amazing images just with their imagination.

The one thing common in all of the tools is that there is **pricing involved**, So if you plan on **generating images for free**, then you will be limited either by a **free trial** or a **limited credit system**.

For example, if you are a designer and you want to create image assets, mockups, or design ideas, there would be a lot of iterations involved, which is expensive.

Sooner or later, after some usage, **your credits will become depleted** and you will **no longer be able to generate images**.

### What technology does Image Generation use?

The technology that these image generators use is called [Stable Diffusion](https://en.wikipedia.org/wiki/Stable_Diffusion).

Stable diffusion **requires a lot of resources**. Making it expensive to be given to everyone for free.

So I thought, Why not run stable diffusion using my own resources? That way, I won't need to deal with payments, and I can create as many images as I want.

So I will be demonstrating by the end of the article how I was able to run AI image generators on my own for **absolutely free**.

[![Demo Image](https://journal-wa6509js.s3.ap-south-1.amazonaws.com/90d6fdad4b5f77e98d1bcdf413a53f4f803b41851e155b023455c72a80a4fa4e.png)](https://journal-wa6509js.s3.ap-south-1.amazonaws.com/90d6fdad4b5f77e98d1bcdf413a53f4f803b41851e155b023455c72a80a4fa4e.png)

Here you can see that I have given a simple prompt, and I got the image generated in high quality.

Let's see how the stable diffusion technology works, so we can start running it on our own.

### How the Tech Behind AI Image Generators Works

To learn about how AI image generation works, we need to know about **Stable Diffusion**.  
We can think of stable diffusion like the real diffusion we have learned in school.

There will be a **clear beaker of water**, we will add a few drops of dye, The dye diffuses throughout the liquid, until it reaches a state of **equilibrium.**

[![Diffusion image](https://journal-wa6509js.s3.ap-south-1.amazonaws.com/60b78a48c83c0b6d4951f96759a56b05c45f0e7af4f5a2928dedc67cb9d43721.png)](https://journal-wa6509js.s3.ap-south-1.amazonaws.com/60b78a48c83c0b6d4951f96759a56b05c45f0e7af4f5a2928dedc67cb9d43721.png)

Now let's apply the same concept to real stable diffusion.

For training a stable diffusion model, we will start with a process called **Forward diffusion**.

[![Forward Diffusion](https://journal-wa6509js.s3.ap-south-1.amazonaws.com/f893aa44072c93e9b19a5585623e017dd5cb6a22c152e98528bf97113b8f6bd5.png)](https://journal-wa6509js.s3.ap-south-1.amazonaws.com/f893aa44072c93e9b19a5585623e017dd5cb6a22c152e98528bf97113b8f6bd5.png)

In forward diffusion, we take an image and add noise to it.  
For those who don't know, think of noise like the static you see when the TV gets disconnected.

The type of noise we are adding here is called **gaussian noise**. This process is done multiple times, so there will be multiple layers of noise.

[![Reverse Diffusion](https://journal-wa6509js.s3.ap-south-1.amazonaws.com/cfe18a55b7cf7e863489ee414915fea47f55d11f5864ee06f1069a4df9772992.png)](https://journal-wa6509js.s3.ap-south-1.amazonaws.com/cfe18a55b7cf7e863489ee414915fea47f55d11f5864ee06f1069a4df9772992.png)

After performing forward diffusion, **Reverse Diffusion** is done. This involves reversing the gaussian noise until we get the original image.

The model gradually starts learning how to predict images from noise.

Similarly, forward and reverse diffusion is done on millions of images to properly train the model.

After the training is done, we can make a random noise, and the model will predict the image.

[![Noise guessing](https://journal-wa6509js.s3.ap-south-1.amazonaws.com/74f8f5536987ef97f34c1d65d1c81f05d64130ceeef1ee359052c4454872c2db.png)](https://journal-wa6509js.s3.ap-south-1.amazonaws.com/74f8f5536987ef97f34c1d65d1c81f05d64130ceeef1ee359052c4454872c2db.png)

We may have a doubt: **How is the model able to generate images from text prompts?**

Images used for training have an alt text associated with them, which describes what the image is about.  
This way, each image is linked to a text, and the model gradually finds the relationship between the text and the images.

[![Image Description](https://journal-wa6509js.s3.ap-south-1.amazonaws.com/ba2956cf7ed3e9b0c10568becccfcfaa7dad7cdd9ac16a64fe7e4486b9b7b604.png)](https://journal-wa6509js.s3.ap-south-1.amazonaws.com/ba2956cf7ed3e9b0c10568becccfcfaa7dad7cdd9ac16a64fe7e4486b9b7b604.png)

This is how stable diffusion models work in a simple way. Now let's get the stable diffusion running on your own.

### Let's get stable diffusion running

Continue reading the [rest of the article](https://journal.hexmos.com/run-your-image-generator/) to see how we can get stable diffusion running on your machine!