How to swap faces in ComfyUI using InstaSwap - Stable Diffusion Workflow

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone how are you doing today in today's video I will show you a new custom node full confy UI which will allow you to swap faces easily and really fast in the description of this video there will be a link a GitHub link to this particular rer story click on it and you will reach the landing page the project has been around for quite a while about 3 month and it is similar to reactor phase however recently there has been quite a few issues with the reactor phase custom node if we scroll down we can see there is a demo and in the demo it's basically going to swap this Source face into this input image and here's the result I will take you through the installation and then we are going to do a quick testing of our during my installation process I also got about two errors I will show you how to fix those in case you also encounter those errors first go to your config UI installation folder and then click on the config UI folder go into it next look for the custom node folder go into it and then at the top here click once and type in CMD like so and press enter this will open a command prompt directly in the confy UI custom node folder next go back to the geub repository link and then click on code copy the code in your terminal where you have the custom node type in get clone and then paste the link press enter this will clone the repository basically copy the repos story from GitHub to your computer next in the installation guide it tells us to type in python install.py or if you are on Windows you can also type in install.bat directly in the terminal if you want to double click on it that also will work so go back into your custom nde folder in the Explorer and then look for comy UI insta swap folder go into it in there there will be the install.bat double click in order to install the requirements in my case it installed pretty much instantly because I already had the inside phas Onyx open CV python as well as numpy install on my system if you've installed instant ID in the past or if you've installed IP adapter that as well you should have inside phase Onyx already installed now next in the installation guide it requires the C++ build tool and this comes from Visual Studio but like I said if you already have instant ID or IP adapter most likely you already have this build tools available but in case when you're running this config UI insta Swap and you get any errors check the documentation on how to install Visual Studio for your particular machine if you're having difficulty you can go to the channel click on videos and scroll down until you see this video here instant ID implementation in confy UI and in that particular video I do explain how to install visual studio now for me I will skip step four and go directly to step five which is to download these two models and place them in the correct directory so simply click on the link and it will start the download it's about 400 megabyte per model there are two models now keep in mind that this insta swap is also compatible with video node and in the read me you will see that we have video files it requires the VHS video helper site so you can pass in a video it will automatically extract the individual frames as images and then do the swapping for each frame now once the model has downloaded go into the config UI insta swap folder the same custom node folder right click click on new and then select folder name this folder as models go into the folder again right click new and then name this folder as face restore uncore models now go into that folder and then paste those two models the code forer and gfp gun into this folder okay so to recap inside the insta swap folder you need to create a models folder and then a face restore uncore models folder inside the face restore for models folder you will paste those two checkpoints the models file here next double click on the Run Nvidia GPU or inst start confy UI in any way you're comfortable with as for the workflow it is fairly simple all you need is one single custom node so double click on an empty space and search for insta swap add the node and now you will see that it requires three input Fe fields and then we have two output Fields the input image is just a load image node that is going to be the body basically that you want to use and then the source image is going to be another load image node The Source image is going to be the face that you want to copy and paste on the input image now the face model from the input side and then we have a face model from the output side this one is used when you want to do some chaining let's say you have two different person in your final image then you can use it to do some kind of chaining so you take the face model output from the first one you pass that over to the second one like so otherwise the image output is the final image that you get so the after the face swapping basically now also important to note if you do not see any of these models here then you need to go back and check your directory so make sure that you've pasted those models you've downloaded and saved them in the correct directory remember models and then inside models we need phase restore models inside it that's where you're going to paste those models okay so just make sure that for the face restore model you have the different face restore models available in your drop down I'm going to select gfp gun V 1.4 and let's try to replicate the demo I'm going to take Angelina Jolly the same image use that as my input image then just take a face portray of in this case Mr Bean and use that as the source image so what we are looking for is to swap this face with Mr Bean so at the end we should have Mr Bean's face in this particular image okay I'm going to click on Q promp and I got an error so I'm not sure why people don't test their code before releasing the code but uh we got module loging has no attribute status if you have a similar error like this that's telling you login. status then you can follow along I will show you how I solved it so go into your confy UI insta swap folder and look for insta swap logor called patch. py and open it in any text editor or code editor that you have available in my case I am using visual studio code but you can use notepad if you do not have any other alternative then scroll down to line 17 so 117 and on this line there should be something that says login. status just remove this status and replace it with info in all caps and it should look like this then press contrl s to save or go into file save and restart your confy UI now after restarting when I was checking my CMD log some of you may see this error Onyx and then it's asking for ca. dll basically What's Happening Here is that the Onyx version I have installed on my computer is the CPU version and by default the face swap node will look for the GPU version however do not worry even if you see these error messages the node will roll back and use the CPU version you can safely ignore it I'm doing another test and again I got the same error in this case it's in the file node. py so again go back into the config UI insta swap folder nodes do and then open nodes. py just in case anyone is having difficulty this is the first file and this is the second file so in this file you will change status to info and then open the noes. py Press contrl f you will get this search bar it's quite standard even if you're using notepad you will get some kind of search when you press contrl F and just look for status I found three instances where we had logo do status and that is what's causing the error what I did is I change from logo do status to a simple print statement so here I am using the search and replace functionality of Visual Studio code to change all three instances at once so I'm replacing the logger do status with a simple print statement now at the end this is what you should have just print and then whatever comes after it so look for all the instances of logger do status and change all of them I had three so you will need to change all three of them okay so save and then go back to confy UI restart confy UI I'm going to do it directly from the terminal and then I'm doing another q prompt now in this case as you can see it work for me and I must say it's quite impressive because it was able to transfer the face from this Source image to the input image and it's quite well done I'm going to do another test this time using scholet Johansson and right now I am cropping the face as a square but you can try in any other way just make sure that the face is the most important part of that image so you are putting emphasis on the face going to do another q promp and in this particular case it worked but we just have these two eyes which is little bit weird so this one would probably require some photoshop manipulation in order to correct it otherwise I must say that it worked really well so that was insta swap I hope it was helpful to some of you if you've got the same errors you can follow along and you should be able to work it out however if you got a different error you're trying to use it maybe 5 days in the future let me know in the comments down below and I will try to do my best to help you out I cannot guarantee anything though all right that is it for me I would like to give a quick shout out to my patreon members who has been supporting me for quite a while now big thank you to all of you and just in case you're wondering on my patreon page I have a free teup so you can click on join for free and you are going to get updates work flows and any new features I usually posted over there so you'll be able to see it now if you are to join the patreon and support the channel thank you very much you will get videos like this for example right now I'm still recording but I have an early preview of the insta swap when I was doing my testing already uploaded on my patreon I have other videos as well over there all right that is it for me thank you for watching until the very end I will see you in the next one
Info
Channel: Code Crafters Corner
Views: 1,054
Rating: undefined out of 5
Keywords: comfyui, Code Crafters Corner, CodeCraftersCorner, ComfyUI, Stable Diffusion, Face Swap, InstaSwap
Id: ZnhcVkKCzs0
Channel Id: undefined
Length: 14min 33sec (873 seconds)
Published: Wed Apr 24 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.