-: Hey, I'm gonna walk you through
how to get stable diffusion web UI running
or otherwise known as AUTOMATIC1111.
This is a way
to get stable diffusion running locally on your computer.
And before you do this,
you will need some technical knowledge.
It's not straightforward, it's a bit complicated.
There's a lot of complicated parameters.
You might not know how they work.
There's also a requirement which is you need a GPU.
So I'm running this on a Mac M2.
There's also, you know, windows version
for NVIDIA style GPUs if you have a gaming pc.
But that's something that needs to happen
'cause it can't, it's pretty heavy load
and it can't really run just on your normal computer.
You need a graphics processing unit, a GPU. Cool.
This is Stable Diffusion web UI.
Just wanna show you what it looks like when it's running
and then we'll talk about how to install it.
I'm in the stable diffusion web UI folder
and then I just say bash webui.sh and it's running
and it's gonna install anything it needs
and get it to the place where it's actually running.
You might get some error messages here,
which you'll have to figure out. (laughs)
Sometimes it's a bit complicated, like I said,
there's a technical ability to it.
It says it's just installing the requirements
and once it's running, it will be available on this URL,
which you'll be able to grab from the terminal.
So I have a few extensions installed to try,
so I am bringing some of these things in.
Okay, yeah, here we go. This is the URL.
So you can see there, paste it.
All right, we have it so we can change models up here.
I'm using the standard stable diffusion, the v1.5,
a lot of people use version 1.5 over the version two
or plus models just because it's a bit more flexible.
There's a lot of user generated type content.
People have trained models based on this,
that are quite useful and all of those,
like when you download them, they show up here.
I'll give you a quick example.
So just say like a cat wearing a cape
and hit generate and this is where you put the prompt.
You can also do negative prompts in here.
There's, you know, a lot of functionality
in terms of the parameters and stuff you can change.
Don't worry about that too much right now.
We'll cover that. So here we go.
There's a cat generated with a cape
and then I'm just gonna show you how
that looks like a different model.
So this is a cat wearing a cape.
And actually by the way,
one thing that's interesting is the every image
that's generated,
the prompt is saved as metadata in the image.
So you can also see the seed
and what model you used, et cetera, what sampler.
That's a cat wearing a cape.
I'm just gonna show you,
I'm just gonna try the inkpunk-diffusion model.
And that's working. And if you are downloading a model,
lemme just get generate here.
If you're downloading a new model, say from civitai,
bear in mind that some of these are not safe for work,
but if you download the model then you need
to put it into your folder here.
So this is stable diffusion web UI
and then there's this models folder
and then you have stable diffusion
and this is where you stick it
and when it's there,
then you can just hit this refresh and it should show up
or you can restart.
Yeah, here we go. So this inkpunk-diffusion
it didn't do anything different really
'cause I didn't use the trigger word,
but specifically there's a trigger word nvinkpunk.
If I hit generate, it's gonna do it in this style.
So this is a dream booth model that we can use.
But there are, you know, lots of different types.
Some have trigger words, some don't.
You can see how that works.
Yeah, here we go. So now it's in the ink punk style
where you can see it's diffusing towards that.
There we go, an inkpunk cat in a cape looks a lot cooler.
So you can change the sampling steps.
This is how many, yeah, how long to run diffusion process.
You can also change the sampler.
I just used Euler a, ancestral that stands for,
there's a lot of differences between them,
but the ones that stand out,
a lot of people use eular a,
a lot of people use DPM++ 2M Karras,
this one here and then DDIM.
That was like the original one
that was like made specifically
for stable diffusion, I think.
This is how many images you get.
So this would generate four images in a row
and then this batch size is like how many images per batch
that can be multiplied together.
If you don't have a lot of VRAM
and then your batch size, you wanna keep that small
because it's generating at the same time
it can really lag on your computer.
A CFG scale is how much of a difference the prompt makes.
So how close it is to the prompt versus how creative.
So it's similar to temperature on the GPT-3
or GPT-4 interface.
You can add extensions here.
So I've added control net, which I'm not gonna walk in
but walk you through.
But there's a lot of like cool stuff you can add in here
and they'll show up in different places
in the user interface.
The way that you add extensions is if you go here, oh sorry,
extensions and then available, load from,
and it loads it all from this, this JSON file
and you can see which ones there are and what they do.
And then you can install them.
You can also load them from a URL
if you just find one out there on the web.
But obviously be careful 'cause you're loading code.
Some of them show up as their own separate tabs.
Inpaint Anything is one example.
They have, in some cases, they have like settings here
that you can change.
There's also like a lot of built-in extensions,
like the image to image stuff you have inpaint in here,
which I won't go through.
You have interrogate clip,
so you can reverse engineer the prompt from an image,
which is pretty cool.
There's a lot of parameters here you can mess around with.
There's also the different scripts you can run.
So like the X, Y, Z plot would generate,
you could generate like say the same image
but with five different values for CFG scale for example.
So there's a bunch of different things you can do here.
In the extras is where you do the scaling.
So if you wanna upscale the image to a higher resolution
or higher size, and then this is where you would do it.
In extras you can also do batch processing
for multiple images if you need to.
Cool. That's the user interface.
And if you ever get confused
or you don't know what different things do,
the wiki here is really good.
Like it has a pretty detailed understanding
of what these different things are.
You know, check on that. But to install specifically,
I'll just show you what I did to install on the Mac,
and this is on the Apple Silicon.
So it's the M1 and two Macs in particular.
I used Homebrew, right?
Once you have Homebrew, you run this in the terminal.
I say if I just press Ctrl+C to cancel this,
if you run that, it will install the cmake and protobuf
and get wget. If you don't have them
and then you just do a git clone when you're in your folder
and that will just pull down from GitHub
all the stable diffusion web UI code
and that will give you that local folder
that I was showing you before.
Then you need to download the stable diffusion models.
It has some examples here like where you can get them from.
Version 1.5 is the one that I use.
There's also a special one for Inpainting,
which is quite useful
and or there's version two if you want as well.
And typically you just click it
and it will take you out to somewhere like hugging face
where you can, you know, download the model.
The files and versions are in here
and I think basically you just need this
checkpoint file here.
So if you click that, it'll start downloading. Okay.
Then once you have, once you have that available,
you drop that in your models folder
and then you can just cd like change directory
into stable diffusion web UI and then run bash webui.sh
or just this ./webui.sh.
And that will do everything for you.
Now if you're running any issues
there's actually quite a lot of information here.
There's like all these issues you can search through
and if you just search for the error message you're getting,
quite often people have already written how to solve it.
There's a lot of pull requests
where they're trying to improve some of the UI
and some of the issues that you run into.
And there's like specific discussions.
So that is how to get it running on Mac.
On Windows so let's assume you have a NVIDIA GPU.
Again, the process is similar.
They don't have homebrew on the Windows,
but basically the way it works is you download this
and extract the zip file
and then you double click the update.bat
and then that will get it
to like the latest version essentially.
And then there's a run.bat script.
You just click that and that should launch it.
It will download like all the files that you need.
And then you should see this like running on URL.
And it's the same URL that you get on a Mac.
So that is, that should work on your computer
if you have a GPU.
But there's also like multiple methods if you have issues.
So you can do the get clone method like you do on Mac.
You know, you can also use it on Linux
and there's different instructions by the way,
if you have an NVIDIA GPU versus if you have an AMD GPU.
So just pay attention to that.
But in general, it's always the same thing.
You get the code from GitHub
and then run like the windows, the .bat file
or the .sh file, depending on which file system you're on.
All right. Hopefully that's helpful
because this is open source,
you can literally just have a look
and see how they do different things.
If you want to know how do they do the, you know,
how do they input all the prompts from a file,
you can just see, you know, how they've done that.
That's the code here, you can make updates to this
if you want just locally
or you could actually push 'em back into the main repository
for other people to benefit from.
So yeah, lots of fun.
You're gonna learn a lot about image generation
when you can just generate these images for free
on your own computer and just leave it running.
So you know, have fun with it,
check out all the different parameters,
look up the definitions of what they are.
And that's really the best way to learn.
It's just experimentation.
All right. Hopefully that was helpful.