stable-diffusion-webui icon indicating copy to clipboard operation
stable-diffusion-webui copied to clipboard

[Bug]: Error on launching - UnboundLocalError: local variable 'res_switch_btn' referenced before assignment

Open 2x-y opened this issue 2 years ago • 6 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues and checked the recent builds/commits

What happened?

An error occurs on launching.

Steps to reproduce the problem

Launch app.

Edit: I've worked out that this occurs if the "Show Width/Height and Batch sliders in same row" setting is unchecked.

What should have happened?

No error.

Commit where the problem happens

e8a41df49fadd2cf9f23b1f02d75a4947bec5646

What platforms do you use to access the UI ?

Windows

What browsers do you use to access the UI ?

Mozilla Firefox

Command Line Arguments

None

List of extensions

No

Console logs

venv "C:\Users\<USER>\Documents\GitHub\stable-diffusion-webui\venv\Scripts\Python.exe"
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug  1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
Commit hash: e8a41df49fadd2cf9f23b1f02d75a4947bec5646
Installing requirements for Web UI
Launching Web UI with arguments:
No module 'xformers'. Proceeding without it.
Loading weights [cc6cb27103] from C:\Users\<USER>\Documents\GitHub\stable-diffusion-webui\models\Stable-diffusion\StableDiffusion_v15.ckpt
Creating model from config: C:\Users\<USER>\Documents\GitHub\stable-diffusion-webui\configs\v1-inference.yaml
LatentDiffusion: Running in eps-prediction mode
DiffusionWrapper has 859.52 M params.
Applying cross attention optimization (Doggettx).
Textual inversion embeddings loaded(0):
Model loaded in 3.0s (create model: 0.4s, apply weights to model: 0.7s, apply half(): 0.6s, move model to device: 0.4s, load textual inversion embeddings: 0.8s).
Traceback (most recent call last):
  File "C:\Users\<USER>\Documents\GitHub\stable-diffusion-webui\launch.py", line 360, in <module>
    start()
  File "C:\Users\<USER>\Documents\GitHub\stable-diffusion-webui\launch.py", line 355, in start
    webui.webui()
  File "C:\Users\<USER>\Documents\GitHub\stable-diffusion-webui\webui.py", line 196, in webui
    shared.demo = modules.ui.create_ui()
  File "C:\Users\<USER>\Documents\GitHub\stable-diffusion-webui\modules\ui.py", line 572, in create_ui
    res_switch_btn.click(lambda w, h: (h, w), inputs=[width, height], outputs=[width, height])
UnboundLocalError: local variable 'res_switch_btn' referenced before assignment
Press any key to continue . . .

Additional information

No response

2x-y avatar Jan 28 '23 08:01 2x-y

Also experiencing this issue.

BlackWyvern avatar Jan 28 '23 10:01 BlackWyvern

This must be related to config as I've done a hard-reset and the problem has gone.

2x-y avatar Jan 28 '23 11:01 2x-y

Temporary fix, edit the "dimensions_and_batch_together" line in your config.json file so the value is true:

"dimensions_and_batch_together": true,

2x-y avatar Jan 28 '23 11:01 2x-y

Cannot confirm. Config.json is not being changed/properly read from the settings panel on a 100% stock install. Even changing the option manually in editor, changing any other value immediately reverts to the default invalid state.

Edit: Did a full reinstall again. The only option I changed was to the show width/height in line option. And then saved. Settings said 7 options were changed, and the UI option was not applied. Immediately returns to invalid state. firefox_Z0fFBO2Qu8

BlackWyvern avatar Jan 28 '23 16:01 BlackWyvern

Having same issue and can confirm setting "dimensions_and_batch_together": true, works as a workaround. I don't know the code but suspect this relates to the recent update that added a button for switching height/width.

Somasonic avatar Jan 28 '23 20:01 Somasonic

It seems to be the case. As long as I do not change the width/height inline option, the settings appear to work.

BlackWyvern avatar Jan 28 '23 21:01 BlackWyvern