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

[Bug]: Unable to load embeddings built in "Create Embeddings"

Open kyods opened this issue 2 years ago • 1 comments

Is there an existing issue for this?

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

What happened?

Error verifying pickled file from /Users/kyods/stable-diffusion-webui/embeddings/amyross.pt: Traceback (most recent call last): File "/Users/kyods/stable-diffusion-webui/modules/safe.py", line 135, in load_with_extra check_pt(filename, extra_handler) File "/Users/kyods/stable-diffusion-webui/modules/safe.py", line 93, in check_pt unpickler.load() File "/Users/kyods/stable-diffusion-webui/modules/safe.py", line 62, in find_class raise Exception(f"global '{module}/{name}' is forbidden") Exception: global 'torch._utils/_rebuild_device_tensor_from_numpy' is forbidden

The file may be malicious, so the program is not going to read it. You can skip this check with --disable-safe-unpickle commandline argument.

Error loading emedding amyross.pt: Traceback (most recent call last): File "/Users/kyods/stable-diffusion-webui/modules/textual_inversion/textual_inversion.py", line 134, in load_textual_inversion_embeddings process_file(fullfn, fn) File "/Users/kyods/stable-diffusion-webui/modules/textual_inversion/textual_inversion.py", line 104, in process_file if 'string_to_param' in data: TypeError: argument of type 'NoneType' is not iterable

Steps to reproduce the problem

  1. Go to the Train tab
  2. Press the "Embedding" dropdown
  3. Nothing happens.

What should have happened?

The embedding should be visible.

Commit where the problem happens

685f9631b56ff8bd43bce24ff5ce0f9a0e9af490

What platforms do you use to access UI ?

MacOS

What browsers do you use to access the UI ?

Apple Safari

Command Line Arguments

No response

Additional information, context and logs

No response

kyods avatar Dec 11 '22 18:12 kyods

Same problem. Waiting for fix.

frontend-is-magic avatar Dec 13 '22 13:12 frontend-is-magic

Same here

duendevl avatar Dec 15 '22 04:12 duendevl

Do any of you want to test the patch I created here? My testing isn't done, but I can select my embedding and process now.

BrentWilkins avatar Dec 15 '22 04:12 BrentWilkins

@BrentWilkins, I replaced safe.py with your edited version in #5759, restarted the webui, and it did not make a difference for me. Did I miss a step?

barryanders avatar Dec 15 '22 08:12 barryanders

I cannot reproduce the problem. Can it be some extension writing weird stuff to created embeddings?

AUTOMATIC1111 avatar Dec 24 '22 05:12 AUTOMATIC1111

I have just tested it again in both Safari and Firefox, private mode, with all the browser and SD extensions disabled (since I wasn't sure which ones you were referring to). I can create and select a hypernetwork (the training process itself fails to start, though, the same issue as in https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/5684), but my custom embedding is still not visible in the drop-down list.

kyods avatar Dec 24 '22 10:12 kyods

@BrentWilkins, I replaced safe.py with your edited version in #5759, restarted the webui, and it did not make a difference for me. Did I miss a step?

My validation failed after a day or two of running. I added another commit 4 days ago that has it all working on my system. I'm able to do textual inversions, have the progress saved to a PyTorch, and then use those to generate images. I'd try again if you don't have it working.

BrentWilkins avatar Dec 24 '22 15:12 BrentWilkins

I cannot reproduce the problem. Can it be some extension writing weird stuff to created embeddings?

I initially wondered the same thing, so I tried another browser with no luck. safe.py was trashing torch stuff that it needs to run.

BrentWilkins avatar Dec 24 '22 16:12 BrentWilkins

I have just tested it again in both Safari and Firefox, private mode, with all the browser and SD extensions disabled (since I wasn't sure which ones you were referring to). I can create and select a hypernetwork (the training process itself fails to start, though, the same issue as in #5684), but my custom embedding is still not visible in the drop-down list.

Don't worry about web browser extensions, it is the web UI extensions (such as Dreambooth) that can be problematic. Also, disabling the web UI extensions is not enough - you will have to remove them from the extensions folder.

brkirch avatar Dec 26 '22 05:12 brkirch

Fresh installation of Brave browser, all the built-in (don't use any other) web UI extensions removed from their folder, no improvement.

kyods avatar Dec 26 '22 07:12 kyods

Do you have the latest web UI commits? If you haven't already git pull to make sure you are up to date. If you are still getting an error, post the output here as it should differ slightly from what you had before.

brkirch avatar Dec 26 '22 07:12 brkirch

Confirmed working with the latest commits. Thanks for the help!

kyods avatar Dec 30 '22 10:12 kyods

Seems I'm still having the same issue even with the latest version.

Error loading embedding mwte.pt:
Traceback (most recent call last):
  File "/Users/kelvinzhao/Documents/stable-diffusion-webui/modules/textual_inversion/textual_inversion.py", line 206, in load_from_dir
    self.load_from_file(fullfn, fn)
  File "/Users/kelvinzhao/Documents/stable-diffusion-webui/modules/textual_inversion/textual_inversion.py", line 164, in load_from_file
    if 'string_to_param' in data:
TypeError: argument of type 'NoneType' is not iterable

kelvin-zhao avatar Feb 18 '23 00:02 kelvin-zhao

Seems I'm still having the same issue even with the latest version.

Error loading embedding mwte.pt:
Traceback (most recent call last):
  File "/Users/kelvinzhao/Documents/stable-diffusion-webui/modules/textual_inversion/textual_inversion.py", line 206, in load_from_dir
    self.load_from_file(fullfn, fn)
  File "/Users/kelvinzhao/Documents/stable-diffusion-webui/modules/textual_inversion/textual_inversion.py", line 164, in load_from_file
    if 'string_to_param' in data:
TypeError: argument of type 'NoneType' is not iterable

I don't remember how I got it to work exactly, but have you tried reinstalling stable-diffusion-webui from scratch? I think that's worth a shot.

barryanders avatar Feb 21 '23 15:02 barryanders

I wouldn't recommend copying any changes manually without verifying you are applying them to the correct version. I pulled commit 3715ece0adce7bf7c5e9c5ab3710b2fdc3848f39 from the master branch last week or so and it works fine for me. I had played around with versions of PyTorch, and I got an error about the version with the latest code. I updated to these versions:

$ venv/bin/python -m pip freeze | grep torch    
open-clip-torch @ git+https://github.com/mlfoundations/open_clip.git@bb6e834e9c70d9c27d0dc3ecedeebeaeb1ffad6b
pytorch-lightning==1.7.6
torch==1.13.1
torchdiffeq==0.2.3
torchmetrics==0.11.1
torchsde==0.2.5
torchvision==0.14.1

I used something like this:

$ venv/bin/python -m pip install -U torch

BrentWilkins avatar Feb 21 '23 16:02 BrentWilkins