Change background with inpaint & RemBG in ComfyUI, A.I. Stable Diffusion

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so hello everyone welcome to the next tutorial today I want to show you how you use uh inpainting for changing the background of a generated image or a photo for this we will start to do uh easy inpainting workflow and then integrate our image into it so that we remove move the old background and um exchange it with the generated one so let's start by double click the background and load a checkpoint for this we take the checkpoint loader simple note for now I will choose the uh after that we will need some text and code for positive and for negative we will pipe this into our sampler positive negative then we need our model connected and we need a empty latent image for our resolution with and he uh we need to get the load image node so for this we need uh the load image node so right click on the background image load image so I have this girl here and I want to remove this background and then later on in paint a new another background with the prompt I have chosen here above so first we need to create a mask for the in paint uh we take the remove background note we also used in the last tutorial I will search for Ram BG and we choose this one this is um included in the was note V note suit uh I will link this so to convert the image to Alpha mask we need an alpha Channel as mask node so we search for Alpha is uh an custom node as well it's uh included in the all I will link it below this takes our uh Alpha channel so will take this image and convert it to Alpha Channel with this mask we now can finalize our in paint so we have to pipe The Mask into our inpaint encoder and then replace the empty latent image with is our in paint encoder so we can delete this we need to pipe our image to the pixel port and our vae needs to be connected to the vae so this should be it now everything which is around our G will re replaced with in paint uh procedure with our generated background so let's queue it and have a look so there you go I think the the result is quite nice let's get another one I think it quite it works quite well what we can do to further optimize the result is to uh change the checkpoint to a special in painting version so there is this deliberate version five in painting model and uh this should give this is optimized for in painting and should give uh a better result so I think here we don't see any big Advantage but there might be images and backgrounds where this is giving you a greater benefit when using in painting checkpoint so maybe as a side note this remove background note works best for op for images where you have a um quite obvious um separation from foreground object and background here this is quite simple you see the girl is in the foreground and the lights and the fo's background is in the background so the algorithm can easily um separate them and can easily create an alpha channel of it so you have to um keep this in mind when you play around with this so this might not work for everything what you can do if you have a more complex image you can create the alpha Channel inside Photoshop or you can use uh if you right click on the image here you can use comy shop here you can also um draw um the alpha mask with this paintbrush so I just do it quickly to to show you you can uh change the brush size with your mouse wheel so now it's quite big you can do it smaller so but this is nice for testing but if you want really good results I suggest that you do it in Photoshop uh this will give you much better results so after this you can save it to note and uh there you have your Alpha Channel um in this case you I think you have to [Music] invert your Alpha Channel your mask like this and then you can pipe it directly into the mask um Port Let's test this one so see this is working as well so that's it I think there you go you can now uh exchange your background uh um and yeah play around with this I hope you got some benefits out of this um so if so please subscribe comment below and like the video goodbye
Info
Channel: neuron
Views: 3,933
Rating: undefined out of 5
Keywords:
Id: hrHfySDSEb8
Channel Id: undefined
Length: 8min 16sec (496 seconds)
Published: Fri Feb 02 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.