Easy Face Swaps in ComfyUI with Reactor

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
face swaps can be a quick way to develop somewhat consistent characters designs when generating AI images this video will teach you how to do a face swap using the reactor node within comfy UI along with fixing a few common errors that'll likely occur let's take a look okay looking at comfy UI here the first thing you want to do is go ahead and load up your manager this assumes that you already have the comfy UI manager installed if not there's lots of helpful resources online that walk you through the steps here uh but once you do you're going to want go ahead and install custom nodes and then you're just going to search for reactor and install the reactor node for comfy UI uh full installation instructions are available on the GitHub repository I'll put a link to this in the description uh but in addition to installing comfy UI reactor nodes you're going to want to go ahead and install some face restore models so there's a couple that you can use the gfp Gan and the code former are both the the uh the models that are used uh with that node and once you have them downloaded you're going to want to go ahead and navigate to comy UI the models directory and the face restore models and place them there uh you can see they're about 350 mags uh some folks prefer one over the other you know if you have both of them they're easy to test against and kind of go with whichever ones give the best results that you're looking for uh whenever using this node so let's go ahead and switch here and start doing a simple face swap with the reactor node so I'm going to go ahead and just go ahead and click on ADD node and go to reactor and do reactor face fast face swap so for the input image that's going to be whatever image that you want to impose a face onto so in this case I'm going to use this one and then put in the input image and so for the source image I'm going to go go ahead and just do the load image and I'm going actually create a brand new image right now here do just a quick picture um I like to make sure that you know like the eyes are open uh in neutral expression there uh so let's go ahead and Export this reactor Test 2 I was playing around with this earlier uh and so let me go ahead and upload this reactor Test 2 so there's my image that I just took um and then use that as the source image uh so the whenever I was looking at the installation instructions uh for the kuui reactor node uh some folks might be having problems to get this uh swap model downloaded it should download on the first run but there are um kind of tips for dealing with this issue in case if you have any problems on your machine within the readme document on the GitHub repository again it's linked in the Des description for you to check out there so for the face restore model if we click here we're going to go ahead and just use the gfp G version 1.4 and I'm going to leave everything else as the default uh so whenever it comes to face swaps with the reactor node you can actually you know if you have a group picture and you want to just uh swap out your face for one um of the characters within that you can go ahead and do that um you know by using like the index and such and through all these options but that's a little bit you know just more G uh context about this node and what you can uh can do with it there so let's go ahead and take a look at the preview image so this is a basic uh workflow here so all we did is added just the load image this reactor face swap and now we can see uh my face is now imposed onto this original uh image's face so very cool um so uh that's one part of it so another thing is to that's really cool is while we loaded this as an image you can actually save this as its own separate model and it's only 4 kilobyte file uh but you basically just go ahead and um save the model face model connect the image and the face model and you can name this to whatever you want want so I'm going to put in YouTube me uh and two so I'm going to go ahead and save that run it and if I go ahead and take a look at my comfy UI folder I have uh that file saved right here so then I can actually delete this image and then go to reactor load face model um and I don't think it will show up now so so we're just going to go ahead and click refresh and then click on here again and then pop that into there as the face model so we don't have to use the source image so you know there might be applicable reasons for this if you want to work this into multiple nodes within your uh workflow here and you don't want to go through the load image you can basically just save it um you know or if you have multiple characters if you will you can save all those as individual models and then just go ahead and load them throughout so I'm going to go ahead and delete this node and if I go ahead and cue The Prompt nothing should change on this image because it's using this basically same reference image but now as a model and then popped it in there okay so that is uh a basic uh face swap now as far as this restore model if you don't have those models downloaded as I mentioned earlier this will turn out grainy it will still do it but you'll get this really grainy look so that's the importance of this pH restore model and if we want to test out how the code forer um model works here we can go ahead and run that uh and if we wanted to try to compare we could basically do two of these nodes and put them side by side uh here's the gfp Gan again both of them fairly close uh little subtle differences but you'd want to go ahead and kind of play around with it until you get the results you're looking for okay so the thing is with this uh reactor node is that like it's not perfect so we can see some sort of like artifacts or it's not like the cleanest uh whenever it comes to doing a face swap here and it looks like my eyebrows completely disappeared or behind the glasses here so we can try to clean that up either through in painting or also through uh basically an imageo image process so um I like the image to image image process uh while still trying to retain whatever uh the swap is here um into uh you know retaining the likeness if you will so how would you do that um so you would go ahead and basically repeat this process uh again uh but basically turn the D noise down to like 0.15 uh or so on so let's go ahead and just do that really quick so we're going to uh vae encode this image so we're basically turning it back into the latent space noise uh so we can go ahead and um manipulate it if you will so I'm going to go ahead and pull in my original positive prompt my original negative prompt and also the original model okay and then we're going to go ahead and decode this now uh again we're g oops we're going to go ahead and get the vae let me zoom out just the haor here oops wrong button okay so we are going to go ahead and preview the image and now you going to want to make sure that you uh copy over all the options the same as the case sampler so on Windows computer you can do like I think it's like a shift control C or something and it will actually retain all the noodles um for some reason I can't get it to work on a Mac um but we're going to want to go ahead and pull in the same seed as both of these so seed number five it's a fixed value change the sampler to DPM pp2 M and then Caris and of course this will vary depending on the model that you're using uh and then I think I think that might be good oh the D noise so we're going to turn this way down because basically well let's go ahead and test it out so if I leave the D noise at one it's going to basically create this image because while it took this in as noise it's going to give a fairly uh close representation to this it might not be 100% exact uh there might be some subtle details that changeed because it's using this as noise instead of an empty D latent image uh but it will get um it will more so take on whatever this is um so we want to go ahead and turn this noise way down so it adds basically a little bit of noise to this image but then the diffusion model will go ahead and clean it up and then hopefully retain much of the likeness within this image so if I go ahead and cue The Prompt here and we can see right now that it now took on on much more of this original image now let's take a look at like the artifact and so here's the original just to give you a reference we can see it like breaks right here on the head um and kind of gets blurry as it goes down and I know I'm really zoomed in here uh but let's go ahead and see we can see it's kind of a little bit smoother along this edge here uh and kind of cleaned up some of the jaggedness uh of that image without completely destroying the likeness uh between the two so that's kind of an easy way to clean it up within the latent space uh and then once you get something you know you can keep playing with this however you want until you get something that you exactly like but you know you're going to start to pull in more of this original reference image the higher the noise is uh to that so I'll just leave it at around like 0.14 somewhere in that neighborhood it's not an exact science here now what we can do though is since it's a 512 x 512 image we can go ahead and upscale it and make it look a little bit nicer so let me go ahead and do image upscale and then image upscale image using the model and then I'm going to go ahead and um I thought there was a loader for the upscaler uh let's see yes upscale model loader so we're going to go ahead and take that that and you can use there's lots of different UPS scalers um this is just one of the default ones that I have here um and then let's go ahead and preview the image again and um whoops this is actually by 4K so it's going to be massive um you can actually set it to like you know 1.5 uh by just going ahead and uh image upscale upscale image by and then save 1.5 so you don't have a massive image but regardless uh here's the upscaled image and we can still see it didn't clean up um all the lines but still it looks pretty good uh compared to where we started um on the original image here is it was um you know not bad but there's definitely some areas that you could clean up there to get to the final image here so that's it with doing a reactor face swap uh within com UI um this workflow is available to download uh link to it is in the description so you can go ahead and play around with it as well too uh if you have any questions about it you know feel free to drop a line in the comment section I'll be more than happy to take a look at the workflow that you have going together here or trying to answer any of the questions the best to my ability if you uh all like the video please consider the thumbs up and also subscribing thanks so much for watching I'll see you in the next one take care
Info
Channel: Prompting Pixels
Views: 2,144
Rating: undefined out of 5
Keywords: stable diffusion
Id: YhBp1TsIBMA
Channel Id: undefined
Length: 13min 14sec (794 seconds)
Published: Tue Jan 30 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.