lshqqytiger / stable-diffusion-webui-amdgpu

Stable Diffusion web UI
GNU Affero General Public License v3.0
1.67k stars 175 forks source link

[Bug]: Can't select VAE in settings: 'ONNXStableDiffusionModel' object has no attribute 'first_stage_model' #359

Closed hlpientt closed 4 months ago

hlpientt commented 5 months ago

Checklist

What happened?

When I select a VAE in the settings tab, it shows an error and the VAE isn't selected.

Steps to reproduce the problem

  1. Start WebUI
  2. Go to settings tab
  3. Select the VAE menu
  4. Select a VAE from the SD VAE drop-down list
  5. Press Apply Settings

What should have happened?

It should select the VAE without an error.

What browsers do you use to access the UI ?

Google Chrome

Sysinfo

sysinfo-2024-01-14-15-53.json

Console logs

F:\stable-diffusion-webui-directml\modules\ui.py:1326: GradioDeprecationWarning: The `style` method is deprecated. Please set these arguments in the constructor instead.
  with gr.Row().style(equal_height=False):
F:\stable-diffusion-webui-directml\modules\ui.py:1448: GradioDeprecationWarning: The `style` method is deprecated. Please set these arguments in the constructor instead.
  with gr.Row().style(equal_height=False):
Running on local URL:  http://127.0.0.1:7860

To create a public link, set `share=True` in `launch()`.
Startup time: 0.4s (create ui: 0.3s).
Loading VAE weights specified in settings: F:\stable-diffusion-webui-directml\models\VAE\vae-ft-mse-840000-ema-pruned.safetensors
changing setting sd_vae to vae-ft-mse-840000-ema-pruned.safetensors: AttributeError
Traceback (most recent call last):
  File "F:\stable-diffusion-webui-directml\modules\options.py", line 146, in set
    option.onchange()
  File "F:\stable-diffusion-webui-directml\modules\call_queue.py", line 13, in f
    res = func(*args, **kwargs)
  File "F:\stable-diffusion-webui-directml\modules\initialize_util.py", line 175, in <lambda>
    shared.opts.onchange("sd_vae", wrap_queued_call(lambda: sd_vae.reload_vae_weights()), call=False)
  File "F:\stable-diffusion-webui-directml\modules\sd_vae.py", line 273, in reload_vae_weights
    load_vae(sd_model, vae_file, vae_source)
  File "F:\stable-diffusion-webui-directml\modules\sd_vae.py", line 209, in load_vae
    store_base_vae(model)
  File "F:\stable-diffusion-webui-directml\modules\sd_vae.py", line 49, in store_base_vae
    base_vae = deepcopy(model.first_stage_model.state_dict())
  File "F:\stable-diffusion-webui-directml\venv\lib\site-packages\torch\nn\modules\module.py", line 1269, in __getattr__
    raise AttributeError("'{}' object has no attribute '{}'".format(
AttributeError: 'ONNXStableDiffusionModel' object has no attribute 'first_stage_model'

Additional information

AMD Radeon RX 7900XT - Latest drivers Intel Core i7-12700F 32GB RAM

lshqqytiger commented 5 months ago

You can't load single file VAE with ONNX. If you want higher compatibility and stability, try olive branch of vladmandic/automatic which provides diffusers-integrated code base. It also supports .safetensors VAE loading.

hlpientt commented 5 months ago

You can't load single file VAE with ONNX. If you want higher compatibility and stability, try olive branch of vladmandic/automatic which provides diffusers-integrated code base. It also supports .safetensors VAE loading.

Thank you for the information, I will definitely check it out.