Bing-su / adetailer

Auto detecting, masking and inpainting with detection model.
GNU Affero General Public License v3.0
4.18k stars 326 forks source link

NansException #593

Closed 158zd closed 6 months ago

158zd commented 6 months ago

Describe the bug

NansException:Using separate steps, the facial features in the image remain unchanged, just like when ADetailer is not used

Steps to reproduce

The error persists after restarting

Screenshots

image

Console logs, from start to end.

Loading VAE weights specified in settings: D:\ai\stable-diffusion-webui\models\VAE\klF8Anime2VAE_klF8Anime2VAE.safetensors
Applying attention optimization: xformers... done.
Model loaded in 17.0s (load weights from disk: 1.0s, create model: 1.5s, apply weights to model: 13.7s, load VAE: 0.3s, calculate empty prompt: 0.2s).
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████| 30/30 [00:09<00:00,  3.12it/s]
Total progress: 100%|█████████████████████████████████████████████████████████████████████████████████████████████| 30/30 [00:06<00:00,  4.47it/s] 
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████| 30/30 [00:07<00:00,  4.13it/s] 
Total progress: 100%|█████████████████████████████████████████████████████████████████████████████████████████████| 30/30 [00:06<00:00,  4.36it/s] 
0: 640x384 1 face, 169.9ms
Speed: 4.0ms preprocess, 169.9ms inference, 24.0ms postprocess per image at shape (1, 3, 640, 384)
Reusing loaded model tissuemixReality_v10.safetensors [14c5a15808] to load XLBailingXLFantastic_v1036.safetensors [80ec5baa18]
Loading weights [80ec5baa18] from D:\ai\stable-diffusion-webui\models\Stable-diffusion\XLBailingXLFantastic_v1036.safetensors
Creating model from config: D:\ai\stable-diffusion-webui\repositories\generative-models\configs\inference\sd_xl_base.yaml
Loading VAE weights specified in settings: D:\ai\stable-diffusion-webui\models\VAE\klF8Anime2VAE_klF8Anime2VAE.safetensors
Applying attention optimization: xformers... done.
Model loaded in 10.5s (create model: 0.9s, apply weights to model: 8.5s, apply half(): 0.4s, load VAE: 0.2s, move model to device: 0.3s, calculate empty prompt: 0.1s).
  0%|                                                                                                                      | 0/61 [00:10<?, ?it/s]
[-] ADetailer: 'NansException' occurred with 1st settings.
A tensor with all NaNs was produced in Unet. This could be either because there's not enough precision to represent the picture, or because your   
video card does not support half type. Try setting the "Upcast cross attention layer to float32" option in Settings > Stable Diffusion or using the
--no-half commandline argument to fix this. Use --disable-nan-check commandline argument to disable this check.
Total progress: 100%|█████████████████████████████████████████████████████████████████████████████████████████████| 30/30 [00:39<00:00,  1.33s/it]
Total progress: 100%|█████████████████████████████████████████████████████████████████████████████████████████████| 30/30 [00:39<00:00,  4.36it/s]

List of installed extensions

ADetailer

dosubot[bot] commented 6 months ago

The NansException you're encountering suggests an issue with NaN (Not a Number) values during processing, likely due to insufficient precision or unsupported half type by your video card. To address this, try enabling the "Upcast cross attention layer to float32" in the settings or use the --no-half command-line argument.

For the issue of unchanged facial features despite using ADetailer, it's important to adjust the ADetailer configuration for optimal facial feature detection and enhancement. Ensure the ADetailer parameters, such as ad_model for the model specializing in facial features, ad_confidence for detection confidence, and ad_dilate_erode for improving the mask around facial features, are correctly set. Tweaking these parameters can significantly improve face detection and processing results.

Additionally, integrating ControlNet models with parameters like ad_controlnet_model and ad_controlnet_weight can enhance facial feature restoration and enhancement. Adjusting these settings according to your needs should help mitigate the issues you're facing.

For detailed configuration options, refer to the adetailer/args.py file and the ADetailer extension's main script in the repository. Properly setting these parameters can lead to better detection and inpainting results for facial features.

#### Details **Sources** - [Ugly and natural face](https://github.com/Bing-su/adetailer/issues/292) - [scripts/!adetailer.py](https://github.com/Bing-su/adetailer/blob/main/scripts/!adetailer.py) - [adetailer/ui.py](https://github.com/Bing-su/adetailer/blob/main/adetailer/ui.py) - [adetailer/args.py](https://github.com/Bing-su/adetailer/blob/main/adetailer/args.py)
**About Dosu** This response is meant to be useful and save you time. It is **not meant to be a precise solution**, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

Elise96nl commented 5 months ago

redownload models. put in in seperate folder (fixed models) and give it a hard read only attribute. Use seperate checkpoint for adetailer, so it has to reload between txt2image and adetailer. also allow only 1 model in memory.

I've had no nans errors after doing that