Mikubill / sd-webui-controlnet

WebUI extension for ControlNet
GNU General Public License v3.0
16.98k stars 1.96k forks source link

[Bug]: Reordering the UI and placing the controlnet box before the dimensions box breaks the UI #2494

Closed emorris00 closed 9 months ago

emorris00 commented 9 months ago

Is there an existing issue for this?

What happened?

If you change the 'UI item order for txt2img/img2img tabs' setting and place the dimensions after scripts then the UI breaks and you have to manually change the config.json to fix it.

Steps to reproduce the problem

  1. Go to Settings > User Interface > User Interface
  2. Change 'UI item order for txt2img/img2img tabs' settings and place dimensions after scripts
  3. Apply Settings
  4. Reload UI

What should have happened?

The UI should not completely break.

Commit where the problem happens

webui: cf2772fab0af5573da775e7437e6acdca424f26e controlnet: ba05e1ea20df0e29a3dce9fcbe3ecc30777a5271

What browsers do you use to access the UI ?

Mozilla Firefox, Microsoft Edge

Command Line Arguments

--medvram-sdxl --xformers --opt-split-attention

List of enabled extensions

LDSR Lora ScuNET SwinIR canvas-zoom-and-pan extra-options-section hypertile mobile prompt-bracket-checker Stable-Diffusion-Webui-Civitai-Helper openpose-editor sd-webui-controlnet sd-webui-lobe-theme stable-diffusion-webui-images-browser

Console logs

C:\coding\stable-diffusion>webui-user.bat
venv "C:\coding\stable-diffusion\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: v1.7.0
Commit hash: cf2772fab0af5573da775e7437e6acdca424f26e
Launching Web UI with arguments: --medvram-sdxl --xformers --opt-split-attention
Style database not found: C:\coding\stable-diffusion\styles.csv
Civitai Helper: Get Custom Model Folder
ControlNet preprocessor location: C:\coding\stable-diffusion\extensions\sd-webui-controlnet\annotator\downloads
2024-01-18 15:17:14,325 - ControlNet - INFO - ControlNet v1.1.431
2024-01-18 15:17:14,394 - ControlNet - INFO - ControlNet v1.1.431
Loading weights [fe4efff1e1] from C:\coding\stable-diffusion\models\Stable-diffusion\model.ckpt
*** Error calling: C:\coding\stable-diffusion\extensions\sd-webui-controlnet\scripts\controlnet.py/ui
    Traceback (most recent call last):
      File "C:\coding\stable-diffusion\modules\scripts.py", line 489, in wrap_call
        return func(*args, **kwargs)
      File "C:\coding\stable-diffusion\extensions\sd-webui-controlnet\scripts\controlnet.py", line 307, in ui
        group, state = self.uigroup(f"ControlNet-{i}", is_img2img, elem_id_tabname, photopea)
      File "C:\coding\stable-diffusion\extensions\sd-webui-controlnet\scripts\controlnet.py", line 246, in uigroup
        group.register_callbacks(is_img2img)
      File "C:\coding\stable-diffusion\extensions\sd-webui-controlnet\scripts\controlnet_ui\controlnet_ui_group.py", line 954, in register_callbacks
        self.register_send_dimensions(is_img2img)
      File "C:\coding\stable-diffusion\extensions\sd-webui-controlnet\scripts\controlnet_ui\controlnet_ui_group.py", line 533, in register_send_dimensions
        self.send_dimen_button.click(
      File "C:\coding\stable-diffusion\venv\lib\site-packages\gradio\events.py", line 140, in __call__
        dep, dep_index = self.trigger.set_event_trigger(
      File "C:\coding\stable-diffusion\venv\lib\site-packages\gradio\blocks.py", line 287, in set_event_trigger
        "outputs": [block._id for block in outputs],
      File "C:\coding\stable-diffusion\venv\lib\site-packages\gradio\blocks.py", line 287, in <listcomp>
        "outputs": [block._id for block in outputs],
    AttributeError: 'NoneType' object has no attribute '_id'

Additional information

This seems to be happening because if the dimensions box is before the controlnet box then controlnet_ui_group.py sets the outputs of the send_dimen_button to [None, None]. This is because the sliders are set in the on_after_component callback at lines 1223-1237 and those sliders haven't been created yet so the callback for them hasn't happened yet. So should be able to create a callback for when those sliders are set similar to subscribe_for_batch_dir + img2img_batch_input_dir_callbacks.

huchenlei commented 9 months ago

Yea. I do notice that we should probably delay the register of all callbacks when all ui elements are rendered. https://github.com/Mikubill/sd-webui-controlnet/issues/2270 is also blocked on this issue, as the sd_model checkpoint selection is also created after ControlNet ui code's execution.