klimaleksus / stable-diffusion-webui-embedding-merge

Extension for AUTOMATIC1111/stable-diffusion-webui for creating and merging Textual Inversion embeddings at runtime from string literals.
The Unlicense
110 stars 10 forks source link

expected Tensor, but got tuple #15

Open knight-captain opened 8 months ago

knight-captain commented 8 months ago

After updating Auto1111 a couple weeks ago, EM stopped working. It can analyze the tokens, but when it tries to save an embedding I get the following stack trace:

Traceback (most recent call last):
  File [file path]"\stable-diffusion-webui-embedding-merge\scripts\embedding_merge.py", line 1231, in need_save_embed
    vectors = [torch.cat([r[0] for r in pair[0]])]
TypeError: expected Tensor as element 0 in argument 0, but got tuple
aleksusklim commented 7 months ago

Can you remove the extension (delete stable-diffusion-webui\extensions\stable-diffusion-webui-embedding-merge\ folder) and reinstall it again with default settings?

I could not see the error with updated WebUI dev branch. If you still can trigger it with updated EM (on sdxl branch) and latest A1111, then tell me which model do you use (SD1, SD2 or SDXL)?

victorca25 commented 5 months ago

Same issue, I just installed a fresh version of the repo for the first time an got the error on Forge

victorca25 commented 5 months ago

In case it's useful, the problem is that the structure of pair is not correct. According to the code, it expects that r[0] is the token vector, but instead it's a tuple of (tensor, str, list), so you would need to use: vectors = [torch.cat([r[0][0] for r in pair[0]])] After this change, it works fine

aleksusklim commented 5 months ago

There is no way the existing code can be incorrect.

Something is probably off in inputs? Or it takes a strange codepath.

I'll try installing Forge from scratch to see this.

zethfoxster commented 3 months ago

going to add to this TypeError: expected Tensor as element 0 in argument 0, but got tuple it happens only when saving a "by comma" embedding

zethfoxster commented 3 months ago

In case it's useful, the problem is that the structure of pair is not correct. According to the code, it expects that r[0] is the token vector, but instead it's a tuple of (tensor, str, list), so you would need to use: vectors = [torch.cat([r[0][0] for r in pair[0]])] After this change, it works fine

this does indeed fix the issue completely