Bing-su / adetailer

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

[Bug]: Waiting to Interrupt skips ADetailer (Forge) #692

Closed younyokel closed 21 hours ago

younyokel commented 3 weeks ago

Describe the bug

When "Don't Interrupt in the middle" is enabled, before generation ends, it skips over ADetailer. I use Forge, maybe it's related to latest rework

Steps to reproduce

  1. Enable "Don't Interrupt in the middle"
  2. Enable ADetailer
  3. Generate (must be >1 batch count)
  4. Press Interrupt during generation

Screenshots

No response

Console logs, from start to end.

venv "D:\Program Files\stable-diffusion-webui-forge\venv\Scripts\Python.exe"
Python 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)]
Version: f2.0.1v1.10.1-previous-415-gf23ee63c
Commit hash: f23ee63cb340504c15607cc68798cd28abb88037
Launching Web UI with arguments: --autolaunch
Total VRAM 6144 MB, total RAM 16295 MB
pytorch version: 2.3.1+cu121
Set vram state to: NORMAL_VRAM
Device: cuda:0 NVIDIA GeForce RTX 2060 : native
Hint: your device supports --cuda-malloc for potential speed improvements.
VAE dtype preferences: [torch.float32] -> torch.float32
CUDA Using Stream: False
Using pytorch cross attention
Using pytorch attention for VAE
ControlNet preprocessor location: D:\Program Files\stable-diffusion-webui-forge\models\ControlNetPreprocessor
[-] ADetailer initialized. version: 24.8.0, num models: 10
2024-08-23 20:58:22,065 - ControlNet - INFO - ControlNet UI callback registered.
Model selected: {'checkpoint_info': {'filename': 'D:\\Program Files\\stable-diffusion-webui-forge\\models\\Stable-diffusion\\ponyDiffusionV6XL.safetensors', 'hash': 'e577480d'}, 'additional_modules': [], 'unet_storage_dtype': None}
Using online LoRAs in FP16: False
Running on local URL:  http://127.0.0.1:7860

To create a public link, set `share=True` in `launch()`.
IIB Database file has been successfully backed up to the backup folder.
Startup time: 27.6s (prepare environment: 6.4s, import torch: 9.9s, initialize shared: 0.3s, other imports: 0.8s, load scripts: 4.7s, create ui: 3.1s, gradio launch: 1.7s, app_started_callback: 0.6s).
Environment vars changed: {'stream': False, 'inference_memory': 1024.0, 'pin_shared_memory': False}
[GPU Setting] You will use 83.33% GPU memory (5119.00 MB) to load weights, and use 16.67% GPU memory (1024.00 MB) to do matrix computation.
Loading Model: {'checkpoint_info': {'filename': 'D:\\Program Files\\stable-diffusion-webui-forge\\models\\Stable-diffusion\\ponyDiffusionV6XL.safetensors', 'hash': 'e577480d'}, 'additional_modules': [], 'unet_storage_dtype': None}
[Unload] Trying to free all memory for cuda:0 with 0 models keep loaded ...
StateDict Keys: {'unet': 1680, 'vae': 248, 'text_encoder': 197, 'text_encoder_2': 518, 'ignore': 0}
Working with z of shape (1, 4, 32, 32) = 4096 dimensions.
K-Model Created: {'storage_dtype': torch.float16, 'computation_dtype': torch.float16}
Model loaded in 1.7s (unload existing model: 0.2s, forge model load: 1.5s).
To load target model JointTextEncoder
Begin to load 1 model
[Unload] Trying to free 3051.58 MB for cuda:0 with 0 models keep loaded ...
[Memory Management] Current Free GPU Memory: 5093.15 MB
[Memory Management] Required Model Memory: 1559.68 MB
[Memory Management] Required Inference Memory: 1024.00 MB
[Memory Management] Estimated Remaining GPU Memory: 2509.47 MB
Moving model(s) has taken 3.99 seconds
[Unload] Trying to free 1024.00 MB for cuda:0 with 1 models keep loaded ...
[Unload] Current free memory is 3301.44 MB ...
To load target model KModel
Begin to load 1 model
[Unload] Trying to free 7630.80 MB for cuda:0 with 0 models keep loaded ...
[Unload] Current free memory is 3300.59 MB ...
[Unload] Unload model JointTextEncoder
[Memory Management] Current Free GPU Memory: 5060.95 MB
[Memory Management] Required Model Memory: 4897.05 MB
[Memory Management] Required Inference Memory: 1024.00 MB
[Memory Management] Estimated Remaining GPU Memory: -860.10 MB
[Memory Management] Loaded to CPU Swap: 1791.83 MB (blocked method)
[Memory Management] Loaded to GPU: 3105.22 MB
Moving model(s) has taken 2.28 seconds
100%|████████████████████████████████████████████████████████████████████████| 30/30 [00:39<00:00,  1.31s/it]
To load target model IntegratedAutoencoderKL█████                            | 30/60 [00:37<00:38,  1.29s/it]
Begin to load 1 model
[Unload] Trying to free 8820.57 MB for cuda:0 with 0 models keep loaded ...
[Unload] Current free memory is 1859.30 MB ...
[Unload] Unload model KModel
[Memory Management] Current Free GPU Memory: 5030.46 MB
[Memory Management] Required Model Memory: 319.11 MB
[Memory Management] Required Inference Memory: 1024.00 MB
[Memory Management] Estimated Remaining GPU Memory: 3687.35 MB
Moving model(s) has taken 4.80 seconds

0: 640x448 1 face, 45.2ms
Speed: 21.3ms preprocess, 45.2ms inference, 214.8ms postprocess per image at shape (1, 3, 640, 448)
[Unload] Trying to free 6819.52 MB for cuda:0 with 1 models keep loaded ...
[Unload] Current free memory is 4660.29 MB ...
*** Error running postprocess_image: D:\Program Files\stable-diffusion-webui-forge\extensions\adetailer\scripts\!adetailer.py
    Traceback (most recent call last):
      File "D:\Program Files\stable-diffusion-webui-forge\modules\scripts.py", line 940, in postprocess_image
        script.postprocess_image(p, pp, *script_args)
      File "D:\Program Files\stable-diffusion-webui-forge\extensions\adetailer\aaaaaa\traceback.py", line 173, in wrapper
        raise error from None
    IndexError:
    ╭────────────────────────────────────────────────────────────────────────────────────────────────────────╮    │                                              System info                                               │    │ ┏━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ │    │ ┃             ┃ Value                                                                                ┃ │    │ ┡━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │    │ │    Platform │ Windows-10-10.0.19045-SP0                                                            │ │    │ │      Python │ 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)]   │ │    │ │     Version │ f2.0.1v1.10.1-previous-415-gf23ee63c                                                 │ │    │ │      Commit │ f23ee63cb340504c15607cc68798cd28abb88037                                             │ │    │ │ Commandline │ ['launch.py', '--autolaunch']                                                        │ │    │ │   Libraries │ {'torch': '2.3.1+cu121', 'torchvision': '0.18.1+cu121', 'ultralytics': '8.2.78',     │ │    │ │             │ 'mediapipe': '0.10.14'}                                                              │ │    │ └─────────────┴──────────────────────────────────────────────────────────────────────────────────────┘ │    │                                                 Inputs                                                 │    │ ┏━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ │    │ ┃                 ┃ Value                                                                            ┃ │    │ ┡━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │    │ │          prompt │ score_9, score_8_up, score_7_up, source_anime, masterpiece, perfectly detailed,  │ │    │ │                 │ detailed face, detailed eyes, beautiful eyes, 1boy, dark-skinned male, muscular  │ │    │ │                 │ male, solo, looking at viewer                                                    │ │    │ │ negative_prompt │                                                                                  │ │    │ │          n_iter │ 2                                                                                │ │    │ │      batch_size │ 1                                                                                │ │    │ │           width │ 832                                                                              │ │    │ │          height │ 1216                                                                             │ │    │ │    sampler_name │ Euler a                                                                          │ │    │ │       enable_hr │ False                                                                            │ │    │ │     hr_upscaler │ Latent                                                                           │ │    │ │      checkpoint │ ponyDiffusionV6XL.safetensors                                                    │ │    │ │             vae │ Automatic                                                                        │ │    │ │            unet │ Automatic                                                                        │ │    │ └─────────────────┴──────────────────────────────────────────────────────────────────────────────────┘ │    │                 ADetailer                                                                              │    │ ┏━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┓                                                              │    │ ┃                     ┃ Value           ┃                                                              │    │ ┡━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━┩                                                              │    │ │             version │ 24.8.0          │                                                              │    │ │            ad_model │ face_yolov8n.pt │                                                              │    │ │           ad_prompt │                 │                                                              │    │ │  ad_negative_prompt │                 │                                                              │    │ │ ad_controlnet_model │ None            │                                                              │    │ │              is_api │ False           │                                                              │    │ └─────────────────────┴─────────────────┘                                                              │    │ ╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮   │    │ │ D:\Program Files\stable-diffusion-webui-forge\extensions\adetailer\aaaaaa\traceback.py:153 in    │   │    │ │ wrapper                                                                                          │   │    │ │                                                                                                  │   │    │ │   152 │   │   try:                                                                               │   │    │ │ ❱ 153 │   │   │   return func(*args, **kwargs)                                                   │   │    │ │   154 │   │   except Exception as e:                                                             │   │    │ │                                                                                                  │   │    │ │ D:\Program Files\stable-diffusion-webui-forge\extensions\adetailer\scripts\!adetailer.py:816 in  │   │    │ │ postprocess_image                                                                                │   │    │ │                                                                                                  │   │    │ │    815 │   │   │   │   │   continue                                                              │   │    │ │ ❱  816 │   │   │   │   is_processed |= self._postprocess_image_inner(p, pp, args, n=n)           │   │    │ │    817                                                                                           │   │    │ │                                                                                                  │   │    │ │ D:\Program Files\stable-diffusion-webui-forge\extensions\adetailer\scripts\!adetailer.py:787 in  │   │    │ │ _postprocess_image_inner                                                                         │   │    │ │                                                                                                  │   │    │ │    786 │   │   │   p2 = copy(i2i)                                                                │   │    │ │ ❱  787 │   │   │   p2.init_images = [processed.images[0]]                                        │   │    │ │    788                                                                                           │   │    │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯   │    │ IndexError: list index out of range                                                                    │    ╰────────────────────────────────────────────────────────────────────────────────────────────────────────╯

---

List of installed extensions

none was used directly but: sd-perturbed-attention sd-webui-aspect-ratio-helper sd-webui-hires-fix-tweaks sd-webui-infinite-image-browsing sd_extension-prompt_formatter

dosubot[bot] commented 3 weeks ago

Hello @younyokel! I'm here to help you with any bugs, questions, or contributions you have. I'm a bot and can assist you while you wait for a human maintainer.

I found a similar closed issue that might be relevant to your problem: Preview disabled during adetailer pass. The issue was related to timing and hardware performance, where increasing the number of ADetailer steps resolved the problem by allowing previews to appear after a delay. The root cause was slower hardware performance, not an issue with ADetailer itself [1].

Regarding your specific issue with the "Don't Interrupt in the middle" setting, it seems that enabling this setting causes ADetailer to be skipped when an interruption occurs during batch processing. This might be related to how ADetailer manages state and interruptions. ADetailer checks for interruptions using the state.interrupted flag, and if an interruption is detected, it stops further processing [2].

Additionally, the IndexError: list index out of range in the postprocess_image function is likely caused by accessing an empty or out-of-bounds index in the arg_list. This can happen if the list of arguments for processing is not correctly populated or if the index n is out of bounds [2].

To address this issue, you might want to:

  1. Ensure that the arg_list is correctly populated and that the index n is within bounds.
  2. Check if the interruption handling logic in ADetailer is correctly implemented and if it needs adjustments to work with the "Don't Interrupt in the middle" setting.

If the problem persists, you may need to investigate further into how the latest rework of Forge interacts with ADetailer, as there might be changes affecting this behavior.

To continue talking to Dosu, mention @dosu.