How to Create PNGs with Alpha Transparency in Stable Diffusion - LayerDiffusion Tutorial 2024

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey welcome I'm Albert boson and today I'm going to show you how to create images with transparency in your stable diffusion web UI now why would you want that you can just cut it out later right well yes if you have the time and effort but some things are practically impossible to cut out well like for example frizzy hair or fur or even half transparent things like glass and ice cubes and this extension layer diffusion generates the images transparent right away so you save a ton of time or even do things that were otherwise not possible before now when I first talked about layer diffusion on my LinkedIn the other day I got thousands of Impressions and a ton of people asking for a tutorial on how to use it so here goes enjoy the first thing you need to have in order to do this is fundamental experience with stable diffusion ideally the stable diffusion web UI so if you've seen what is up on screen right now before and know what most of the buttons mean you're probably ready for this if not I strongly recommend going back to my videos or some of the videos I have recommended in the video description in order to learn these Basics this might look like what I've recommended in the past the auto 1111 web UI it is in fact not it is something called Forge which is an improvement upon that and you can get it under this GitHub link which I've also linked below of course it is by the same person who came came up with control net and focus both things I've made videos on and it's basically just way way way faster and more stable than the auto 1111 web UI so you can see up to 75% speed increase if you have the right Nvidia GPU it's very impressive and since we switched to it at work we have not used the old web UI again basically that's how great it is why do you need this well it's because the extension that I'm about to show you Builds on top of it and to get this extension you go to a different GitHub to something called SD Forge layer diffuse and what you do is you copy this link go to your webui extensions install from URL and paste it in here and hit install and it should install pretty quickly then you can go to your installed tab make sure it's on SD Forge layer diffuse that checkbox is there and then you have to apply and restart your UI once your UI has restarted you'll see this new new tab down here called layer diffuse if you open it it's very simple you can just hit enabled and then down here you'll have a couple methods these differentiate themselves mostly between 1.5 models which are of course lower resolution and sdxl so let's make an sdxl only generate transparent image first I'm going to pick attension injection because the creator of the extension says it's better than the other one so why not and the rest is much as you usual so let's um generate something that could be a little difficult to cut out usually photo of a woman with frizzy hair wearing a fur coat settings are as they would be with any sdxl model so make sure the resolution is at at least 1024 by 1024 and we hit generate be aware that the first time you generate using the layer diffusion model it is going to download the model that fits the method that you chose but this is a onetime only thing so don't worry too much about it they're pretty small files no problem unless you're using my internet connection and unlike normal Generations you can immediately see that it's creating it with this gray background and that tells you layer diffusion is working because it's now in the final couple steps going to make that transparent and here you can already see the result this is you know the classic kind of alpha grid so you can tell that it's transparent the hair is cut out really well the fur absolutely no problem her hands are messed up but you know whose AI hands aren't this first image is a preview with a grid background and the second one is the actual one with Alpha so if we copy this I can demonstrate by just putting it in front of a color background and you can see it's actually transparent so if I change this Hue it's pretty perfect and very very useful so now let's do something more fun more weird just to demonstrate the power of this let's do something with water um a large t Nami wave splashes of foam something like that you know and just to demonstrate we can do anything else that we would do with sdxl normally you can change the resolution for example you can change the CFG scale none of that impacts the result it's always going to work well and you can see it really got those details so all those little splashes are all here you can see kind of the foam in the air it works really really well for all kinds of uses just to demonstrate let's do this test again it really got those tiny little pixel precise details going on which is really neat now of course you might be wondering okay but the water itself isn't transparent it's a pretty thick wave and you have to know this of course is limited that it doesn't have refraction or any sort of physical stuff that you would need 3D rendering for right so um you're never going to get that with a normal PNG but it can approximate it so you'll get pretty far with kind of standard transparency excellent so now you can generate images with transparency using sdxl models but what if you want a fitting background to this foreground that you've generated well it's very easy you have that setting here in layer diffuse by choosing another method for example SD 1.5 generate everything get together generate everything together so we just click that and again we can do whatever we want so how about a portrait of a man with frizzy hair then make sure you pick a 1.5 checkpoint let's stick in the Juggernaut family so I'm going to do Juggernaut reborn and remember to change your resolution back down to 1.5 sizes so 512 by 512 you might be tempted now to click this higher res fix if you know what that is because it will upscale it'll give you a bigger result despite the lower original resolution unfortunately that does not work with layer diffuse it'll give you broken results so we can't do that another thing you need to watch this method needs a batch size of three because you're generating three images at once now the foreground the background and both of them together so make sure your batch size is on three and now let's generate and here's your man but what's this who's this other man well this is actually background it generated together it looks okay a little weird but of course you don't want your subject in both the foreground and the background you just want one of them so what do you do about that well the creators of layer diffusion do have a fix for you they have this foreground additional prompt and background additional prompt in order to use them you have to actually remove your primary prompt out of here so everything you don't want in the back background you put down here man with frizzy hair and if you want something specific in the background you can for example say City Library indoors something like that and there you go here's your transparent man here's your man in front of his background and here's just your background obviously the quality is lacking because my prompt is terrible but in theory that's how it works after playing around with this for a bit a question that came up immediately was can I use this for images that already exist right if I'm editing something real a real photo in Photoshop can I maybe put it in the image to image Tab and let layer diffusion run over it I tried unfortunately not at this point at least let's hope that feature gets added in the future though because that would make it really really special if you liked this video be sure to click down there and actually like this video And subscribe to my channel if you're already subscribed and a longtime viewer of my videos wondering why I haven't been posting as much that's because I've been working full-time day in and day out with AI in my job as creative director of story book Studios that's a production companies specialized in using AI for feature film and series production so if that sounds exciting to you be sure to also follow me on LinkedIn where you'll get project updates for me every couple of days either way see you next time and have fun with stable diffusion e
Info
Channel: Albert Bozesan
Views: 1,655
Rating: undefined out of 5
Keywords: ai art, concept art, stable diffusion, midjourney, dalle, open source, artifical intelligence, controlnet, layerdiffusion
Id: dsSXa8KdnKw
Channel Id: undefined
Length: 9min 10sec (550 seconds)
Published: Mon Apr 15 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.