ADetailer in A1111: How to auto inpaint and fix multiple faces, hands, and eyes with After Detailer.

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone keyboard Alchemist here and welcome back to another stable diffusion tutorial today we're going to talk about a fantastic automatic 1111 extension called after detailer this extension can save you time and effort by automatically imp painting faces bodies hands and eyes after you have generated your initial image in this video I will show you how to install and use the after detailer extension we will walk through an example showing you how you can incorporate this extension into your workflow and stick around to the end where I will show you an advanced usage case without further Ado let's get into it let's install the extension first go to the extensions tab then the available subtab and click on load from search for after and after detailer will be the first extension mention in the list click the install button on the right hand side wait a few seconds for the install to finish then go back to the installed Tab and click on apply and restart UI once your web UI reloads you should see after detailer as a drop-down list click on the triangle to expand the extensions interface by default you can run two instances of after detailer but you can increase this number from the settings menu go to set settings scroll down to a detailer click on it then scroll back up to the top of the page using the slider select a desired number of after detailer models to run then click apply settings you may need to click on the reload UI button to make the extra after detailer tabs show up you may also want to change the sort bounding Boxes by option to position left to right this will ensure that the after detailer in painting order goes from left left to right when there are multiple objects in the image otherwise the inpaint order will be arbitrary and hard to control we will see why this setting is important later in the video when you are done changing the settings click on apply settings again then reload UI coming back to the after detailer tab we can now see four tabs this enables us to run up to four instances of different after detailer models one after the other note the models will always be applied from the first instance to the last instance there are currently nine different models from the drop- down list that we can use and a bonus one which you can download from civet ey and use for the eyes let's go through each of these models in a bit more detail here I'm showing the different models and what they detect on the top row then the output of the after detailer in painting on the bottom row the face YOLO v8n and face YOLO V8s models both detect faces the V8s model is a bit larger however as we can see on the bottom row of images in practice there is not a lot of difference for the resulting output the person YOLO v8n and person YOLO V8s models detect entire bodies again the V8s model is a little different but the output is very similar if you ever have any trouble detecting either faces or entire bodies with the v8n model you can switch to the V8s model to see if it will give you any better results note as we can see after the inpainting the two outputs for the body models still have messed up faces this is because when in painting the whole body there are only a small number of pixels dedicated to the face it's similar to redrawing the entire image again needless to say you can't expect the whole body models to fix the faces you will need to run a second instance of the face model in the second tab to fix the faces you probably have noticed there is a small number on top of each detection box this number is the detection model's confidence value for example a value of 0.84 on the face Box means that the model is 84% confident that it has detected a face there is a corresponding detection model confidence threshold value in the web UI it is set to 0.3 by default which means that if the model detects anything with a confidence value that is below 0.3 then the object is rejected or not detected the default value works well but if you run into situations where after detailer is not detecting anything when you think it should be detecting something then you might consider lowering this threshold value continuing with the other models within after detailer the media pipe face full media pipe face short and the media pipe face mesh models are different methods for face detection as we can see the first two models uses dots to represent the positions of different facial features and the last one uses a mesh these three face detection methods are kind of Hit or Miss depending on your image sometimes it cannot detect the face at all so in general I would recommend to use the Yola face detection methods however in case you run into a difficult situation with detecting the face in your image you will always have these Alternatives that you can try the next model is the media pipe face mesh Eyes Only model like the name suggests this one is for detecting eyes this model like the media pipe face mesh model does not always successfully detect the eyes so I have an alternative suggestion we can use the eyes. PT detection model this eye detection model does not come with the after detailer extension but we can download it from civit AI I have a link down in the descriptions for convenience download the file and unzip it you will see the eyes. PT file go to your main stable diffusion installation folder then the models folder then the a detailer subfolder then copy and paste the eyes. PT file here afterwards you will be able to select this model in the drop-down list we can see this model is much more consistent even when the media pipe face mesh eyes model does not detect anything this model will detect the eyes with relatively high confidence last but not least is the hand YOLO v8n model that will detect hands in your image this detection method is pretty good even though the hands are usually small in an image this model will manage to detect the hands you can lower the detection confidence threshold in case the hands are harder to detect however detecting hands and fixing hands are two very different issues once the hands are detected after detailer will inpaint them but as you know inpainting hands does not guarantee the hands will come come out looking great in this example image the inpainted hands looks just okay and now that we know which model does what let's go through the different functionalities of after detailer first we have the positive prompt and negative prompt Fields if you leave them blank a detailer will take your original prompts and use them during inpainting so if you are just looking to enhance and fix the character's face then you don't really need to fill anything in these fields however if you want to paint the hands in this case female hands I suggest writing feminine hands in the positive prompt field for your hand YOLO model after detailer has four different sections detection mass pre-processing inpainting and control net let's go through each of these in detail first the detection section since we already talked about detection confidence threshold let's not repeat it here mask Min area ratio and mask Max area ratio these two numbers work together to set a boundary for the size of the objects being detected by default Min is set to zero and Max is set to one which means objects of all sizes ranging from 0% of the Total Image area to 100% of the Total Image area will be detected and nothing is rejected but if you do not want to detect objects that are very small relative to the overall size of the image you can set the Min value a little higher then there's mask only the top K largest slider you can use this option to restrict the number of objects being detected in your image starting from the largest object by area this can be set as any integer from 0 to 10 I have not found a great use case for this option so I just keep it at zero next up is the mask pre-processing section the X and Y offsets will move the position of the Mask by the specified amount this setting follows the normal XY cartisian coordinates where positive X values are to the right and positive y values are going up in most cases you won't need to change these from the default zero values since the detected mask is usually very accurate the default mask erosion and dilation value is four increasing this value will make the inpainting mask area larger and decreasing the value will make the masked area smaller this value ranges from -128 to 128 there are three mask merge options the default none option will inpaint each detected objects as normal the merge option will merge all detected masks first and then inpaint the merge and invert option will merge all masks and invert the selection then in paint the inverted selection you can use this option to in paint the background for example if you use one of the person YOLO models but I haven't found any good usage for the merge option let me know down in the comments if you have any good use cases for the merge mode now we go to the inpainting section this section is basic basically the same as our normal image to image in paint interface the settings all do the same thing they are just laid out a bit differently I will go through each setting and show you the corresponding setting in imageo image in paint on the right hand side mask blur is the same parameter as the one in image to image it will change how much the inpainted area is being blurred which help to avoid sharp edges the default value of four usually works well but you can increase this value if you are seeing sharper edges around your inpainted area the inpaint only masked checkbox is enabled by default and it controls the inpaint only masked padding slider the masked padding slider specifies how many pixels around the mask is being used as context for the model to generate the new inpainted stuff with this inpaint only mask checkbox checked it is the equivalent of selecting the only masked option in the normal image 2 image interface this is telling the model to only consider the area under the mask and the number of pixels surrounding the mask as context for generating the new inpainted stuff unchecking this box will disable the Mas padding pixel slider and this is equivalent to selecting the whole picture option within the regular imageo image in painting interface then there is the denoising strength slider if you have seen my other inpainting videos then you already know this value is very important increasing it will introduce more changes in your output image and decreasing it will mean less changes by default after detailer we'll use your main image generation width and height but there is an option here to use a different width and height during inpainting be sure to check this check box for the inpaint width and height to be used if the box is not checked these changes will be ignored the next few sets settings are pretty much self-explanatory you can ask after detailer to use a different sampling steps a different CFG scale use a different checkpoint vae sampling method noise multiplier and clip skip value all of these settings work the same as their text to image or imageo image counterparts so I won't go through each in detail I will however add a note here for the noise multiplier for imageo image value I couldn't find a clear answer online but here's what I pieced together and adding my own interpretation so take it with a grain of salt the noise multiplier value is applied to a so-called latent tensor or a matrix of random noise the latent tensor is applied to your original image during image to image generation which could change your original image by a little or a lot depending on your denoising strength value so the noise multiplier value is essentially controlling how much random noise is being added to the latent tensor and and in turn controlling how much noise is added to your output image here's a more concrete example with different noise multiplier values used a value of one means no change a value of more than one means more noise being added and a value of less than one means less noise being added therefore we see in these example images that for a value of 0.5 we get a less noisy output and a value of 1.5 we get a more noisy output so what does this mean for your image generation I think it makes sense to adjust the noise multiplier less than one to get a cleaner result or you can just leave it alone lastly just don't use the restore faces option okay so the last section here is the control net section at the risk of overgeneralizing the usefulness of this section basically we have a bunch of control net models that will help us keep the output image composition the same as your input image image when in painting this is useful when you need to dial the in painting denoising strength higher here is an example we can see that by increasing the denoising strength to 0.8 the model is trying to generate another portrait within the face area which is clearly not good so you can select the control net inpaint Global harmonious option to correct for this here we see the different control net models available within after detailer and what the corresponding prepr processors due to the image the five pre-processors shown here all help you control the overall composition of your image a note on the tile model the pre-processor for the tile model is not very interesting because it's just taking the original image and breaking it apart into smaller tiles this control net model has two behaviors one it ignore the details in the original image and generate new details and two it ignore Global prompts if the prompts and the local tile semantics doesn't match and it will guide diffusion with the local context so here we see that the tiles model added more details to her suit and the background while maintaining the overall composition of the image you might be thinking so all of this is cool and all but how will it help me in paint my image well let me show you let's go through an advanced usage case that will inpaint the image on the left and turn it into the image on the right before we start do me a favor and click the like And subscribe buttons to help support this channel your likes and subscriptions Help Me Grow this Channel and allow me to continue making quality content thank you okay so I've previously generated this image with a simple prompt and I want to use after detailer to help me inpaint these three girls into Tifa aith and yui from Final Fantasy 7 in that order we will do this in image to image first I am adjusting the imageo image denoising strength to 0.2 so that the origal origal image doesn't change much I will enable after detailer and use the person YOLO v8n model so here is where the advanced usage comes in I want to inpaint all three characters at the same time but usually if you inpaint three faces or people at the same time you will get three of the same faces but after detailer has this sep token that can be used when multiple objects are detected and this token will separate the prompts and allow us to input a different set of prompts for each object that is being imp painted note if there are more detected objects than separate prompts then the last prompt will be used for the rest of the objects here is how I created my prompts for the positive prompt I have previously created three different sets of prompts that will generate each of the ff7 characters using luras I will note which luras I used in the video descriptions then I put the prompts in order Tifa first then aith then yui and of course using the sep token to separate each of the prompt blocks this will ensure that the characters are inpainted in order also remember in the beginning of the video when I said to change the sort bounding boxes option to position left to right this option helps to keep the in paint order consistent I kept the detection and mass pre-processing parameters at their default values and only increased the mass dilation from 4 to 8 I later compared Mass dilation at 4 versus 8 and there were not a whole lot of differences in the first generation I left the denoising strength at 0.4 to see what it will look like and as we can see the results were not ideal the characters Beed some resemblance but did not fully convert so this requires us to turn up the denoising strength to 0.8 however after cranking up the denoising strength the inpainted area was not coherent so this required us to turn on control net to maintain our composition in this this case I use the open pose control net model then run the image generation again and now we have a decent image where the characters look the way we want as we have talked about earlier in the video If You imp paint the entire person or body the face is still going to be messed up so I am running the face YOLO model on the second after detailer tab to fix the faces for the prompts you simply want to copy over your entire positive and negative prompt for the the face model then I'm also running a third after detailer tab to inpaint the hands you can write feminine hands in the prompts for the hand YOLO model then when everything is ready generate again the image generation here took a few minutes because it is in painting three bodies then three faces and then a few hands so I will fast forward through it we can see that the final image after all the inpainting is quite good there are some artifacts and details that we need to clean up but those are fairly easy to do with the inpainting methods that that we have discussed in previous videos check them out if you need some help with in painting and cleaning up random stuff in your image and here's the final image on the right after I cleaned things up and performed a latent upscale also I decided to switch the positions of Tifa and aith because it looked better okay that's it for today I hope you enjoyed this video and found it helpful I would appreciate it if you show your support by clicking on the like button and subscribe to this channel it will help me a lot thank you and I will see you in the next video
Info
Channel: Keyboard Alchemist
Views: 11,780
Rating: undefined out of 5
Keywords: stable diffusion, automatic 1111, stable diffusion tutorials, a1111, AI Art, AI, Tips and Tricks, Tutorials
Id: 6EraysHdhHE
Channel Id: undefined
Length: 19min 29sec (1169 seconds)
Published: Fri Oct 06 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.