hello everyone welcome to the channel generating images from text prompt is fun but there are lot of things which go behind the scene and I believe it is extremely important to understand few of the basic concepts which I often asked about whenever I do a video around stable diffusion models or whenever I cover some text to image generation model in this video I'm going to answer a very core concept about noising and denoising of the images when whenever we are creating images from the text pront by using AI models I will try to keep it
as simple as possible while ensuring that once you have watched the video you are crystal clear about these Concepts the tool which I'm going to use for it is called as comy UI I already have covered comy UI on the channel where I have shown you how to install it and that is again a very easy to follow video which you can search on my channel and you will find it at the very top so please do watch it out if you're looking to install comy UI but that is not the topic of this video
for this video as you can see I'm showing you the comy UI interface now whenever we generating images from text prompt with the help of AI model the usual process is that first a latent image is created a latent image is simply an abstract hidden compressed image which is either based on an input image or an empty image for example if you see at this screen we are simply using this empty latent image here again if you want to know more about what exactly this latent space latent images I have done a very easy to
follow video which I'm more than sure you will enjoy but for now just remember that whenever we are creating an image from a text prompt first a latent image is created latent means an abstract image secondly a random noise is added to this image then the AI model Den noises this image Guided by the text prompts so for example in this window at the moment you see if you start from the left hand side we have this model which is dream shaper and then here we have two prompts the top one is a positive prompt
the bottom one is the negative prompt so in the positive prompt we want this image to be created the text prompt is beautiful scenery nature glass bottle landscape purple Galaxy bottle and then what we don't want is text and Watermark and we are also providing a latent image here which is an abstract or empty image now on the basis of these two prompts and this latent image our AI model is going to generate a new image so how that works the way it works is that first a random noise is added to this latent image
then the AI model Den noises this latent image Guided by these two text prompts and then a new latent image emerges here by K sampler which is then decoded back to the pixel space so that we can see it this is how this whole process works now you might be wondering what is this noise why it is added and then why we Den noise it again to get a new image why don't we just change this uh image the lat image in place and create a new one why do we you have to add a
noise and then remove the noise so in this video this is what I'm going to explain to you why exactly this noise is edit and why do we D noise it so the in this video I'm going to not only explain this process I'm also going to show you a Hands-On thing so the node which is specifically responsible for this image generation process is called as case sampler which you can see here this is the one let me first describe this flow and then I will explain the case sampler and this noise and D noise
let's start from the left so again this is the model we are using dream shaper then this model is output model is connected to this case sampler model and then this positive and negative prompts are connected to these positive and negative prompts and this empty latent image is connected to this case sampler so this is how it is working so case sampler takes these inputs the model dream shaper positive negative prompt and latent image and then on the basis of these parameters it creates a new image so what it does is it first adds the
noise G sampler adds the noise to a latent image noise simply means random unpredictable data and adding noise to the latent images just like introducing random errors or distortions to the blueprint and let me give you an example for example let the original empty image is some uh blue color sky with white clouds and then when we add the noise it means that along with that blue sky with white clouds we have also added some random splotches of gray and black just to distort it so now the noisy latent image is like corrupted version of
the original and then we do the D noising or case sampler does the D noising D noising is the process of removing the added noise from the latent image using the AI model and these two prompts positive and negative the AI model tries to restore the original image based on its understanding of what the image should look like now example of D noise could be that our noisy latent image was blue sky with white clouds but with random splotches of gray and black D noised image will be blue sky with white clouds restored to its
original state so we have restored it back now here is the interesting part during D noising the AI model doesn't just simply restore the original image instead it uses the positive and negative prompts to create new details textures and patterns that were not present in the original image so the resultant D nois image could be blue sky with white fluffy clouds and a few birds flying in the distance the new D noise image is combines the element of the original with the AI model's own creativity so that is why uh we do the denoising and
noising and this process allows a Cas sampler node to generate new Unique Images based on the original latent image and the in these PRS provided so again you may ask why noise and D noise so there are few reasons for it first D noising allows the AI model to explore new possibilities while still being Guided by the original image by introducing noise and then removing it the model can discover new combinations of features textures and patterns and the way noise is added is through this seed so if you click here you can change the seed
to maybe uh zero then there will be no noise and once you run it there will be just clicking on Q prompt you will see that is running and nothing has been added to it so let me see Zero here and click on okay and then Q prompt you see once I remove it it just randomly put something here maybe I'll just say something like this click okay and then Q prompt it has again change it it is just depending upon case sampler stuff so this is how it just add some random numbers that's it
and creates a new unique thing every time you will do it every time there will be a new image there are ways of keeping it static but that is for another video so for now you just need to remember that the seed is primarily adding the noise to the image and this D noising is helping not only preserving the overall structure and composition of the original image if there is any or the text prompt but also it adds more model's own creativity another cool thing is that it helps in avoiding overwriting so for example if
your text prompt says bottle it is going to use the bottle not not anything else and by the way you can also input images so for example if your image is of white or blue sky with white clouds it is going to retain that with the help of this noising and d noising and then uh D noising also enables the emergence of unexpected features and patterns by introducing Randomness which is noise and then resolving it the model can create new combinations that that is not simply possible through direct manipulation and then from technical perspective D
noising is way more computationally efficient and stable than directly generating new images and it also by the way helps us in the issues issues like overfitting overfitting means that when an AI model becomes too special to the training data that is where it memorizes its training data instead of learning General patterns for example a model uh which is overfitted on cat photos of your own CAT will recognize your cat's photos but it will fail to recognize other cats so that is what overfitting is so that's it um I hope that you enjoyed it and now
you understand what exactly is meant by noising and Denis noising why do we do the D noising and how case sampler plays a role there in order to use the C to noise and then it also denises on the basis of the positive negative and then the latent image so but if you still are confused about noising Den noising K sampler and all that please put uh your comments in the video uh below the video and I will try to answer it also before I let you go let me give a huge thanks to agent
ql agent ql is the sponsor of the of this video agent ql is a cury language for extracting data from web pages quickly easily and at scale you can use the python SDK to run your queries in production using playright and use the browser base debugger for optimizing cues in real time on any web page so that's it guys if you like the content please consider subscribing to the channel if you are already subscribed please share it among your net work as it helps a lot thank you for watching