Technology Sharing

AI painting Stable Diffusion always distorts faces when drawing full-body pictures? ADetailer plugin solves this problem with one click!

2024-07-11

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

Hello everyone, I am Xiangyang

Have you ever encountered a situation where the face of a character generated by SD is distorted or even disgusting? Have you ever felt helpless? Don't worry, this tutorial is for you.

When using SD to generate full-body photos of people, you may often find that the person's face is distorted. This is because the proportion of facial pixels is too small, resulting in the inability to fully restore facial information.

A common way to solve this problem is to use the local repainting (inpaint) tool. By setting appropriate parameters, you can often achieve very good results.

However, if you want to generate a large number of full-body images of people, you have to draw a mask and adjust the parameters for each image, which is very cumbersome. Even if you do this for a single image, you may feel annoyed sometimes. So is there a plug-in that can automatically repair distorted faces? The answer is: Yes!

After detailer (Adetailer for short) is the best solution. This plug-in can automatically detect faces in generated images, automatically apply masks to faces, and automatically redraw them. The entire process is done in one go, so many repeated operations can be avoided.In addition, Adetailer can detect the hands, eyes and even the whole body of a person and redraw these parts. One of Adetailer's functions is that it can be used with ControlNet.

I'm sure that after using ADetailer, you will never use inpaint to fix facial distortion! But we can still use inpaint to handle other situations.

The following is a method to use local repainting (inpaint) and Adetailer to repair the face.


1. Installation of ADetailer

Before you begin, please follow the steps below to install the plugin.

① Open the browser: https://github.com/Bing-su/adetailer

Note: This method requires a scientific Internet connection. If you cannot download it, please scan at the end of the article to get the ADetailer plugin installation package for free.

③ Unzip the downloaded compressed package and move the folder to AI-stable-diffusion-webuiextensionsPath

④ After installation, the first time you start the webui, you may get stuck at the following interface. At this time, open the task manager. If you see that the network is receiving data, then there is no problem. Just wait for the download to complete.

⑤ After opening the webui, you can find the plug-in in the following location

2. Face repair method

The input images used by all the repair methods in this tutorial are as follows. It can be found that the distortion of the face is quite serious.

1. Partial repainting (inpaint)

1) Usage

① Send the image generated by the text image interface to the local redraw. If it is an external image, first upload the image to the image information (PNG info) page, and then send it to the local redraw.

② Use the brush to paint the face of the character completely, as shown below

③ The inpaint area must beSelect only mask, so that the model will use the full image resolution (my image is 512x768) to generate the mask area, generate a high-resolution face image, and then scale it to the original resolution, so that a normal face can be generated.

④ The redraw amplitude is set to less than 0.6, otherwise normal faces cannot be generated. The seed can be set to random and the number of generated faces can be increased.

⑤ Click Generate

⑥ You can find that it has been perfectly restored. The same method can also be used to repair hands, backgrounds, clothing details, etc.

⑦ You will find that the face in the above picture does not change much. If you want to get more different facial expressions, you need to use it with controlnet's inpaint. The method is as follows

⑧ Open the controlnet panel, no need to upload pictures, other settings are as follows

⑨ Set the redraw amplitude to 1, or lower, depending on how big a change you want. Keep all other parameters the same.

⑩ Click Generate

Finally, send the generated image to the post-processing (Extra) page, enlarge it 4x and turn on face repair, and you can get a very good effect.

2) Parameter details

The most important parameter for local redrawing is the denosing strength. Don’t set this value too high. A value greater than 0.6 can easily cause facial collapse.

2、Adetailer

The effect of Adetailer is similar to partial redrawing, but Adetailer helps us save the steps of drawing masks and setting parameters, and realizes the function of one-click face repair. Adetailer model can recognize the face of the person in the picture, automatically draw a mask, and then use the default parameters to process it, and finally get the repaired effect.

1) Usage

ADtailer can be used in the text-to-graph interface, or in the graph-to-graph interface with more complex parameter settings to obtain richer generation effects.

Wenshengtu interface:

① Perform other settings as usual for the Wensheng diagram

② Open Adetailer, select Enable, and leave the model as default

③ Click Generate

④ Comparison with the original image

Image interface:

① Send the image generated by the text-to-image interface to the image-to-image interface, so that the prompt words and other settings will be automatically filled in

Set the redraw amplitude to 0.1 or lower

③ Open Adetailer and selectEnable, the model defaults

④ Click Generate. If the redraw amplitude is very low, the effect is basically the same as using ADetailer in the Wenshengtu interface, so it will not be shown here.

2) Parameter details

Detection model

Detection models can be divided into the following categories

  • Face_xxxx: Detect and redraw faces

  • Hand_xxxx: detect and redraw hands

  • Person_xxxx: detect and redraw the entire person

  • Mediapipe_face_xxxxx: detect and redraw faces

face_yoloandperson_yoloThe models are the two most useful models. The default option is the face_yolo model. The effect of the face_yolo model has been demonstrated above and will not be given again. The effect of the person_yolo model is as follows. The whole character will undergo certain changes.

The Hands model can detect and redraw hands, but don't hold your breath for this feature. It's currently difficult for the SD model to draw good hands, so no matter how many times you redraw, the result may not be perfect, but you can always get a relatively good-looking picture.

In addition, the suffix of the model name8sand8nWhat is the significance? For comparison, see the following figure:

In short, the number of parameters of 8s is more than three times that of 8n, which means that the processing time of 8s will be longer than that of 8n, but the effect is better. The effect of 8n model in repairing the face is already very good, so usually you can choose 8n, and switch to 8s model if the repair is not good.

Finally, you may notice the following options in Adetailer

Adetailer allows you to set up to two detection and redraw models, and will repair them one by one after setting. If you want to perform more detections at one time, you need to set them in settings.