Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'Tensor' object has no attribute 'last_hidden_state' #1085

Closed
ParityError opened this issue Sep 26, 2022 · 5 comments · Fixed by #1978
Closed

AttributeError: 'Tensor' object has no attribute 'last_hidden_state' #1085

ParityError opened this issue Sep 26, 2022 · 5 comments · Fixed by #1978
Labels
asking-for-help-with-local-system-issues This issue is asking for help related to local system; please offer assistance

Comments

@ParityError
Copy link
Contributor

ParityError commented Sep 26, 2022

Describe the bug
When attempting to generate from the web interface I'm presented with an AttributeError. The issue seems similar to #474 and #13.

To Reproduce
Steps to reproduce the behavior:

  1. ./stable-diffusion-webui/run_webui_mac.sh
  2. Click on Generate
  3. AttributeError shows in the terminal output and generate does nothing
  4. See error

Expected behavior
No error.

Desktop (please complete the following information):

  • OS: macOS 12.6 (Apple M1)
  • Safari Version 16.0 (17614.1.25.9.10, 17614)
  • Commit revision [db4ab47f09450cbeb454a6e02698cb636a456878]

Additional context
Complete output of the error below; I've also included the lines you asked to be included from issue #474, which show in the output.

% ./stable-diffusion-webui/run_webui_mac.sh
WARNING: overwriting environment variables set in the machine
overwriting variable PYTORCH_ENABLE_MPS_FALLBACK
WARNING: overwriting environment variables set in the machine
overwriting variable PYTORCH_ENABLE_MPS_FALLBACK
error: cannot pull with rebase: You have unstaged changes.
error: please commit or stash them.
Warning: Taming Transformers not found at path /Users/Me/taming-transformers/taming
Warning: CodeFormer not found at path /Users/Me/CodeFormer/inference_codeformer.py
Warning: BLIP not found at path /Users/Me/BLIP/models/blip.py
Warning: LDSR not found at path /Users/Me/latent-diffusion/LDSR.py
Warning: caught exception 'Torch not compiled with CUDA enabled', memory monitor disabled
LatentDiffusion: Running in eps-prediction mode
DiffusionWrapper has 859.52 M params.
making attention of type 'vanilla' with 512 in_channels
Working with z of shape (1, 4, 32, 32) = 4096 dimensions.
making attention of type 'vanilla' with 512 in_channels
Loading weights [7460a6fa] from /Users/Me/stable-diffusion/stable-diffusion-webui/models/model.ckpt
Global Step: 470000
Model loaded.
Running on local URL:  http://127.0.0.1:7860

To create a public link, set `share=True` in `launch()`.

txt2img: a nice dog
<class 'ldm.modules.encoders.modules.FrozenCLIPEmbedder'>
<class 'transformers.models.clip.modeling_clip.CLIPTextModel'>
<class 'torch.Tensor'>
Error completing request
Arguments: ('a nice dog', '', 'None', 'None', 20, 0, False, False, 1, 1, 7, -1.0, -1.0, 0, 0, 0, False, 512, 512, False, False, 0.7, 0, 1, '', 4, '', True, False, False, False, None, '') {}
Traceback (most recent call last):
  File "/Users/Me/stable-diffusion/stable-diffusion-webui/modules/ui.py", line 136, in f
    res = list(func(*args, **kwargs))
  File "/Users/Me/stable-diffusion/stable-diffusion-webui/webui.py", line 60, in f
    res = func(*args, **kwargs)
  File "/Users/Me/stable-diffusion/stable-diffusion-webui/modules/txt2img.py", line 41, in txt2img
    processed = process_images(p)
  File "/Users/Me/stable-diffusion/stable-diffusion-webui/modules/processing.py", line 333, in process_images
    uc = prompt_parser.get_learned_conditioning(len(prompts) * [p.negative_prompt], p.steps)
  File "/Users/Me/stable-diffusion/stable-diffusion-webui/modules/prompt_parser.py", line 104, in get_learned_conditioning
    conds = shared.sd_model.get_learned_conditioning(texts)
  File "/Users/Me/stable-diffusion/ldm/models/diffusion/ddpm.py", line 834, in get_learned_conditioning
    c = self.cond_stage_model(c)
  File "/Users/Me/.pyenv/versions/anaconda3-2022.05/envs/web-ui/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
    return forward_call(*input, **kwargs)
  File "/Users/Me/stable-diffusion/stable-diffusion-webui/modules/sd_hijack.py", line 378, in forward
    z = outputs.last_hidden_state
AttributeError: 'Tensor' object has no attribute 'last_hidden_state'

^CInterrupted with signal 2 in <frame at 0x2eaae8ec0, file '/Users/Me/.pyenv/versions/anaconda3-2022.05/envs/web-ui/lib/python3.10/site-packages/gradio/blocks.py', line 1238, code block_thread>
@ParityError ParityError added the bug-report Report of a bug, yet to be confirmed label Sep 26, 2022
@dylancl
Copy link
Collaborator

dylancl commented Sep 26, 2022

Have you tried a clean reinstall? Also, I see that you've got uncommitted changes causing the git pull --rebase to fail - restore your changes and try running again.

@dylancl
Copy link
Collaborator

dylancl commented Sep 26, 2022

Actually, all these warnings point to an incomplete/failed install

Warning: Taming Transformers not found at path /Users/Me/taming-transformers/taming Warning: CodeFormer not found at path /Users/Me/CodeFormer/inference_codeformer.py Warning: BLIP not found at path /Users/Me/BLIP/models/blip.py Warning: LDSR not found at path /Users/Me/latent-diffusion/LDSR.py

@dylancl dylancl added asking-for-help-with-local-system-issues This issue is asking for help related to local system; please offer assistance and removed bug-report Report of a bug, yet to be confirmed labels Sep 26, 2022
@ParityError
Copy link
Contributor Author

ParityError commented Sep 26, 2022

Have you tried a clean reinstall? Also, I see that you've got uncommitted changes causing the git pull --rebase to fail - restore your changes and try running again.

I have tried re-installing multiple times and encountered the same error each time. I thought it might be a case where something was not installed correctly or in the correct location, which it seems. Why would the taming transformers want to be installing two directories above the directory where my stable-diffusion-webui installation resides?

I did the installation with the mac_setup.sh script within a conda env. If this is not the route to go then please let me know, thanks.

@telans
Copy link

telans commented Sep 26, 2022

/Users/Me/taming-transformers/taming

What directory path & filesystem was the stable-diffusion-webui repo downloaded to? That path appears like the script doesn't know where it's running from. The path for that directory in my case is $HOME/[...]/stable-diffusion-webui/repositories/taming-transformers/taming

@ParityError
Copy link
Contributor Author

/Users/Me/taming-transformers/taming

What directory path & filesystem was the stable-diffusion-webui repo downloaded to? That path appears like the script doesn't know where it's running from. The path for that directory in my case is $HOME/[...]/stable-diffusion-webui/repositories/taming-transformers/taming

I executed git clone in the directory /Users/Me/stable-diffusion/, after that there was a directory /Users/Me/stable-diffusion/stable-diffusion/web-ui within it. I then executed:

% ./stable-diffusion-webui/setup_mac.sh

If you need a complete install log I can provide it.

eleurent added a commit to eleurent/stable-diffusion-webui that referenced this issue Oct 8, 2022
Otherwise, we may override it with one of the next two path (. or ..) if it is present there, and then the local paths of other modules (taming transformers, codeformers, etc.) wont be found in sd_path/../.

Fix AUTOMATIC1111#1085
AUTOMATIC1111 pushed a commit that referenced this issue Oct 8, 2022
Otherwise, we may override it with one of the next two path (. or ..) if it is present there, and then the local paths of other modules (taming transformers, codeformers, etc.) wont be found in sd_path/../.

Fix #1085
nne998 pushed a commit to fjteam/stable-diffusion-webui that referenced this issue Sep 26, 2023
fix hints (toole tip) for webui when controlnet is enabled
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
asking-for-help-with-local-system-issues This issue is asking for help related to local system; please offer assistance
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants